1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
6 #define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
12 static const int kAwDrawGLInfoVersion
= 1;
14 // Holds the information required to trigger an OpenGL drawing operation.
16 int version
; // The AwDrawGLInfo this struct was built with.
18 // Input: tells the draw function what action to perform.
22 kModeProcessNoContext
,
26 // Input: current clip rect in surface coordinates. Reflects the current state
27 // of the OpenGL scissor rect. Both the OpenGL scissor rect and viewport are
28 // set by the caller of the draw function and updated during View animations.
34 // Input: current width/height of destination surface.
38 // Input: is the View rendered into an independent layer.
39 // If false, the surface is likely to hold to the full screen contents, with
40 // the scissor box set by the caller to the actual View location and size.
41 // Also the transformation matrix will contain at least a translation to the
42 // position of the View to render, plus any other transformations required as
43 // part of any ongoing View animation. View translucency (alpha) is ignored,
44 // although the framework will set is_layer to true for non-opaque cases.
45 // Can be requested via the View.setLayerType(View.LAYER_TYPE_NONE, ...)
46 // Android API method.
48 // If true, the surface is dedicated to the View and should have its size.
49 // The viewport and scissor box are set by the caller to the whole surface.
50 // Animation transformations are handled by the caller and not reflected in
51 // the provided transformation matrix. Translucency works normally.
52 // Can be requested via the View.setLayerType(View.LAYER_TYPE_HARDWARE, ...)
53 // Android API method.
56 // Input: current transformation matrix in surface pixels.
57 // Uses the column-based OpenGL matrix format.
61 // Function to invoke a direct GL draw into the client's pre-configured
62 // GL context. Obtained via AwContents.getDrawGLFunction() (static).
63 // |view_context| is an opaque identifier that was returned by the corresponding
64 // call to AwContents.getAwDrawGLViewContext().
65 // |draw_info| carries the in and out parameters for this draw.
66 // |spare| ignored; pass NULL.
67 typedef void (AwDrawGLFunction
)(long view_context
,
68 AwDrawGLInfo
* draw_info
,
76 // Called to create a GraphicBuffer
77 typedef long AwCreateGraphicBufferFunction(int w
, int h
);
78 // Called to release a GraphicBuffer
79 typedef void AwReleaseGraphicBufferFunction(long buffer_id
);
80 // Called to map a GraphicBuffer in |mode|.
81 typedef int AwMapFunction(long buffer_id
, AwMapMode mode
, void** vaddr
);
82 // Called to unmap a GraphicBuffer
83 typedef int AwUnmapFunction(long buffer_id
);
84 // Called to get a native buffer pointer
85 typedef void* AwGetNativeBufferFunction(long buffer_id
);
86 // Called to get the stride of the buffer
87 typedef unsigned int AwGetStrideFunction(long buffer_id
);
89 static const int kAwDrawGLFunctionTableVersion
= 1;
91 // Set of functions used in rendering in hardware mode
92 struct AwDrawGLFunctionTable
{
94 AwCreateGraphicBufferFunction
* create_graphic_buffer
;
95 AwReleaseGraphicBufferFunction
* release_graphic_buffer
;
97 AwUnmapFunction
* unmap
;
98 AwGetNativeBufferFunction
* get_native_buffer
;
99 AwGetStrideFunction
* get_stride
;
106 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_