Debian Codegraph @

native/webview/plat_support/draw_gl.h

raw symbols SCIP
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.
4 //
5 //******************************************************************************
6 // This is a copy of the coresponding android_webview/public/browser header.
7 // Any changes to the interface should be made there.
8 //
9 // The purpose of having the copy is twofold:
10 // - it removes the need to have Chromium sources present in the tree in order
11 // to build the plat_support library,
12 // - it captures API that the corresponding Android release supports.
13 //******************************************************************************
14
15 #ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
16 #define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 // 1 is L/L MR1
23 //
24 // 2 starts at M, and added an imperfect workaround for complex clipping by
25 // elevating the WebView into an FBO layer. If any transform, clip, or outline
26 // clip occurs that would either likely use the stencil buffer for clipping, or
27 // require shader based clipping in HWUI, the WebView is drawn into an FBO (if
28 // it fits).
29 // This is a temporary workaround for a lack of WebView support for stencil/
30 // shader based round rect clipping, and should be removed when webview is
31 // capable of supporting these clips internally when drawing.
32 //
33 // 3 starts during development of P, when android defaults from HWUI to skia as
34 // the GL renderer. Skia already maintains and restores its GL state, so there
35 // is no need for WebView to restore this state. Skia also no longer promises
36 // GL state on entering draw, such as no vertex array buffer binding.
37 static const int kAwDrawGLInfoVersion = 3;
38
39 // Holds the information required to trigger an OpenGL drawing operation.
40 struct AwDrawGLInfo {
41 int version; // The AwDrawGLInfo this struct was built with.
42
43 // Input: tells the draw function what action to perform.
44 enum Mode {
45 kModeDraw = 0,
46 kModeProcess = 1,
47 kModeProcessNoContext = 2,
48 kModeSync = 3,
49 } mode;
50
51 // Input: current clip rect in surface coordinates. Reflects the current state
52 // of the OpenGL scissor rect. Both the OpenGL scissor rect and viewport are
53 // set by the caller of the draw function and updated during View animations.
54 int clip_left;
55 int clip_top;
56 int clip_right;
57 int clip_bottom;
58
59 // Input: current width/height of destination surface.
60 int width;
61 int height;
62
63 // Input: is the View rendered into an independent layer.
64 // If false, the surface is likely to hold to the full screen contents, with
65 // the scissor box set by the caller to the actual View location and size.
66 // Also the transformation matrix will contain at least a translation to the
67 // position of the View to render, plus any other transformations required as
68 // part of any ongoing View animation. View translucency (alpha) is ignored,
69 // although the framework will set is_layer to true for non-opaque cases.
70 // Can be requested via the View.setLayerType(View.LAYER_TYPE_NONE, ...)
71 // Android API method.
72 //
73 // If true, the surface is dedicated to the View and should have its size.
74 // The viewport and scissor box are set by the caller to the whole surface.
75 // Animation transformations are handled by the caller and not reflected in
76 // the provided transformation matrix. Translucency works normally.
77 // Can be requested via the View.setLayerType(View.LAYER_TYPE_HARDWARE, ...)
78 // Android API method.
79 bool is_layer;
80
81 // Input: current transformation matrix in surface pixels.
82 // Uses the column-based OpenGL matrix format.
83 float transform[16];
84 };
85
86 // Function to invoke a direct GL draw into the client's pre-configured
87 // GL context. Obtained via AwContents.getDrawGLFunction() (static).
88 // |view_context| is an opaque identifier that was returned by the corresponding
89 // call to AwContents.getAwDrawGLViewContext().
90 // |draw_info| carries the in and out parameters for this draw.
91 // |spare| ignored; pass NULL.
92 typedef void (AwDrawGLFunction)(long view_context,
93 AwDrawGLInfo* draw_info,
94 void* spare);
95 enum AwMapMode {
96 MAP_READ_ONLY = 0,
97 MAP_WRITE_ONLY = 1,
98 MAP_READ_WRITE = 2,
99 };
100
101 // Called to create a GraphicBuffer
102 typedef long AwCreateGraphicBufferFunction(int w, int h);
103 // Called to release a GraphicBuffer
104 typedef void AwReleaseGraphicBufferFunction(long buffer_id);
105 // Called to map a GraphicBuffer in |mode|.
106 typedef int AwMapFunction(long buffer_id, AwMapMode mode, void** vaddr);
107 // Called to unmap a GraphicBuffer
108 typedef int AwUnmapFunction(long buffer_id);
109 // Called to get a native buffer pointer
110 typedef void* AwGetNativeBufferFunction(long buffer_id);
111 // Called to get the stride of the buffer
112 typedef unsigned int AwGetStrideFunction(long buffer_id);
113
114 static const int kAwDrawGLFunctionTableVersion = 1;
115
116 // Set of functions used in rendering in hardware mode
117 struct AwDrawGLFunctionTable {
118 int version;
119 AwCreateGraphicBufferFunction* create_graphic_buffer;
120 AwReleaseGraphicBufferFunction* release_graphic_buffer;
121 AwMapFunction* map;
122 AwUnmapFunction* unmap;
123 AwGetNativeBufferFunction* get_native_buffer;
124 AwGetStrideFunction* get_stride;
125 };
126
127 #ifdef __cplusplus
128 } // extern "C"
129 #endif
130
131 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_