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 // Holds the information required to trigger an OpenGL drawing operation.
14 // Input: tells the draw function what action to perform.
20 // Input: current clip rect in surface coordinates. Reflects the current state
21 // of the OpenGL scissor rect. Both the OpenGL scissor rect and viewport are
22 // set by the caller of the draw function and updated during View animations.
28 // Input: current width/height of destination surface.
32 // Input: is the View rendered into an independent layer.
33 // If false, the surface is likely to hold to the full screen contents, with
34 // the scissor box set by the caller to the actual View location and size.
35 // Also the transformation matrix will contain at least a translation to the
36 // position of the View to render, plus any other transformations required as
37 // part of any ongoing View animation. View translucency (alpha) is ignored,
38 // although the framework will set is_layer to true for non-opaque cases.
39 // Can be requested via the View.setLayerType(View.LAYER_TYPE_NONE, ...)
40 // Android API method.
42 // If true, the surface is dedicated to the View and should have its size.
43 // The viewport and scissor box are set by the caller to the whole surface.
44 // Animation transformations are handled by the caller and not reflected in
45 // the provided transformation matrix. Translucency works normally.
46 // Can be requested via the View.setLayerType(View.LAYER_TYPE_HARDWARE, ...)
47 // Android API method.
50 // Input: current transformation matrix in surface pixels.
51 // Uses the column-based OpenGL matrix format.
54 // Output: tells the caller what to do next.
56 kStatusMaskDone = 0x0,
57 kStatusMaskDraw = 0x1,
58 kStatusMaskInvoke = 0x2,
61 // Output: mask indicating the status after calling the functor.
62 unsigned int status_mask;
64 // Output: dirty region to redraw in surface coordinates.
71 // Function to invoke a direct GL draw into the client's pre-configured
72 // GL context. Obtained via AwContents.getDrawGLFunction() (static).
73 // |view_context| is an opaque identifier that was returned by the corresponding
74 // call to AwContents.getAwDrawGLViewContext().
75 // |draw_info| carries the in and out parameters for this draw.
76 // |spare| ignored; pass NULL.
77 typedef void (AwDrawGLFunction)(int view_context,
78 AwDrawGLInfo* draw_info,
86 // Called to create a GraphicBuffer
87 typedef int AwCreateGraphicBufferFunction(int w, int h);
88 // Called to release a GraphicBuffer
89 typedef void AwReleaseGraphicBufferFunction(int buffer_id);
90 // Called to map a GraphicBuffer in |mode|.
91 typedef int AwMapFunction(int buffer_id, AwMapMode mode, void** vaddr);
92 // Called to unmap a GraphicBuffer
93 typedef int AwUnmapFunction(int buffer_id);
94 // Called to get a native buffer pointer
95 typedef void* AwGetNativeBufferFunction(int buffer_id);
96 // Called to get the stride of the buffer
97 typedef unsigned int AwGetStrideFunction(int buffer_id);
99 // Set of functions used in rendering in hardware mode
100 struct AwDrawGLFunctionTable {
101 AwCreateGraphicBufferFunction* create_graphic_buffer;
102 AwReleaseGraphicBufferFunction* release_graphic_buffer;
104 AwUnmapFunction* unmap;
105 AwGetNativeBufferFunction* get_native_buffer;
106 AwGetStrideFunction* get_stride;
113 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_