| 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 <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class TextureMailboxDeleter; | 42 class TextureMailboxDeleter; |
| 43 class StaticGeometryBinding; | 43 class StaticGeometryBinding; |
| 44 class DynamicGeometryBinding; | 44 class DynamicGeometryBinding; |
| 45 class ScopedEnsureFramebufferAllocation; | 45 class ScopedEnsureFramebufferAllocation; |
| 46 | 46 |
| 47 // Class that handles drawing of composited render layers using GL. | 47 // Class that handles drawing of composited render layers using GL. |
| 48 class CC_EXPORT GLRenderer : public DirectRenderer { | 48 class CC_EXPORT GLRenderer : public DirectRenderer { |
| 49 public: | 49 public: |
| 50 class ScopedUseGrContext; | 50 class ScopedUseGrContext; |
| 51 | 51 |
| 52 static scoped_ptr<GLRenderer> Create( | 52 static std::unique_ptr<GLRenderer> Create( |
| 53 RendererClient* client, | 53 RendererClient* client, |
| 54 const RendererSettings* settings, | 54 const RendererSettings* settings, |
| 55 OutputSurface* output_surface, | 55 OutputSurface* output_surface, |
| 56 ResourceProvider* resource_provider, | 56 ResourceProvider* resource_provider, |
| 57 TextureMailboxDeleter* texture_mailbox_deleter, | 57 TextureMailboxDeleter* texture_mailbox_deleter, |
| 58 int highp_threshold_min); | 58 int highp_threshold_min); |
| 59 | 59 |
| 60 ~GLRenderer() override; | 60 ~GLRenderer() override; |
| 61 | 61 |
| 62 const RendererCapabilitiesImpl& Capabilities() const override; | 62 const RendererCapabilitiesImpl& Capabilities() const override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 | 81 |
| 82 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } | 82 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } |
| 83 | 83 |
| 84 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } | 84 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } |
| 85 const StaticGeometryBinding* SharedGeometry() const { | 85 const StaticGeometryBinding* SharedGeometry() const { |
| 86 return shared_geometry_.get(); | 86 return shared_geometry_.get(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void GetFramebufferPixelsAsync(const DrawingFrame* frame, | 89 void GetFramebufferPixelsAsync(const DrawingFrame* frame, |
| 90 const gfx::Rect& rect, | 90 const gfx::Rect& rect, |
| 91 scoped_ptr<CopyOutputRequest> request); | 91 std::unique_ptr<CopyOutputRequest> request); |
| 92 void GetFramebufferTexture(unsigned texture_id, | 92 void GetFramebufferTexture(unsigned texture_id, |
| 93 ResourceFormat texture_format, | 93 ResourceFormat texture_format, |
| 94 const gfx::Rect& device_rect); | 94 const gfx::Rect& device_rect); |
| 95 void ReleaseRenderPassTextures(); | 95 void ReleaseRenderPassTextures(); |
| 96 enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; | 96 enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; |
| 97 void PrepareGeometry(BoundGeometry geometry_to_bind); | 97 void PrepareGeometry(BoundGeometry geometry_to_bind); |
| 98 void SetStencilEnabled(bool enabled); | 98 void SetStencilEnabled(bool enabled); |
| 99 bool stencil_enabled() const { return stencil_shadow_; } | 99 bool stencil_enabled() const { return stencil_shadow_; } |
| 100 void SetBlendEnabled(bool enabled); | 100 void SetBlendEnabled(bool enabled); |
| 101 bool blend_enabled() const { return blend_shadow_; } | 101 bool blend_enabled() const { return blend_shadow_; } |
| 102 | 102 |
| 103 void BindFramebufferToOutputSurface(DrawingFrame* frame) override; | 103 void BindFramebufferToOutputSurface(DrawingFrame* frame) override; |
| 104 bool BindFramebufferToTexture(DrawingFrame* frame, | 104 bool BindFramebufferToTexture(DrawingFrame* frame, |
| 105 const ScopedResource* resource) override; | 105 const ScopedResource* resource) override; |
| 106 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; | 106 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; |
| 107 void PrepareSurfaceForPass(DrawingFrame* frame, | 107 void PrepareSurfaceForPass(DrawingFrame* frame, |
| 108 SurfaceInitializationMode initialization_mode, | 108 SurfaceInitializationMode initialization_mode, |
| 109 const gfx::Rect& render_pass_scissor) override; | 109 const gfx::Rect& render_pass_scissor) override; |
| 110 void DoDrawQuad(DrawingFrame* frame, | 110 void DoDrawQuad(DrawingFrame* frame, |
| 111 const class DrawQuad*, | 111 const class DrawQuad*, |
| 112 const gfx::QuadF* draw_region) override; | 112 const gfx::QuadF* draw_region) override; |
| 113 void BeginDrawingFrame(DrawingFrame* frame) override; | 113 void BeginDrawingFrame(DrawingFrame* frame) override; |
| 114 void FinishDrawingFrame(DrawingFrame* frame) override; | 114 void FinishDrawingFrame(DrawingFrame* frame) override; |
| 115 bool FlippedFramebuffer(const DrawingFrame* frame) const override; | 115 bool FlippedFramebuffer(const DrawingFrame* frame) const override; |
| 116 bool FlippedRootFramebuffer() const; | 116 bool FlippedRootFramebuffer() const; |
| 117 void EnsureScissorTestEnabled() override; | 117 void EnsureScissorTestEnabled() override; |
| 118 void EnsureScissorTestDisabled() override; | 118 void EnsureScissorTestDisabled() override; |
| 119 void CopyCurrentRenderPassToBitmap( | 119 void CopyCurrentRenderPassToBitmap( |
| 120 DrawingFrame* frame, | 120 DrawingFrame* frame, |
| 121 scoped_ptr<CopyOutputRequest> request) override; | 121 std::unique_ptr<CopyOutputRequest> request) override; |
| 122 void FinishDrawingQuadList() override; | 122 void FinishDrawingQuadList() override; |
| 123 | 123 |
| 124 // Returns true if quad requires antialiasing and false otherwise. | 124 // Returns true if quad requires antialiasing and false otherwise. |
| 125 static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, | 125 static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, |
| 126 bool clipped, | 126 bool clipped, |
| 127 bool force_aa); | 127 bool force_aa); |
| 128 | 128 |
| 129 // Inflate the quad and fill edge array for fragment shader. | 129 // Inflate the quad and fill edge array for fragment shader. |
| 130 // |local_quad| is set to inflated quad. |edge| array is filled with | 130 // |local_quad| is set to inflated quad. |edge| array is filled with |
| 131 // inflated quad's edge data. | 131 // inflated quad's edge data. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 162 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); | 162 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); |
| 163 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); | 163 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); |
| 164 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode); | 164 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode); |
| 165 | 165 |
| 166 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( | 166 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( |
| 167 DrawingFrame* frame, | 167 DrawingFrame* frame, |
| 168 const RenderPassDrawQuad* quad, | 168 const RenderPassDrawQuad* quad, |
| 169 const gfx::Transform& contents_device_transform, | 169 const gfx::Transform& contents_device_transform, |
| 170 const gfx::QuadF* clip_region, | 170 const gfx::QuadF* clip_region, |
| 171 bool use_aa); | 171 bool use_aa); |
| 172 scoped_ptr<ScopedResource> GetBackdropTexture(const gfx::Rect& bounding_rect); | 172 std::unique_ptr<ScopedResource> GetBackdropTexture( |
| 173 const gfx::Rect& bounding_rect); |
| 173 | 174 |
| 174 static bool ShouldApplyBackgroundFilters(const RenderPassDrawQuad* quad); | 175 static bool ShouldApplyBackgroundFilters(const RenderPassDrawQuad* quad); |
| 175 skia::RefPtr<SkImage> ApplyBackgroundFilters( | 176 skia::RefPtr<SkImage> ApplyBackgroundFilters( |
| 176 DrawingFrame* frame, | 177 DrawingFrame* frame, |
| 177 const RenderPassDrawQuad* quad, | 178 const RenderPassDrawQuad* quad, |
| 178 ScopedResource* background_texture, | 179 ScopedResource* background_texture, |
| 179 const gfx::RectF& rect); | 180 const gfx::RectF& rect); |
| 180 | 181 |
| 181 void DrawRenderPassQuad(DrawingFrame* frame, | 182 void DrawRenderPassQuad(DrawingFrame* frame, |
| 182 const RenderPassDrawQuad* quadi, | 183 const RenderPassDrawQuad* quadi, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 const gfx::Transform& draw_transform, | 234 const gfx::Transform& draw_transform, |
| 234 const gfx::RectF& quad_rect, | 235 const gfx::RectF& quad_rect, |
| 235 int matrix_location); | 236 int matrix_location); |
| 236 void SetUseProgram(unsigned program); | 237 void SetUseProgram(unsigned program); |
| 237 | 238 |
| 238 bool MakeContextCurrent(); | 239 bool MakeContextCurrent(); |
| 239 | 240 |
| 240 void InitializeSharedObjects(); | 241 void InitializeSharedObjects(); |
| 241 void CleanupSharedObjects(); | 242 void CleanupSharedObjects(); |
| 242 | 243 |
| 243 typedef base::Callback<void(scoped_ptr<CopyOutputRequest> copy_request, | 244 typedef base::Callback<void(std::unique_ptr<CopyOutputRequest> copy_request, |
| 244 bool success)> | 245 bool success)> |
| 245 AsyncGetFramebufferPixelsCleanupCallback; | 246 AsyncGetFramebufferPixelsCleanupCallback; |
| 246 void FinishedReadback(unsigned source_buffer, | 247 void FinishedReadback(unsigned source_buffer, |
| 247 unsigned query, | 248 unsigned query, |
| 248 const gfx::Size& size); | 249 const gfx::Size& size); |
| 249 | 250 |
| 250 void ReinitializeGLState(); | 251 void ReinitializeGLState(); |
| 251 void RestoreGLState(); | 252 void RestoreGLState(); |
| 252 void RestoreFramebuffer(DrawingFrame* frame); | 253 void RestoreFramebuffer(DrawingFrame* frame); |
| 253 | 254 |
| 254 void DiscardBackbuffer() override; | 255 void DiscardBackbuffer() override; |
| 255 void EnsureBackbuffer() override; | 256 void EnsureBackbuffer() override; |
| 256 void EnforceMemoryPolicy(); | 257 void EnforceMemoryPolicy(); |
| 257 | 258 |
| 258 void ScheduleCALayers(DrawingFrame* frame); | 259 void ScheduleCALayers(DrawingFrame* frame); |
| 259 void ScheduleOverlays(DrawingFrame* frame); | 260 void ScheduleOverlays(DrawingFrame* frame); |
| 260 | 261 |
| 261 using OverlayResourceLockList = | 262 using OverlayResourceLockList = |
| 262 std::vector<scoped_ptr<ResourceProvider::ScopedReadLockGL>>; | 263 std::vector<std::unique_ptr<ResourceProvider::ScopedReadLockGL>>; |
| 263 OverlayResourceLockList pending_overlay_resources_; | 264 OverlayResourceLockList pending_overlay_resources_; |
| 264 std::deque<OverlayResourceLockList> swapped_overlay_resources_; | 265 std::deque<OverlayResourceLockList> swapped_overlay_resources_; |
| 265 | 266 |
| 266 RendererCapabilitiesImpl capabilities_; | 267 RendererCapabilitiesImpl capabilities_; |
| 267 | 268 |
| 268 unsigned offscreen_framebuffer_id_; | 269 unsigned offscreen_framebuffer_id_; |
| 269 | 270 |
| 270 scoped_ptr<StaticGeometryBinding> shared_geometry_; | 271 std::unique_ptr<StaticGeometryBinding> shared_geometry_; |
| 271 scoped_ptr<DynamicGeometryBinding> clipped_geometry_; | 272 std::unique_ptr<DynamicGeometryBinding> clipped_geometry_; |
| 272 gfx::QuadF shared_geometry_quad_; | 273 gfx::QuadF shared_geometry_quad_; |
| 273 | 274 |
| 274 // 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 |
| 275 // itself. Add any new programs here to GLRendererShaderTest. | 276 // itself. Add any new programs here to GLRendererShaderTest. |
| 276 | 277 |
| 277 // Tiled layer shaders. | 278 // Tiled layer shaders. |
| 278 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> | 279 typedef ProgramBinding<VertexShaderTile, FragmentShaderRGBATexAlpha> |
| 279 TileProgram; | 280 TileProgram; |
| 280 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA> | 281 typedef ProgramBinding<VertexShaderTileAA, FragmentShaderRGBATexClampAlphaAA> |
| 281 TileProgramAA; | 282 TileProgramAA; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 bool is_scissor_enabled_; | 492 bool is_scissor_enabled_; |
| 492 bool scissor_rect_needs_reset_; | 493 bool scissor_rect_needs_reset_; |
| 493 bool stencil_shadow_; | 494 bool stencil_shadow_; |
| 494 bool blend_shadow_; | 495 bool blend_shadow_; |
| 495 unsigned program_shadow_; | 496 unsigned program_shadow_; |
| 496 TexturedQuadDrawCache draw_cache_; | 497 TexturedQuadDrawCache draw_cache_; |
| 497 int highp_threshold_min_; | 498 int highp_threshold_min_; |
| 498 int highp_threshold_cache_; | 499 int highp_threshold_cache_; |
| 499 | 500 |
| 500 struct PendingAsyncReadPixels; | 501 struct PendingAsyncReadPixels; |
| 501 std::vector<scoped_ptr<PendingAsyncReadPixels>> pending_async_read_pixels_; | 502 std::vector<std::unique_ptr<PendingAsyncReadPixels>> |
| 503 pending_async_read_pixels_; |
| 502 | 504 |
| 503 scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_; | 505 std::unique_ptr<ResourceProvider::ScopedWriteLockGL> |
| 506 current_framebuffer_lock_; |
| 504 | 507 |
| 505 class SyncQuery; | 508 class SyncQuery; |
| 506 std::deque<scoped_ptr<SyncQuery>> pending_sync_queries_; | 509 std::deque<std::unique_ptr<SyncQuery>> pending_sync_queries_; |
| 507 std::deque<scoped_ptr<SyncQuery>> available_sync_queries_; | 510 std::deque<std::unique_ptr<SyncQuery>> available_sync_queries_; |
| 508 scoped_ptr<SyncQuery> current_sync_query_; | 511 std::unique_ptr<SyncQuery> current_sync_query_; |
| 509 bool use_sync_query_; | 512 bool use_sync_query_; |
| 510 bool use_blend_equation_advanced_; | 513 bool use_blend_equation_advanced_; |
| 511 bool use_blend_equation_advanced_coherent_; | 514 bool use_blend_equation_advanced_coherent_; |
| 512 | 515 |
| 513 SkBitmap on_demand_tile_raster_bitmap_; | 516 SkBitmap on_demand_tile_raster_bitmap_; |
| 514 ResourceId on_demand_tile_raster_resource_id_; | 517 ResourceId on_demand_tile_raster_resource_id_; |
| 515 BoundGeometry bound_geometry_; | 518 BoundGeometry bound_geometry_; |
| 516 DISALLOW_COPY_AND_ASSIGN(GLRenderer); | 519 DISALLOW_COPY_AND_ASSIGN(GLRenderer); |
| 517 }; | 520 }; |
| 518 | 521 |
| 519 } // namespace cc | 522 } // namespace cc |
| 520 | 523 |
| 521 #endif // CC_OUTPUT_GL_RENDERER_H_ | 524 #endif // CC_OUTPUT_GL_RENDERER_H_ |
| OLD | NEW |