OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 #ifndef CCRendererGL_h | 6 #ifndef CCRendererGL_h |
7 #define CCRendererGL_h | 7 #define CCRendererGL_h |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "CCCheckerboardDrawQuad.h" | 10 #include "CCCheckerboardDrawQuad.h" |
11 #include "CCDebugBorderDrawQuad.h" | 11 #include "CCDebugBorderDrawQuad.h" |
12 #include "CCDirectRenderer.h" | 12 #include "CCDirectRenderer.h" |
13 #include "CCIOSurfaceDrawQuad.h" | 13 #include "CCIOSurfaceDrawQuad.h" |
14 #include "CCRenderPassDrawQuad.h" | 14 #include "CCRenderPassDrawQuad.h" |
15 #include "CCRenderer.h" | 15 #include "CCRenderer.h" |
16 #include "CCSolidColorDrawQuad.h" | 16 #include "CCSolidColorDrawQuad.h" |
17 #include "CCStreamVideoDrawQuad.h" | 17 #include "CCStreamVideoDrawQuad.h" |
18 #include "CCTextureDrawQuad.h" | 18 #include "CCTextureDrawQuad.h" |
19 #include "CCTileDrawQuad.h" | 19 #include "CCTileDrawQuad.h" |
20 #include "CCYUVVideoDrawQuad.h" | 20 #include "CCYUVVideoDrawQuad.h" |
21 #include "Extensions3DChromium.h" | 21 #include "Extensions3DChromium.h" |
22 | 22 |
23 namespace WebKit { | 23 namespace WebKit { |
24 class WebGraphicsContext3D; | 24 class WebGraphicsContext3D; |
25 } | 25 } |
26 | 26 |
27 namespace cc { | 27 namespace cc { |
28 | 28 |
29 class CCScopedTexture; | 29 class ScopedTexture; |
30 class GeometryBinding; | 30 class GeometryBinding; |
31 class ScopedEnsureFramebufferAllocation; | 31 class ScopedEnsureFramebufferAllocation; |
32 | 32 |
33 // Class that handles drawing of composited render layers using GL. | 33 // Class that handles drawing of composited render layers using GL. |
34 class CCRendererGL : public CCDirectRenderer, | 34 class GLRenderer : public DirectRenderer, |
35 public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffers
CompleteCallbackCHROMIUM, | 35 public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffers
CompleteCallbackCHROMIUM, |
36 public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAlloc
ationChangedCallbackCHROMIUM , | 36 public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAlloc
ationChangedCallbackCHROMIUM , |
37 public WebKit::WebGraphicsContext3D::WebGraphicsContextLost
Callback { | 37 public WebKit::WebGraphicsContext3D::WebGraphicsContextLost
Callback { |
38 public: | 38 public: |
39 static scoped_ptr<CCRendererGL> create(CCRendererClient*, CCResourceProvider
*); | 39 static scoped_ptr<GLRenderer> create(RendererClient*, ResourceProvider*); |
40 | 40 |
41 virtual ~CCRendererGL(); | 41 virtual ~GLRenderer(); |
42 | 42 |
43 virtual const RendererCapabilities& capabilities() const OVERRIDE; | 43 virtual const RendererCapabilities& capabilities() const OVERRIDE; |
44 | 44 |
45 WebKit::WebGraphicsContext3D* context(); | 45 WebKit::WebGraphicsContext3D* context(); |
46 | 46 |
47 virtual void viewportChanged() OVERRIDE; | 47 virtual void viewportChanged() OVERRIDE; |
48 | 48 |
49 const FloatQuad& sharedGeometryQuad() const { return m_sharedGeometryQuad; } | 49 const FloatQuad& sharedGeometryQuad() const { return m_sharedGeometryQuad; } |
50 | 50 |
51 // waits for rendering to finish | 51 // waits for rendering to finish |
52 virtual void finish() OVERRIDE; | 52 virtual void finish() OVERRIDE; |
53 | 53 |
54 virtual void doNoOp() OVERRIDE; | 54 virtual void doNoOp() OVERRIDE; |
55 // puts backbuffer onscreen | 55 // puts backbuffer onscreen |
56 virtual bool swapBuffers() OVERRIDE; | 56 virtual bool swapBuffers() OVERRIDE; |
57 | 57 |
58 static void debugGLCall(WebKit::WebGraphicsContext3D*, const char* command,
const char* file, int line); | 58 static void debugGLCall(WebKit::WebGraphicsContext3D*, const char* command,
const char* file, int line); |
59 | 59 |
60 const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(
); } | 60 const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(
); } |
61 | 61 |
62 virtual void getFramebufferPixels(void *pixels, const IntRect&) OVERRIDE; | 62 virtual void getFramebufferPixels(void *pixels, const IntRect&) OVERRIDE; |
63 bool getFramebufferTexture(CCScopedTexture*, const IntRect& deviceRect); | 63 bool getFramebufferTexture(ScopedTexture*, const IntRect& deviceRect); |
64 | 64 |
65 virtual bool isContextLost() OVERRIDE; | 65 virtual bool isContextLost() OVERRIDE; |
66 | 66 |
67 virtual void setVisible(bool) OVERRIDE; | 67 virtual void setVisible(bool) OVERRIDE; |
68 | 68 |
69 protected: | 69 protected: |
70 CCRendererGL(CCRendererClient*, CCResourceProvider*); | 70 GLRenderer(RendererClient*, ResourceProvider*); |
71 | 71 |
72 bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } | 72 bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } |
73 bool initialize(); | 73 bool initialize(); |
74 | 74 |
75 void releaseRenderPassTextures(); | 75 void releaseRenderPassTextures(); |
76 | 76 |
77 virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE; | 77 virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE; |
78 virtual bool bindFramebufferToTexture(DrawingFrame&, const CCScopedTexture*,
const IntRect& framebufferRect) OVERRIDE; | 78 virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, c
onst IntRect& framebufferRect) OVERRIDE; |
79 virtual void setDrawViewportSize(const IntSize&) OVERRIDE; | 79 virtual void setDrawViewportSize(const IntSize&) OVERRIDE; |
80 virtual void enableScissorTestRect(const IntRect& scissorRect) OVERRIDE; | 80 virtual void enableScissorTestRect(const IntRect& scissorRect) OVERRIDE; |
81 virtual void disableScissorTest() OVERRIDE; | 81 virtual void disableScissorTest() OVERRIDE; |
82 virtual void clearFramebuffer(DrawingFrame&) OVERRIDE; | 82 virtual void clearFramebuffer(DrawingFrame&) OVERRIDE; |
83 virtual void drawQuad(DrawingFrame&, const CCDrawQuad*) OVERRIDE; | 83 virtual void drawQuad(DrawingFrame&, const DrawQuad*) OVERRIDE; |
84 virtual void beginDrawingFrame(DrawingFrame&) OVERRIDE; | 84 virtual void beginDrawingFrame(DrawingFrame&) OVERRIDE; |
85 virtual void finishDrawingFrame(DrawingFrame&) OVERRIDE; | 85 virtual void finishDrawingFrame(DrawingFrame&) OVERRIDE; |
86 virtual bool flippedFramebuffer() const OVERRIDE; | 86 virtual bool flippedFramebuffer() const OVERRIDE; |
87 | 87 |
88 private: | 88 private: |
89 static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&); | 89 static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&); |
90 | 90 |
91 void drawCheckerboardQuad(const DrawingFrame&, const CCCheckerboardDrawQuad*
); | 91 void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*); |
92 void drawDebugBorderQuad(const DrawingFrame&, const CCDebugBorderDrawQuad*); | 92 void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*); |
93 scoped_ptr<CCScopedTexture> drawBackgroundFilters(DrawingFrame&, const CCRen
derPassDrawQuad*, const WebKit::WebFilterOperations&, const WebKit::WebTransform
ationMatrix& deviceTransform); | 93 scoped_ptr<ScopedTexture> drawBackgroundFilters(DrawingFrame&, const RenderP
assDrawQuad*, const WebKit::WebFilterOperations&, const WebKit::WebTransformatio
nMatrix& deviceTransform); |
94 void drawRenderPassQuad(DrawingFrame&, const CCRenderPassDrawQuad*); | 94 void drawRenderPassQuad(DrawingFrame&, const RenderPassDrawQuad*); |
95 void drawSolidColorQuad(const DrawingFrame&, const CCSolidColorDrawQuad*); | 95 void drawSolidColorQuad(const DrawingFrame&, const SolidColorDrawQuad*); |
96 void drawStreamVideoQuad(const DrawingFrame&, const CCStreamVideoDrawQuad*); | 96 void drawStreamVideoQuad(const DrawingFrame&, const StreamVideoDrawQuad*); |
97 void drawTextureQuad(const DrawingFrame&, const CCTextureDrawQuad*); | 97 void drawTextureQuad(const DrawingFrame&, const TextureDrawQuad*); |
98 void drawIOSurfaceQuad(const DrawingFrame&, const CCIOSurfaceDrawQuad*); | 98 void drawIOSurfaceQuad(const DrawingFrame&, const IOSurfaceDrawQuad*); |
99 void drawTileQuad(const DrawingFrame&, const CCTileDrawQuad*); | 99 void drawTileQuad(const DrawingFrame&, const TileDrawQuad*); |
100 void drawYUVVideoQuad(const DrawingFrame&, const CCYUVVideoDrawQuad*); | 100 void drawYUVVideoQuad(const DrawingFrame&, const YUVVideoDrawQuad*); |
101 | 101 |
102 void setShaderOpacity(float opacity, int alphaLocation); | 102 void setShaderOpacity(float opacity, int alphaLocation); |
103 void setShaderFloatQuad(const FloatQuad&, int quadLocation); | 103 void setShaderFloatQuad(const FloatQuad&, int quadLocation); |
104 void drawQuadGeometry(const DrawingFrame&, const WebKit::WebTransformationMa
trix& drawTransform, const FloatRect& quadRect, int matrixLocation); | 104 void drawQuadGeometry(const DrawingFrame&, const WebKit::WebTransformationMa
trix& drawTransform, const FloatRect& quadRect, int matrixLocation); |
105 | 105 |
106 void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const IntR
ect&, const WebKit::WebTransformationMatrix& drawMatrix); | 106 void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const IntR
ect&, const WebKit::WebTransformationMatrix& drawMatrix); |
107 | 107 |
108 bool useScopedTexture(DrawingFrame&, const CCScopedTexture*, const IntRect&
viewportRect); | 108 bool useScopedTexture(DrawingFrame&, const ScopedTexture*, const IntRect& vi
ewportRect); |
109 | 109 |
110 bool makeContextCurrent(); | 110 bool makeContextCurrent(); |
111 | 111 |
112 bool initializeSharedObjects(); | 112 bool initializeSharedObjects(); |
113 void cleanupSharedObjects(); | 113 void cleanupSharedObjects(); |
114 | 114 |
115 // WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROM
IUM implementation. | 115 // WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROM
IUM implementation. |
116 virtual void onSwapBuffersComplete() OVERRIDE; | 116 virtual void onSwapBuffersComplete() OVERRIDE; |
117 | 117 |
118 // WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackC
HROMIUM implementation. | 118 // WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackC
HROMIUM implementation. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 WebKit::WebGraphicsContext3D* m_context; | 208 WebKit::WebGraphicsContext3D* m_context; |
209 | 209 |
210 IntRect m_swapBufferRect; | 210 IntRect m_swapBufferRect; |
211 bool m_isViewportChanged; | 211 bool m_isViewportChanged; |
212 bool m_isFramebufferDiscarded; | 212 bool m_isFramebufferDiscarded; |
213 bool m_discardFramebufferWhenNotVisible; | 213 bool m_discardFramebufferWhenNotVisible; |
214 bool m_isUsingBindUniform; | 214 bool m_isUsingBindUniform; |
215 bool m_visible; | 215 bool m_visible; |
216 | 216 |
217 scoped_ptr<CCResourceProvider::ScopedWriteLockGL> m_currentFramebufferLock; | 217 scoped_ptr<ResourceProvider::ScopedWriteLockGL> m_currentFramebufferLock; |
218 | 218 |
219 DISALLOW_COPY_AND_ASSIGN(CCRendererGL); | 219 DISALLOW_COPY_AND_ASSIGN(GLRenderer); |
220 }; | 220 }; |
221 | 221 |
222 | 222 |
223 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL | 223 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL |
224 // call made by the compositor. Useful for debugging rendering issues but | 224 // call made by the compositor. Useful for debugging rendering issues but |
225 // will significantly degrade performance. | 225 // will significantly degrade performance. |
226 #define DEBUG_GL_CALLS 0 | 226 #define DEBUG_GL_CALLS 0 |
227 | 227 |
228 #if DEBUG_GL_CALLS && !defined ( NDEBUG ) | 228 #if DEBUG_GL_CALLS && !defined ( NDEBUG ) |
229 #define GLC(context, x) (x, CCRendererGL::debugGLCall(&*context, #x, __FILE__, _
_LINE__)) | 229 #define GLC(context, x) (x, GLRenderer::debugGLCall(&*context, #x, __FILE__, __L
INE__)) |
230 #else | 230 #else |
231 #define GLC(context, x) (x) | 231 #define GLC(context, x) (x) |
232 #endif | 232 #endif |
233 | 233 |
234 | 234 |
235 } | 235 } |
236 | 236 |
237 #endif | 237 #endif |
OLD | NEW |