From e4be25a7c5d547be06ed43166d82237cb08ad38a Mon Sep 17 00:00:00 2001 From: Marcin Kosiba Date: Tue, 25 Nov 2014 16:37:27 +0000 Subject: Fork draw_gl.h/draw_sw.h. This is to make it possible to remove external/chromium_org sources. Change-Id: Id001c75a9f32788372c713b83ee6bc5cb9259122 --- chromium/Android.mk | 1 - chromium/plat_support/draw_gl.h | 116 ++++++++++++++++++++++++++++ chromium/plat_support/draw_gl_functor.cpp | 2 +- chromium/plat_support/draw_sw.h | 66 ++++++++++++++++ chromium/plat_support/graphic_buffer_impl.h | 2 +- chromium/plat_support/graphics_utils.cpp | 4 +- 6 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 chromium/plat_support/draw_gl.h create mode 100644 chromium/plat_support/draw_sw.h (limited to 'chromium') diff --git a/chromium/Android.mk b/chromium/Android.mk index edcfdb2..b2d2cea 100644 --- a/chromium/Android.mk +++ b/chromium/Android.mk @@ -32,7 +32,6 @@ LOCAL_SRC_FILES:= \ plat_support/graphic_buffer_impl.cpp \ LOCAL_C_INCLUDES:= \ - $(CHROMIUM_PATH) \ external/skia/include/core \ frameworks/base/core/jni/android/graphics \ frameworks/native/include/ui \ diff --git a/chromium/plat_support/draw_gl.h b/chromium/plat_support/draw_gl.h new file mode 100644 index 0000000..a60346f --- /dev/null +++ b/chromium/plat_support/draw_gl.h @@ -0,0 +1,116 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +//****************************************************************************** +// This is a copy of the coresponding android_webview/public/browser header. +// Any changes to the interface should be made there. +// +// The purpose of having the copy is twofold: +// - it removes the need to have Chromium sources present in the tree in order +// to build the plat_support library, +// - it captures API that the corresponding Android release supports. +//****************************************************************************** + +#ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_ +#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +static const int kAwDrawGLInfoVersion = 1; + +// Holds the information required to trigger an OpenGL drawing operation. +struct AwDrawGLInfo { + int version; // The AwDrawGLInfo this struct was built with. + + // Input: tells the draw function what action to perform. + enum Mode { + kModeDraw = 0, + kModeProcess, + kModeProcessNoContext, + kModeSync, + } mode; + + // Input: current clip rect in surface coordinates. Reflects the current state + // of the OpenGL scissor rect. Both the OpenGL scissor rect and viewport are + // set by the caller of the draw function and updated during View animations. + int clip_left; + int clip_top; + int clip_right; + int clip_bottom; + + // Input: current width/height of destination surface. + int width; + int height; + + // Input: is the View rendered into an independent layer. + // If false, the surface is likely to hold to the full screen contents, with + // the scissor box set by the caller to the actual View location and size. + // Also the transformation matrix will contain at least a translation to the + // position of the View to render, plus any other transformations required as + // part of any ongoing View animation. View translucency (alpha) is ignored, + // although the framework will set is_layer to true for non-opaque cases. + // Can be requested via the View.setLayerType(View.LAYER_TYPE_NONE, ...) + // Android API method. + // + // If true, the surface is dedicated to the View and should have its size. + // The viewport and scissor box are set by the caller to the whole surface. + // Animation transformations are handled by the caller and not reflected in + // the provided transformation matrix. Translucency works normally. + // Can be requested via the View.setLayerType(View.LAYER_TYPE_HARDWARE, ...) + // Android API method. + bool is_layer; + + // Input: current transformation matrix in surface pixels. + // Uses the column-based OpenGL matrix format. + float transform[16]; +}; + +// Function to invoke a direct GL draw into the client's pre-configured +// GL context. Obtained via AwContents.getDrawGLFunction() (static). +// |view_context| is an opaque identifier that was returned by the corresponding +// call to AwContents.getAwDrawGLViewContext(). +// |draw_info| carries the in and out parameters for this draw. +// |spare| ignored; pass NULL. +typedef void (AwDrawGLFunction)(long view_context, + AwDrawGLInfo* draw_info, + void* spare); +enum AwMapMode { + MAP_READ_ONLY, + MAP_WRITE_ONLY, + MAP_READ_WRITE, +}; + +// Called to create a GraphicBuffer +typedef long AwCreateGraphicBufferFunction(int w, int h); +// Called to release a GraphicBuffer +typedef void AwReleaseGraphicBufferFunction(long buffer_id); +// Called to map a GraphicBuffer in |mode|. +typedef int AwMapFunction(long buffer_id, AwMapMode mode, void** vaddr); +// Called to unmap a GraphicBuffer +typedef int AwUnmapFunction(long buffer_id); +// Called to get a native buffer pointer +typedef void* AwGetNativeBufferFunction(long buffer_id); +// Called to get the stride of the buffer +typedef unsigned int AwGetStrideFunction(long buffer_id); + +static const int kAwDrawGLFunctionTableVersion = 1; + +// Set of functions used in rendering in hardware mode +struct AwDrawGLFunctionTable { + int version; + AwCreateGraphicBufferFunction* create_graphic_buffer; + AwReleaseGraphicBufferFunction* release_graphic_buffer; + AwMapFunction* map; + AwUnmapFunction* unmap; + AwGetNativeBufferFunction* get_native_buffer; + AwGetStrideFunction* get_stride; +}; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_ diff --git a/chromium/plat_support/draw_gl_functor.cpp b/chromium/plat_support/draw_gl_functor.cpp index 03b6385..a7fbe5b 100644 --- a/chromium/plat_support/draw_gl_functor.cpp +++ b/chromium/plat_support/draw_gl_functor.cpp @@ -19,7 +19,7 @@ #define LOG_TAG "webviewchromium_plat_support" -#include "android_webview/public/browser/draw_gl.h" +#include "draw_gl.h" #include #include diff --git a/chromium/plat_support/draw_sw.h b/chromium/plat_support/draw_sw.h new file mode 100644 index 0000000..7423e13 --- /dev/null +++ b/chromium/plat_support/draw_sw.h @@ -0,0 +1,66 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +//****************************************************************************** +// This is a copy of the coresponding android_webview/public/browser header. +// Any changes to the interface should be made there. +// +// The purpose of having the copy is twofold: +// - it removes the need to have Chromium sources present in the tree in order +// to build the plat_support library, +// - it captures API that the corresponding Android release supports. +//****************************************************************************** + +#ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ +#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ + +#include +#include + +#ifndef __cplusplus +#error "Can't mix C and C++ when using jni.h" +#endif + +class SkCanvasState; +class SkPicture; + +static const int kAwPixelInfoVersion = 3; + +// Holds the information required to implement the SW draw to system canvas. +struct AwPixelInfo { + int version; // The kAwPixelInfoVersion this struct was built with. + SkCanvasState* state; // The externalize state in skia format. + // NOTE: If you add more members, bump kAwPixelInfoVersion. +}; + +// Function that can be called to fish out the underlying native pixel data +// from a Java canvas object, for optimized rendering path. +// Returns the pixel info on success, which must be freed via a call to +// AwReleasePixelsFunction, or NULL. +typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas); + +// Must be called to balance every *successful* call to AwAccessPixelsFunction +// (i.e. that returned true). +typedef void (AwReleasePixelsFunction)(AwPixelInfo* pixels); + +// Called to create an Android Picture object encapsulating a native SkPicture. +typedef jobject (AwCreatePictureFunction)(JNIEnv* env, SkPicture* picture); + +// Method that returns the current Skia function. +typedef void (SkiaVersionFunction)(int* major, int* minor, int* patch); + +// Called to verify if the Skia versions are compatible. +typedef bool (AwIsSkiaVersionCompatibleFunction)(SkiaVersionFunction function); + +static const int kAwDrawSWFunctionTableVersion = 1; + +// "vtable" for the functions declared in this file. An instance must be set via +// AwContents.setAwDrawSWFunctionTable +struct AwDrawSWFunctionTable { + int version; + AwAccessPixelsFunction* access_pixels; + AwReleasePixelsFunction* release_pixels; +}; + +#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ diff --git a/chromium/plat_support/graphic_buffer_impl.h b/chromium/plat_support/graphic_buffer_impl.h index 5d5da12..442710a 100644 --- a/chromium/plat_support/graphic_buffer_impl.h +++ b/chromium/plat_support/graphic_buffer_impl.h @@ -22,7 +22,7 @@ #include -#include "android_webview/public/browser/draw_gl.h" +#include "draw_gl.h" namespace android { diff --git a/chromium/plat_support/graphics_utils.cpp b/chromium/plat_support/graphics_utils.cpp index 320e419..c2017d3 100644 --- a/chromium/plat_support/graphics_utils.cpp +++ b/chromium/plat_support/graphics_utils.cpp @@ -19,8 +19,8 @@ #define LOG_TAG "webviewchromium_plat_support" -#include "android_webview/public/browser/draw_gl.h" -#include "android_webview/public/browser/draw_sw.h" +#include "draw_gl.h" +#include "draw_sw.h" #include #include -- cgit v1.2.3