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

Side by Side Diff: cc/output/gl_renderer.h

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « cc/output/geometry_binding.cc ('k') | cc/output/gl_renderer.cc » ('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 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 21 matching lines...) Expand all
32 32
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 StaticGeometryBinding;
43 class DynamicGeometryBinding;
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 RendererSettings* settings, 53 const RendererSettings* settings,
(...skipping 25 matching lines...) Expand all
78 OutputSurface* output_surface, 79 OutputSurface* output_surface,
79 ResourceProvider* resource_provider, 80 ResourceProvider* resource_provider,
80 TextureMailboxDeleter* texture_mailbox_deleter, 81 TextureMailboxDeleter* texture_mailbox_deleter,
81 int highp_threshold_min); 82 int highp_threshold_min);
82 83
83 void DidChangeVisibility() override; 84 void DidChangeVisibility() override;
84 85
85 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } 86 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; }
86 87
87 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } 88 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; }
88 const GeometryBinding* SharedGeometry() const { 89 const StaticGeometryBinding* SharedGeometry() const {
89 return shared_geometry_.get(); 90 return shared_geometry_.get();
90 } 91 }
91 92
92 void GetFramebufferPixelsAsync(const DrawingFrame* frame, 93 void GetFramebufferPixelsAsync(const DrawingFrame* frame,
93 const gfx::Rect& rect, 94 const gfx::Rect& rect,
94 scoped_ptr<CopyOutputRequest> request); 95 scoped_ptr<CopyOutputRequest> request);
95 void GetFramebufferTexture(unsigned texture_id, 96 void GetFramebufferTexture(unsigned texture_id,
96 ResourceFormat texture_format, 97 ResourceFormat texture_format,
97 const gfx::Rect& device_rect); 98 const gfx::Rect& device_rect);
98 void ReleaseRenderPassTextures(); 99 void ReleaseRenderPassTextures();
99 100 enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING };
101 void PrepareGeometry(BoundGeometry geometry_to_bind);
100 void SetStencilEnabled(bool enabled); 102 void SetStencilEnabled(bool enabled);
101 bool stencil_enabled() const { return stencil_shadow_; } 103 bool stencil_enabled() const { return stencil_shadow_; }
102 void SetBlendEnabled(bool enabled); 104 void SetBlendEnabled(bool enabled);
103 bool blend_enabled() const { return blend_shadow_; } 105 bool blend_enabled() const { return blend_shadow_; }
104 106
105 void BindFramebufferToOutputSurface(DrawingFrame* frame) override; 107 void BindFramebufferToOutputSurface(DrawingFrame* frame) override;
106 bool BindFramebufferToTexture(DrawingFrame* frame, 108 bool BindFramebufferToTexture(DrawingFrame* frame,
107 const ScopedResource* resource, 109 const ScopedResource* resource,
108 const gfx::Rect& target_rect) override; 110 const gfx::Rect& target_rect) override;
109 void SetDrawViewport(const gfx::Rect& window_space_viewport) override; 111 void SetDrawViewport(const gfx::Rect& window_space_viewport) override;
110 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; 112 void SetScissorTestRect(const gfx::Rect& scissor_rect) override;
111 void DiscardPixels(bool has_external_stencil_test, 113 void DiscardPixels(bool has_external_stencil_test,
112 bool draw_rect_covers_full_surface) override; 114 bool draw_rect_covers_full_surface) override;
113 void ClearFramebuffer(DrawingFrame* frame, 115 void ClearFramebuffer(DrawingFrame* frame,
114 bool has_external_stencil_test) override; 116 bool has_external_stencil_test) override;
115 void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) override; 117 void DoDrawQuad(DrawingFrame* frame,
118 const class DrawQuad*,
119 const gfx::QuadF* draw_region) override;
116 void BeginDrawingFrame(DrawingFrame* frame) override; 120 void BeginDrawingFrame(DrawingFrame* frame) override;
117 void FinishDrawingFrame(DrawingFrame* frame) override; 121 void FinishDrawingFrame(DrawingFrame* frame) override;
118 bool FlippedFramebuffer(const DrawingFrame* frame) const override; 122 bool FlippedFramebuffer(const DrawingFrame* frame) const override;
119 bool FlippedRootFramebuffer() const; 123 bool FlippedRootFramebuffer() const;
120 void EnsureScissorTestEnabled() override; 124 void EnsureScissorTestEnabled() override;
121 void EnsureScissorTestDisabled() override; 125 void EnsureScissorTestDisabled() override;
122 void CopyCurrentRenderPassToBitmap( 126 void CopyCurrentRenderPassToBitmap(
123 DrawingFrame* frame, 127 DrawingFrame* frame,
124 scoped_ptr<CopyOutputRequest> request) override; 128 scoped_ptr<CopyOutputRequest> request) override;
125 void FinishDrawingQuadList() override; 129 void FinishDrawingQuadList() override;
126 130
127 // Returns true if quad requires antialiasing and false otherwise. 131 // Returns true if quad requires antialiasing and false otherwise.
128 static bool ShouldAntialiasQuad(const gfx::Transform& device_transform, 132 static bool ShouldAntialiasQuad(const gfx::Transform& device_transform,
129 const DrawQuad* quad, 133 const DrawQuad* quad,
130 bool force_antialiasing); 134 bool force_antialiasing);
131 135
132 // Inflate the quad and fill edge array for fragment shader. 136 // Inflate the quad and fill edge array for fragment shader.
133 // |local_quad| is set to inflated quad. |edge| array is filled with 137 // |local_quad| is set to inflated quad. |edge| array is filled with
134 // inflated quad's edge data. 138 // inflated quad's edge data.
135 static void SetupQuadForAntialiasing(const gfx::Transform& device_transform, 139 static void SetupQuadForClippingAndAntialiasing(
136 const DrawQuad* quad, 140 const gfx::Transform& device_transform,
137 gfx::QuadF* local_quad, 141 const DrawQuad* quad,
138 float edge[24]); 142 bool use_aa,
143 const gfx::QuadF* clip_region,
144 gfx::QuadF* local_quad,
145 float edge[24]);
139 146
140 private: 147 private:
141 friend class GLRendererShaderPixelTest; 148 friend class GLRendererShaderPixelTest;
142 friend class GLRendererShaderTest; 149 friend class GLRendererShaderTest;
143 150
144 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); 151 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform);
145 152
146 void DrawCheckerboardQuad(const DrawingFrame* frame, 153 void DrawCheckerboardQuad(const DrawingFrame* frame,
147 const CheckerboardDrawQuad* quad); 154 const CheckerboardDrawQuad* quad,
155 const gfx::QuadF* clip_region);
148 void DrawDebugBorderQuad(const DrawingFrame* frame, 156 void DrawDebugBorderQuad(const DrawingFrame* frame,
149 const DebugBorderDrawQuad* quad); 157 const DebugBorderDrawQuad* quad);
150 static bool IsDefaultBlendMode(SkXfermode::Mode blend_mode) { 158 static bool IsDefaultBlendMode(SkXfermode::Mode blend_mode) {
151 return blend_mode == SkXfermode::kSrcOver_Mode; 159 return blend_mode == SkXfermode::kSrcOver_Mode;
152 } 160 }
153 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); 161 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode);
154 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); 162 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode);
155 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode); 163 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode);
156 164
157 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( 165 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad(
158 DrawingFrame* frame, 166 DrawingFrame* frame,
159 const RenderPassDrawQuad* quad, 167 const RenderPassDrawQuad* quad,
160 const gfx::Transform& contents_device_transform, 168 const gfx::Transform& contents_device_transform,
169 const gfx::QuadF* clip_region,
161 bool use_aa); 170 bool use_aa);
162 scoped_ptr<ScopedResource> GetBackdropTexture(const gfx::Rect& bounding_rect); 171 scoped_ptr<ScopedResource> GetBackdropTexture(const gfx::Rect& bounding_rect);
163 172
164 static bool ShouldApplyBackgroundFilters(DrawingFrame* frame, 173 static bool ShouldApplyBackgroundFilters(DrawingFrame* frame,
165 const RenderPassDrawQuad* quad); 174 const RenderPassDrawQuad* quad);
166 skia::RefPtr<SkImage> ApplyBackgroundFilters( 175 skia::RefPtr<SkImage> ApplyBackgroundFilters(
167 DrawingFrame* frame, 176 DrawingFrame* frame,
168 const RenderPassDrawQuad* quad, 177 const RenderPassDrawQuad* quad,
169 ScopedResource* background_texture); 178 ScopedResource* background_texture);
170 179
171 void DrawRenderPassQuad(DrawingFrame* frame, const RenderPassDrawQuad* quad); 180 void DrawRenderPassQuad(DrawingFrame* frame,
181 const RenderPassDrawQuad* quadi,
182 const gfx::QuadF* clip_region);
172 void DrawSolidColorQuad(const DrawingFrame* frame, 183 void DrawSolidColorQuad(const DrawingFrame* frame,
173 const SolidColorDrawQuad* quad); 184 const SolidColorDrawQuad* quad,
185 const gfx::QuadF* clip_region);
174 void DrawStreamVideoQuad(const DrawingFrame* frame, 186 void DrawStreamVideoQuad(const DrawingFrame* frame,
175 const StreamVideoDrawQuad* quad); 187 const StreamVideoDrawQuad* quad,
188 const gfx::QuadF* clip_region);
189 void DrawTextureQuad(const DrawingFrame* frame,
190 const TextureDrawQuad* quad,
191 const gfx::QuadF* clip_region);
176 void EnqueueTextureQuad(const DrawingFrame* frame, 192 void EnqueueTextureQuad(const DrawingFrame* frame,
177 const TextureDrawQuad* quad); 193 const TextureDrawQuad* quad,
178 void FlushTextureQuadCache(); 194 const gfx::QuadF* clip_region);
195 void FlushTextureQuadCache(BoundGeometry flush_binding);
179 void DrawIOSurfaceQuad(const DrawingFrame* frame, 196 void DrawIOSurfaceQuad(const DrawingFrame* frame,
180 const IOSurfaceDrawQuad* quad); 197 const IOSurfaceDrawQuad* quad,
181 void DrawTileQuad(const DrawingFrame* frame, const TileDrawQuad* quad); 198 const gfx::QuadF* clip_region);
199 void DrawTileQuad(const DrawingFrame* frame,
200 const TileDrawQuad* quad,
201 const gfx::QuadF* clip_region);
182 void DrawContentQuad(const DrawingFrame* frame, 202 void DrawContentQuad(const DrawingFrame* frame,
183 const ContentDrawQuadBase* quad, 203 const ContentDrawQuadBase* quad,
184 ResourceProvider::ResourceId resource_id); 204 ResourceProvider::ResourceId resource_id,
205 const gfx::QuadF* clip_region);
185 void DrawContentQuadAA(const DrawingFrame* frame, 206 void DrawContentQuadAA(const DrawingFrame* frame,
186 const ContentDrawQuadBase* quad, 207 const ContentDrawQuadBase* quad,
187 ResourceProvider::ResourceId resource_id, 208 ResourceProvider::ResourceId resource_id,
188 const gfx::Transform& device_transform); 209 const gfx::Transform& device_transform,
210 const gfx::QuadF* clip_region);
189 void DrawContentQuadNoAA(const DrawingFrame* frame, 211 void DrawContentQuadNoAA(const DrawingFrame* frame,
190 const ContentDrawQuadBase* quad, 212 const ContentDrawQuadBase* quad,
191 ResourceProvider::ResourceId resource_id); 213 ResourceProvider::ResourceId resource_id,
214 const gfx::QuadF* clip_region);
192 void DrawYUVVideoQuad(const DrawingFrame* frame, 215 void DrawYUVVideoQuad(const DrawingFrame* frame,
193 const YUVVideoDrawQuad* quad); 216 const YUVVideoDrawQuad* quad,
217 const gfx::QuadF* clip_region);
194 void DrawPictureQuad(const DrawingFrame* frame, 218 void DrawPictureQuad(const DrawingFrame* frame,
195 const PictureDrawQuad* quad); 219 const PictureDrawQuad* quad,
220 const gfx::QuadF* clip_region);
196 221
197 void SetShaderOpacity(float opacity, int alpha_location); 222 void SetShaderOpacity(float opacity, int alpha_location);
198 void SetShaderQuadF(const gfx::QuadF& quad, int quad_location); 223 void SetShaderQuadF(const gfx::QuadF& quad, int quad_location);
224 void DrawQuadGeometryClippedByQuadF(const DrawingFrame* frame,
225 const gfx::Transform& draw_transform,
226 const gfx::RectF& quad_rect,
227 const gfx::QuadF& clipping_region_quad,
228 int matrix_location,
229 const float uv[8]);
199 void DrawQuadGeometry(const DrawingFrame* frame, 230 void DrawQuadGeometry(const DrawingFrame* frame,
200 const gfx::Transform& draw_transform, 231 const gfx::Transform& draw_transform,
201 const gfx::RectF& quad_rect, 232 const gfx::RectF& quad_rect,
202 int matrix_location); 233 int matrix_location);
203 void SetUseProgram(unsigned program); 234 void SetUseProgram(unsigned program);
204 235
205 bool UseScopedTexture(DrawingFrame* frame, 236 bool UseScopedTexture(DrawingFrame* frame,
206 const ScopedResource* resource, 237 const ScopedResource* resource,
207 const gfx::Rect& viewport_rect); 238 const gfx::Rect& viewport_rect);
208 239
(...skipping 21 matching lines...) Expand all
230 261
231 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL> 262 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL>
232 OverlayResourceLockList; 263 OverlayResourceLockList;
233 OverlayResourceLockList pending_overlay_resources_; 264 OverlayResourceLockList pending_overlay_resources_;
234 OverlayResourceLockList in_use_overlay_resources_; 265 OverlayResourceLockList in_use_overlay_resources_;
235 266
236 RendererCapabilitiesImpl capabilities_; 267 RendererCapabilitiesImpl capabilities_;
237 268
238 unsigned offscreen_framebuffer_id_; 269 unsigned offscreen_framebuffer_id_;
239 270
240 scoped_ptr<GeometryBinding> shared_geometry_; 271 scoped_ptr<StaticGeometryBinding> shared_geometry_;
272 scoped_ptr<DynamicGeometryBinding> clipped_geometry_;
241 gfx::QuadF shared_geometry_quad_; 273 gfx::QuadF shared_geometry_quad_;
242 274
243 // This block of bindings defines all of the programs used by the compositor 275 // This block of bindings defines all of the programs used by the compositor
244 // itself. Add any new programs here to GLRendererShaderTest. 276 // itself. Add any new programs here to GLRendererShaderTest.
245 277
246 // Tiled layer shaders. 278 // Tiled layer shaders.
247 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> 279 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha>
248 TileProgram; 280 TileProgram;
249 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA> 281 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA>
250 TileProgramAA; 282 TileProgramAA;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 class SyncQuery; 505 class SyncQuery;
474 ScopedPtrDeque<SyncQuery> pending_sync_queries_; 506 ScopedPtrDeque<SyncQuery> pending_sync_queries_;
475 ScopedPtrDeque<SyncQuery> available_sync_queries_; 507 ScopedPtrDeque<SyncQuery> available_sync_queries_;
476 scoped_ptr<SyncQuery> current_sync_query_; 508 scoped_ptr<SyncQuery> current_sync_query_;
477 bool use_sync_query_; 509 bool use_sync_query_;
478 bool use_blend_equation_advanced_; 510 bool use_blend_equation_advanced_;
479 bool use_blend_equation_advanced_coherent_; 511 bool use_blend_equation_advanced_coherent_;
480 512
481 SkBitmap on_demand_tile_raster_bitmap_; 513 SkBitmap on_demand_tile_raster_bitmap_;
482 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_; 514 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_;
483 515 BoundGeometry bound_geometry_;
484 DISALLOW_COPY_AND_ASSIGN(GLRenderer); 516 DISALLOW_COPY_AND_ASSIGN(GLRenderer);
485 }; 517 };
486 518
487 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL 519 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL
488 // call made by the compositor. Useful for debugging rendering issues but 520 // call made by the compositor. Useful for debugging rendering issues but
489 // will significantly degrade performance. 521 // will significantly degrade performance.
490 #define DEBUG_GL_CALLS 0 522 #define DEBUG_GL_CALLS 0
491 523
492 #if DEBUG_GL_CALLS && !defined(NDEBUG) 524 #if DEBUG_GL_CALLS && !defined(NDEBUG)
493 #define GLC(context, x) \ 525 #define GLC(context, x) \
494 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) 526 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__))
495 #else 527 #else
496 #define GLC(context, x) (x) 528 #define GLC(context, x) (x)
497 #endif 529 #endif
498 530
499 } // namespace cc 531 } // namespace cc
500 532
501 #endif // CC_OUTPUT_GL_RENDERER_H_ 533 #endif // CC_OUTPUT_GL_RENDERER_H_
OLDNEW
« no previous file with comments | « cc/output/geometry_binding.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698