1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// 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.
#ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
#ifdef __cplusplus
extern "C" {
#endif
// Holds the information required to trigger an OpenGL drawing operation.
struct AwDrawGLInfo {
// Input: tells the draw function what action to perform.
enum Mode {
kModeDraw,
kModeProcess,
} 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];
// Output: tells the caller what to do next.
enum StatusMask {
kStatusMaskDone = 0x0,
kStatusMaskDraw = 0x1,
kStatusMaskInvoke = 0x2,
};
// Output: mask indicating the status after calling the functor.
unsigned int status_mask;
// Output: dirty region to redraw in surface coordinates.
float dirty_left;
float dirty_top;
float dirty_right;
float dirty_bottom;
};
// 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)(int view_context,
AwDrawGLInfo* draw_info,
void* spare);
// Called to create a GraphicBuffer
typedef int AwCreateGraphicBufferFunction(int w, int h);
// Called to release a GraphicBuffer
typedef void AwReleaseGraphicBufferFunction(int buffer_id);
// Called to lock a GraphicBuffer for writing
typedef int AwLockForWriteFunction(int buffer_id, void** vaddr);
// Called to unlock a GraphicBuffer
typedef int AwUnlockFunction(int buffer_id);
// Called to get a native buffer pointer
typedef void* AwGetNativeBufferFunction(int buffer_id);
// Called to get the stride of the buffer
typedef unsigned int AwGetStrideFunction(int buffer_id);
// Set of functions used in rendering in hardware mode
struct AwDrawGLFunctionTable {
AwCreateGraphicBufferFunction* create_graphic_buffer;
AwReleaseGraphicBufferFunction* release_graphic_buffer;
AwLockForWriteFunction* lock_for_write;
AwUnlockFunction* unlock;
AwGetNativeBufferFunction* get_native_buffer;
AwGetStrideFunction* get_stride;
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
|