Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Side by Side Diff: cc/CCRendererGL.h

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCRenderer.cpp ('k') | cc/CCRendererGL.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 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 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 // Temporary forwarding header
6 #ifndef CCRendererGL_h 6 #include "cc/gl_renderer.h"
7 #define CCRendererGL_h
8
9 #if USE(ACCELERATED_COMPOSITING)
10
11 #include "base/basictypes.h"
12 #include "CCCheckerboardDrawQuad.h"
13 #include "CCDebugBorderDrawQuad.h"
14 #include "CCDirectRenderer.h"
15 #include "CCIOSurfaceDrawQuad.h"
16 #include "CCRenderPassDrawQuad.h"
17 #include "CCRenderer.h"
18 #include "CCSolidColorDrawQuad.h"
19 #include "CCStreamVideoDrawQuad.h"
20 #include "CCTextureDrawQuad.h"
21 #include "CCTileDrawQuad.h"
22 #include "CCYUVVideoDrawQuad.h"
23 #include "Extensions3DChromium.h"
24 #include <wtf/PassOwnPtr.h>
25
26 namespace WebKit {
27 class WebGraphicsContext3D;
28 }
29
30 namespace cc {
31
32 class CCScopedTexture;
33 class GeometryBinding;
34 class ScopedEnsureFramebufferAllocation;
35
36 // Class that handles drawing of composited render layers using GL.
37 class CCRendererGL : public CCDirectRenderer,
38 public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffers CompleteCallbackCHROMIUM,
39 public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAlloc ationChangedCallbackCHROMIUM ,
40 public WebKit::WebGraphicsContext3D::WebGraphicsContextLost Callback {
41 public:
42 static PassOwnPtr<CCRendererGL> create(CCRendererClient*, CCResourceProvider *);
43
44 virtual ~CCRendererGL();
45
46 virtual const RendererCapabilities& capabilities() const OVERRIDE;
47
48 WebKit::WebGraphicsContext3D* context();
49
50 virtual void viewportChanged() OVERRIDE;
51
52 const FloatQuad& sharedGeometryQuad() const { return m_sharedGeometryQuad; }
53
54 // waits for rendering to finish
55 virtual void finish() OVERRIDE;
56
57 virtual void doNoOp() OVERRIDE;
58 // puts backbuffer onscreen
59 virtual bool swapBuffers() OVERRIDE;
60
61 static void debugGLCall(WebKit::WebGraphicsContext3D*, const char* command, const char* file, int line);
62
63 const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get( ); }
64
65 virtual void getFramebufferPixels(void *pixels, const IntRect&) OVERRIDE;
66 bool getFramebufferTexture(CCScopedTexture*, const IntRect& deviceRect);
67
68 virtual bool isContextLost() OVERRIDE;
69
70 virtual void setVisible(bool) OVERRIDE;
71
72 protected:
73 CCRendererGL(CCRendererClient*, CCResourceProvider*);
74
75 bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; }
76 bool initialize();
77
78 void releaseRenderPassTextures();
79
80 virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE;
81 virtual bool bindFramebufferToTexture(DrawingFrame&, const CCScopedTexture*, const IntRect& framebufferRect) OVERRIDE;
82 virtual void setDrawViewportSize(const IntSize&) OVERRIDE;
83 virtual void enableScissorTestRect(const IntRect& scissorRect) OVERRIDE;
84 virtual void disableScissorTest() OVERRIDE;
85 virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
86 virtual void drawQuad(DrawingFrame&, const CCDrawQuad*) OVERRIDE;
87 virtual void beginDrawingFrame(DrawingFrame&) OVERRIDE;
88 virtual void finishDrawingFrame(DrawingFrame&) OVERRIDE;
89 virtual bool flippedFramebuffer() const OVERRIDE;
90
91 private:
92 static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&);
93
94 void drawCheckerboardQuad(const DrawingFrame&, const CCCheckerboardDrawQuad* );
95 void drawDebugBorderQuad(const DrawingFrame&, const CCDebugBorderDrawQuad*);
96 PassOwnPtr<CCScopedTexture> drawBackgroundFilters(DrawingFrame&, const CCRen derPassDrawQuad*, const WebKit::WebFilterOperations&, const WebKit::WebTransform ationMatrix& deviceTransform);
97 void drawRenderPassQuad(DrawingFrame&, const CCRenderPassDrawQuad*);
98 void drawSolidColorQuad(const DrawingFrame&, const CCSolidColorDrawQuad*);
99 void drawStreamVideoQuad(const DrawingFrame&, const CCStreamVideoDrawQuad*);
100 void drawTextureQuad(const DrawingFrame&, const CCTextureDrawQuad*);
101 void drawIOSurfaceQuad(const DrawingFrame&, const CCIOSurfaceDrawQuad*);
102 void drawTileQuad(const DrawingFrame&, const CCTileDrawQuad*);
103 void drawYUVVideoQuad(const DrawingFrame&, const CCYUVVideoDrawQuad*);
104
105 void setShaderOpacity(float opacity, int alphaLocation);
106 void setShaderFloatQuad(const FloatQuad&, int quadLocation);
107 void drawQuadGeometry(const DrawingFrame&, const WebKit::WebTransformationMa trix& drawTransform, const FloatRect& quadRect, int matrixLocation);
108
109 void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const IntR ect&, const WebKit::WebTransformationMatrix& drawMatrix);
110
111 bool useScopedTexture(DrawingFrame&, const CCScopedTexture*, const IntRect& viewportRect);
112
113 bool makeContextCurrent();
114
115 bool initializeSharedObjects();
116 void cleanupSharedObjects();
117
118 // WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROM IUM implementation.
119 virtual void onSwapBuffersComplete() OVERRIDE;
120
121 // WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackC HROMIUM implementation.
122 virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation) OVERRIDE;
123 void onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocati on);
124 void discardFramebuffer();
125 void ensureFramebuffer();
126
127 // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation.
128 virtual void onContextLost() OVERRIDE;
129
130 RendererCapabilities m_capabilities;
131
132 unsigned m_offscreenFramebufferId;
133
134 OwnPtr<GeometryBinding> m_sharedGeometry;
135 FloatQuad m_sharedGeometryQuad;
136
137 // This block of bindings defines all of the programs used by the compositor itself.
138
139 // Tiled layer shaders.
140 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> TilePro gram;
141 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexClampAlphaAA> TileProgramAA;
142 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexClampSwizzleAl phaAA> TileProgramSwizzleAA;
143 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexOpaque> TilePr ogramOpaque;
144 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexSwizzleAlpha> TileProgramSwizzle;
145 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexSwizzleOpaque> TileProgramSwizzleOpaque;
146 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderCheckerboard> TileC heckerboardProgram;
147
148 // Render surface shaders.
149 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Rende rPassProgram;
150 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> R enderPassMaskProgram;
151 typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexAlphaAA> Rende rPassProgramAA;
152 typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexAlphaMaskAA> R enderPassMaskProgramAA;
153
154 // Texture shaders.
155 typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexAlp ha> TextureProgram;
156 typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexFli pAlpha> TextureProgramFlip;
157 typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRec tAlpha> TextureIOSurfaceProgram;
158
159 // Video shaders.
160 typedef ProgramBinding<VertexShaderVideoTransform, FragmentShaderOESImageExt ernal> VideoStreamTextureProgram;
161 typedef ProgramBinding<VertexShaderPosTexYUVStretch, FragmentShaderYUVVideo> VideoYUVProgram;
162
163 // Special purpose / effects shaders.
164 typedef ProgramBinding<VertexShaderPos, FragmentShaderColor> SolidColorProgr am;
165
166 const TileProgram* tileProgram();
167 const TileProgramOpaque* tileProgramOpaque();
168 const TileProgramAA* tileProgramAA();
169 const TileProgramSwizzle* tileProgramSwizzle();
170 const TileProgramSwizzleOpaque* tileProgramSwizzleOpaque();
171 const TileProgramSwizzleAA* tileProgramSwizzleAA();
172 const TileCheckerboardProgram* tileCheckerboardProgram();
173
174 const RenderPassProgram* renderPassProgram();
175 const RenderPassProgramAA* renderPassProgramAA();
176 const RenderPassMaskProgram* renderPassMaskProgram();
177 const RenderPassMaskProgramAA* renderPassMaskProgramAA();
178
179 const TextureProgram* textureProgram();
180 const TextureProgramFlip* textureProgramFlip();
181 const TextureIOSurfaceProgram* textureIOSurfaceProgram();
182
183 const VideoYUVProgram* videoYUVProgram();
184 const VideoStreamTextureProgram* videoStreamTextureProgram();
185
186 const SolidColorProgram* solidColorProgram();
187
188 OwnPtr<TileProgram> m_tileProgram;
189 OwnPtr<TileProgramOpaque> m_tileProgramOpaque;
190 OwnPtr<TileProgramAA> m_tileProgramAA;
191 OwnPtr<TileProgramSwizzle> m_tileProgramSwizzle;
192 OwnPtr<TileProgramSwizzleOpaque> m_tileProgramSwizzleOpaque;
193 OwnPtr<TileProgramSwizzleAA> m_tileProgramSwizzleAA;
194 OwnPtr<TileCheckerboardProgram> m_tileCheckerboardProgram;
195
196 OwnPtr<RenderPassProgram> m_renderPassProgram;
197 OwnPtr<RenderPassProgramAA> m_renderPassProgramAA;
198 OwnPtr<RenderPassMaskProgram> m_renderPassMaskProgram;
199 OwnPtr<RenderPassMaskProgramAA> m_renderPassMaskProgramAA;
200
201 OwnPtr<TextureProgram> m_textureProgram;
202 OwnPtr<TextureProgramFlip> m_textureProgramFlip;
203 OwnPtr<TextureIOSurfaceProgram> m_textureIOSurfaceProgram;
204
205 OwnPtr<VideoYUVProgram> m_videoYUVProgram;
206 OwnPtr<VideoStreamTextureProgram> m_videoStreamTextureProgram;
207
208 OwnPtr<SolidColorProgram> m_solidColorProgram;
209
210 WebKit::WebGraphicsContext3D* m_context;
211
212 IntRect m_swapBufferRect;
213 bool m_isViewportChanged;
214 bool m_isFramebufferDiscarded;
215 bool m_isUsingBindUniform;
216 bool m_visible;
217
218 OwnPtr<CCResourceProvider::ScopedWriteLockGL> m_currentFramebufferLock;
219
220 DISALLOW_COPY_AND_ASSIGN(CCRendererGL);
221 };
222
223
224 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL
225 // call made by the compositor. Useful for debugging rendering issues but
226 // will significantly degrade performance.
227 #define DEBUG_GL_CALLS 0
228
229 #if DEBUG_GL_CALLS && !defined ( NDEBUG )
230 #define GLC(context, x) (x, CCRendererGL::debugGLCall(&*context, #x, __FILE__, _ _LINE__))
231 #else
232 #define GLC(context, x) (x)
233 #endif
234
235
236 }
237
238 #endif // USE(ACCELERATED_COMPOSITING)
239
240 #endif
OLDNEW
« no previous file with comments | « cc/CCRenderer.cpp ('k') | cc/CCRendererGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698