| 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 #ifndef CC_OUTPUT_GL_RENDERER_H_ | 5 #ifndef CC_OUTPUT_GL_RENDERER_H_ |
| 6 #define CC_OUTPUT_GL_RENDERER_H_ | 6 #define CC_OUTPUT_GL_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
| 9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
| 10 #include "cc/base/scoped_ptr_deque.h" | 10 #include "cc/base/scoped_ptr_deque.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace cc { | 33 namespace cc { |
| 34 | 34 |
| 35 class GLRendererShaderTest; | 35 class GLRendererShaderTest; |
| 36 class OutputSurface; | 36 class OutputSurface; |
| 37 class PictureDrawQuad; | 37 class PictureDrawQuad; |
| 38 class ScopedResource; | 38 class ScopedResource; |
| 39 class StreamVideoDrawQuad; | 39 class StreamVideoDrawQuad; |
| 40 class TextureDrawQuad; | 40 class TextureDrawQuad; |
| 41 class TextureMailboxDeleter; | 41 class TextureMailboxDeleter; |
| 42 class GeometryBinding; | 42 class GeometryBinding; |
| 43 class GeometryBindingQuad; |
| 43 class ScopedEnsureFramebufferAllocation; | 44 class ScopedEnsureFramebufferAllocation; |
| 44 | 45 |
| 45 // Class that handles drawing of composited render layers using GL. | 46 // Class that handles drawing of composited render layers using GL. |
| 46 class CC_EXPORT GLRenderer : public DirectRenderer { | 47 class CC_EXPORT GLRenderer : public DirectRenderer { |
| 47 public: | 48 public: |
| 48 class ScopedUseGrContext; | 49 class ScopedUseGrContext; |
| 49 | 50 |
| 50 static scoped_ptr<GLRenderer> Create( | 51 static scoped_ptr<GLRenderer> Create( |
| 51 RendererClient* client, | 52 RendererClient* client, |
| 52 const LayerTreeSettings* settings, | 53 const LayerTreeSettings* settings, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE; | 105 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE; |
| 105 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 106 virtual bool BindFramebufferToTexture(DrawingFrame* frame, |
| 106 const ScopedResource* resource, | 107 const ScopedResource* resource, |
| 107 const gfx::Rect& target_rect) OVERRIDE; | 108 const gfx::Rect& target_rect) OVERRIDE; |
| 108 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) OVERRIDE; | 109 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) OVERRIDE; |
| 109 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) OVERRIDE; | 110 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) OVERRIDE; |
| 110 virtual void DiscardPixels(bool has_external_stencil_test, | 111 virtual void DiscardPixels(bool has_external_stencil_test, |
| 111 bool draw_rect_covers_full_surface) OVERRIDE; | 112 bool draw_rect_covers_full_surface) OVERRIDE; |
| 112 virtual void ClearFramebuffer(DrawingFrame* frame, | 113 virtual void ClearFramebuffer(DrawingFrame* frame, |
| 113 bool has_external_stencil_test) OVERRIDE; | 114 bool has_external_stencil_test) OVERRIDE; |
| 114 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) OVERRIDE; | 115 virtual void DoDrawQuad(DrawingFrame* frame, |
| 116 const class DrawQuad*, |
| 117 const gfx::QuadF* draw_region = NULL) OVERRIDE; |
| 115 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE; | 118 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE; |
| 116 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE; | 119 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE; |
| 117 virtual bool FlippedFramebuffer() const OVERRIDE; | 120 virtual bool FlippedFramebuffer() const OVERRIDE; |
| 118 virtual void EnsureScissorTestEnabled() OVERRIDE; | 121 virtual void EnsureScissorTestEnabled() OVERRIDE; |
| 119 virtual void EnsureScissorTestDisabled() OVERRIDE; | 122 virtual void EnsureScissorTestDisabled() OVERRIDE; |
| 120 virtual void CopyCurrentRenderPassToBitmap( | 123 virtual void CopyCurrentRenderPassToBitmap( |
| 121 DrawingFrame* frame, | 124 DrawingFrame* frame, |
| 122 scoped_ptr<CopyOutputRequest> request) OVERRIDE; | 125 scoped_ptr<CopyOutputRequest> request) OVERRIDE; |
| 123 virtual void FinishDrawingQuadList() OVERRIDE; | 126 virtual void FinishDrawingQuadList() OVERRIDE; |
| 124 | 127 |
| 125 // Check if quad needs antialiasing and if so, inflate the quad and | 128 // Check if quad needs antialiasing and if so, inflate the quad and |
| 126 // fill edge array for fragment shader. local_quad is set to | 129 // fill edge array for fragment shader. local_quad is set to |
| 127 // inflated quad if antialiasing is required, otherwise it is left | 130 // inflated quad if antialiasing is required, otherwise it is left |
| 128 // unchanged. edge array is filled with inflated quad's edge data | 131 // unchanged. edge array is filled with inflated quad's edge data |
| 129 // if antialiasing is required, otherwise it is left unchanged. | 132 // if antialiasing is required, otherwise it is left unchanged. |
| 130 // Returns true if quad requires antialiasing and false otherwise. | 133 // Returns true if quad requires antialiasing and false otherwise. |
| 131 static bool SetupQuadForAntialiasing(const gfx::Transform& device_transform, | 134 static bool SetupQuadForAntialiasing(const gfx::Transform& device_transform, |
| 132 const DrawQuad* quad, | 135 const DrawQuad* quad, |
| 133 gfx::QuadF* local_quad, | 136 gfx::QuadF* local_quad, |
| 134 float edge[24]); | 137 float edge[24]); |
| 135 | 138 |
| 136 private: | 139 private: |
| 137 friend class GLRendererShaderPixelTest; | 140 friend class GLRendererShaderPixelTest; |
| 138 friend class GLRendererShaderTest; | 141 friend class GLRendererShaderTest; |
| 139 | 142 |
| 140 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); | 143 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); |
| 141 | 144 |
| 142 void DrawCheckerboardQuad(const DrawingFrame* frame, | 145 void DrawCheckerboardQuad(const DrawingFrame* frame, |
| 143 const CheckerboardDrawQuad* quad); | 146 const CheckerboardDrawQuad* quad, |
| 147 const gfx::QuadF* clip_region); |
| 144 void DrawDebugBorderQuad(const DrawingFrame* frame, | 148 void DrawDebugBorderQuad(const DrawingFrame* frame, |
| 145 const DebugBorderDrawQuad* quad); | 149 const DebugBorderDrawQuad* quad); |
| 146 scoped_ptr<ScopedResource> GetBackgroundWithFilters( | 150 scoped_ptr<ScopedResource> GetBackgroundWithFilters( |
| 147 DrawingFrame* frame, | 151 DrawingFrame* frame, |
| 148 const RenderPassDrawQuad* quad, | 152 const RenderPassDrawQuad* quad, |
| 149 const gfx::Transform& contents_device_transform, | 153 const gfx::Transform& contents_device_transform, |
| 150 const gfx::Transform& contents_device_transformInverse, | 154 const gfx::Transform& contents_device_transformInverse, |
| 151 bool* background_changed); | 155 bool* background_changed); |
| 152 void DrawRenderPassQuad(DrawingFrame* frame, const RenderPassDrawQuad* quad); | 156 void DrawRenderPassQuad(DrawingFrame* frame, |
| 157 const RenderPassDrawQuad* quad, |
| 158 const gfx::QuadF* clip_region); |
| 153 void DrawSolidColorQuad(const DrawingFrame* frame, | 159 void DrawSolidColorQuad(const DrawingFrame* frame, |
| 154 const SolidColorDrawQuad* quad); | 160 const SolidColorDrawQuad* quad, |
| 161 const gfx::QuadF* clip_region); |
| 155 void DrawStreamVideoQuad(const DrawingFrame* frame, | 162 void DrawStreamVideoQuad(const DrawingFrame* frame, |
| 156 const StreamVideoDrawQuad* quad); | 163 const StreamVideoDrawQuad* quad, |
| 164 const gfx::QuadF* clip_region); |
| 165 void DrawTextureQuad(const DrawingFrame* frame, |
| 166 const TextureDrawQuad* quad, |
| 167 const gfx::QuadF* clip_region); |
| 157 void EnqueueTextureQuad(const DrawingFrame* frame, | 168 void EnqueueTextureQuad(const DrawingFrame* frame, |
| 158 const TextureDrawQuad* quad); | 169 const TextureDrawQuad* quad, |
| 159 void FlushTextureQuadCache(); | 170 const gfx::QuadF* clip_region); |
| 171 void FlushTextureQuadCache(bool using_clip_region); |
| 160 void DrawIOSurfaceQuad(const DrawingFrame* frame, | 172 void DrawIOSurfaceQuad(const DrawingFrame* frame, |
| 161 const IOSurfaceDrawQuad* quad); | 173 const IOSurfaceDrawQuad* quad, |
| 162 void DrawTileQuad(const DrawingFrame* frame, const TileDrawQuad* quad); | 174 const gfx::QuadF* clip_region); |
| 175 void DrawTileQuad(const DrawingFrame* frame, |
| 176 const TileDrawQuad* quad, |
| 177 const gfx::QuadF* clip_region); |
| 163 void DrawContentQuad(const DrawingFrame* frame, | 178 void DrawContentQuad(const DrawingFrame* frame, |
| 164 const ContentDrawQuadBase* quad, | 179 const ContentDrawQuadBase* quad, |
| 165 ResourceProvider::ResourceId resource_id); | 180 ResourceProvider::ResourceId resource_id, |
| 181 const gfx::QuadF* clip_region); |
| 166 void DrawYUVVideoQuad(const DrawingFrame* frame, | 182 void DrawYUVVideoQuad(const DrawingFrame* frame, |
| 167 const YUVVideoDrawQuad* quad); | 183 const YUVVideoDrawQuad* quad, |
| 184 const gfx::QuadF* clip_region); |
| 168 void DrawPictureQuad(const DrawingFrame* frame, | 185 void DrawPictureQuad(const DrawingFrame* frame, |
| 169 const PictureDrawQuad* quad); | 186 const PictureDrawQuad* quad, |
| 187 const gfx::QuadF* clip_region); |
| 170 | 188 |
| 171 void SetShaderOpacity(float opacity, int alpha_location); | 189 void SetShaderOpacity(float opacity, int alpha_location); |
| 172 void SetShaderQuadF(const gfx::QuadF& quad, int quad_location); | 190 void SetShaderQuadF(const gfx::QuadF& quad, int quad_location); |
| 191 void DrawQuadGeometryClippedByQuadF(const DrawingFrame* frame, |
| 192 const gfx::Transform& draw_transform, |
| 193 const gfx::RectF& quad_rect, |
| 194 const gfx::QuadF& clipping_region_quad, |
| 195 int matrix_location); |
| 173 void DrawQuadGeometry(const DrawingFrame* frame, | 196 void DrawQuadGeometry(const DrawingFrame* frame, |
| 174 const gfx::Transform& draw_transform, | 197 const gfx::Transform& draw_transform, |
| 175 const gfx::RectF& quad_rect, | 198 const gfx::RectF& quad_rect, |
| 176 int matrix_location); | 199 int matrix_location); |
| 177 void SetUseProgram(unsigned program); | 200 void SetUseProgram(unsigned program); |
| 178 | 201 |
| 179 void CopyTextureToFramebuffer(const DrawingFrame* frame, | 202 void CopyTextureToFramebuffer(const DrawingFrame* frame, |
| 180 int texture_id, | 203 int texture_id, |
| 181 const gfx::Rect& rect, | 204 const gfx::Rect& rect, |
| 182 const gfx::Transform& draw_matrix, | 205 const gfx::Transform& draw_matrix, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 211 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL> | 234 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL> |
| 212 OverlayResourceLockList; | 235 OverlayResourceLockList; |
| 213 OverlayResourceLockList pending_overlay_resources_; | 236 OverlayResourceLockList pending_overlay_resources_; |
| 214 OverlayResourceLockList in_use_overlay_resources_; | 237 OverlayResourceLockList in_use_overlay_resources_; |
| 215 | 238 |
| 216 RendererCapabilitiesImpl capabilities_; | 239 RendererCapabilitiesImpl capabilities_; |
| 217 | 240 |
| 218 unsigned offscreen_framebuffer_id_; | 241 unsigned offscreen_framebuffer_id_; |
| 219 | 242 |
| 220 scoped_ptr<GeometryBinding> shared_geometry_; | 243 scoped_ptr<GeometryBinding> shared_geometry_; |
| 244 scoped_ptr<GeometryBindingQuad> clipped_geometry_; |
| 221 gfx::QuadF shared_geometry_quad_; | 245 gfx::QuadF shared_geometry_quad_; |
| 222 | 246 |
| 223 // This block of bindings defines all of the programs used by the compositor | 247 // This block of bindings defines all of the programs used by the compositor |
| 224 // itself. Add any new programs here to GLRendererShaderTest. | 248 // itself. Add any new programs here to GLRendererShaderTest. |
| 225 | 249 |
| 226 // Tiled layer shaders. | 250 // Tiled layer shaders. |
| 227 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> | 251 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> |
| 228 TileProgram; | 252 TileProgram; |
| 229 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA> | 253 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA> |
| 230 TileProgramAA; | 254 TileProgramAA; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 #if DEBUG_GL_CALLS && !defined(NDEBUG) | 457 #if DEBUG_GL_CALLS && !defined(NDEBUG) |
| 434 #define GLC(context, x) \ | 458 #define GLC(context, x) \ |
| 435 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) | 459 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) |
| 436 #else | 460 #else |
| 437 #define GLC(context, x) (x) | 461 #define GLC(context, x) (x) |
| 438 #endif | 462 #endif |
| 439 | 463 |
| 440 } // namespace cc | 464 } // namespace cc |
| 441 | 465 |
| 442 #endif // CC_OUTPUT_GL_RENDERER_H_ | 466 #endif // CC_OUTPUT_GL_RENDERER_H_ |
| OLD | NEW |