| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 virtual bool IsContextLost(); | 64 virtual bool IsContextLost(); |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 void DidChangeVisibility() override; | 67 void DidChangeVisibility() override; |
| 68 | 68 |
| 69 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } | 69 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } |
| 70 const StaticGeometryBinding* SharedGeometry() const { | 70 const StaticGeometryBinding* SharedGeometry() const { |
| 71 return shared_geometry_.get(); | 71 return shared_geometry_.get(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void GetFramebufferPixelsAsync(const DrawingFrame* frame, | 74 void GetFramebufferPixelsAsync(const gfx::Rect& rect, |
| 75 const gfx::Rect& rect, | |
| 76 std::unique_ptr<CopyOutputRequest> request); | 75 std::unique_ptr<CopyOutputRequest> request); |
| 77 void GetFramebufferTexture(unsigned texture_id, | 76 void GetFramebufferTexture(unsigned texture_id, |
| 78 const gfx::Rect& device_rect); | 77 const gfx::Rect& device_rect); |
| 79 void ReleaseRenderPassTextures(); | 78 void ReleaseRenderPassTextures(); |
| 80 enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; | 79 enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; |
| 81 void PrepareGeometry(BoundGeometry geometry_to_bind); | 80 void PrepareGeometry(BoundGeometry geometry_to_bind); |
| 82 void SetStencilEnabled(bool enabled); | 81 void SetStencilEnabled(bool enabled); |
| 83 bool stencil_enabled() const { return stencil_shadow_; } | 82 bool stencil_enabled() const { return stencil_shadow_; } |
| 84 void SetBlendEnabled(bool enabled); | 83 void SetBlendEnabled(bool enabled); |
| 85 bool blend_enabled() const { return blend_shadow_; } | 84 bool blend_enabled() const { return blend_shadow_; } |
| 86 | 85 |
| 87 bool CanPartialSwap() override; | 86 bool CanPartialSwap() override; |
| 88 ResourceFormat BackbufferFormat() const override; | 87 ResourceFormat BackbufferFormat() const override; |
| 89 void BindFramebufferToOutputSurface(DrawingFrame* frame) override; | 88 void BindFramebufferToOutputSurface() override; |
| 90 bool BindFramebufferToTexture(DrawingFrame* frame, | 89 bool BindFramebufferToTexture(const ScopedResource* resource) override; |
| 91 const ScopedResource* resource) override; | |
| 92 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; | 90 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; |
| 93 void PrepareSurfaceForPass(DrawingFrame* frame, | 91 void PrepareSurfaceForPass(SurfaceInitializationMode initialization_mode, |
| 94 SurfaceInitializationMode initialization_mode, | |
| 95 const gfx::Rect& render_pass_scissor) override; | 92 const gfx::Rect& render_pass_scissor) override; |
| 96 void DoDrawQuad(DrawingFrame* frame, | 93 void DoDrawQuad(const class DrawQuad*, |
| 97 const class DrawQuad*, | |
| 98 const gfx::QuadF* draw_region) override; | 94 const gfx::QuadF* draw_region) override; |
| 99 void BeginDrawingFrame(DrawingFrame* frame) override; | 95 void BeginDrawingFrame() override; |
| 100 void FinishDrawingFrame(DrawingFrame* frame) override; | 96 void FinishDrawingFrame() override; |
| 101 bool FlippedFramebuffer(const DrawingFrame* frame) const override; | 97 bool FlippedFramebuffer() const override; |
| 102 bool FlippedRootFramebuffer() const; | 98 bool FlippedRootFramebuffer() const; |
| 103 void EnsureScissorTestEnabled() override; | 99 void EnsureScissorTestEnabled() override; |
| 104 void EnsureScissorTestDisabled() override; | 100 void EnsureScissorTestDisabled() override; |
| 105 void CopyCurrentRenderPassToBitmap( | 101 void CopyCurrentRenderPassToBitmap( |
| 106 DrawingFrame* frame, | |
| 107 std::unique_ptr<CopyOutputRequest> request) override; | 102 std::unique_ptr<CopyOutputRequest> request) override; |
| 108 void FinishDrawingQuadList() override; | 103 void FinishDrawingQuadList() override; |
| 109 | 104 |
| 110 // Returns true if quad requires antialiasing and false otherwise. | 105 // Returns true if quad requires antialiasing and false otherwise. |
| 111 static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, | 106 static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, |
| 112 bool clipped, | 107 bool clipped, |
| 113 bool force_aa); | 108 bool force_aa); |
| 114 | 109 |
| 115 // Inflate the quad and fill edge array for fragment shader. | 110 // Inflate the quad and fill edge array for fragment shader. |
| 116 // |local_quad| is set to inflated quad. |edge| array is filled with | 111 // |local_quad| is set to inflated quad. |edge| array is filled with |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 bool UpdateRPDQWithSkiaFilters(DrawRenderPassDrawQuadParams* params); | 136 bool UpdateRPDQWithSkiaFilters(DrawRenderPassDrawQuadParams* params); |
| 142 void UpdateRPDQTexturesForSampling(DrawRenderPassDrawQuadParams* params); | 137 void UpdateRPDQTexturesForSampling(DrawRenderPassDrawQuadParams* params); |
| 143 void UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params); | 138 void UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params); |
| 144 void ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params); | 139 void ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params); |
| 145 void UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params); | 140 void UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params); |
| 146 void DrawRPDQ(const DrawRenderPassDrawQuadParams& params); | 141 void DrawRPDQ(const DrawRenderPassDrawQuadParams& params); |
| 147 | 142 |
| 148 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); | 143 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); |
| 149 | 144 |
| 150 void DiscardPixels(); | 145 void DiscardPixels(); |
| 151 void ClearFramebuffer(DrawingFrame* frame); | 146 void ClearFramebuffer(); |
| 152 void SetViewport(); | 147 void SetViewport(); |
| 153 | 148 |
| 154 void DrawDebugBorderQuad(const DrawingFrame* frame, | 149 void DrawDebugBorderQuad(const DebugBorderDrawQuad* quad); |
| 155 const DebugBorderDrawQuad* quad); | |
| 156 static bool IsDefaultBlendMode(SkBlendMode blend_mode) { | 150 static bool IsDefaultBlendMode(SkBlendMode blend_mode) { |
| 157 return blend_mode == SkBlendMode::kSrcOver; | 151 return blend_mode == SkBlendMode::kSrcOver; |
| 158 } | 152 } |
| 159 bool CanApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); | 153 bool CanApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); |
| 160 void ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); | 154 void ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); |
| 161 void RestoreBlendFuncToDefault(SkBlendMode blend_mode); | 155 void RestoreBlendFuncToDefault(SkBlendMode blend_mode); |
| 162 | 156 |
| 163 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( | 157 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( |
| 164 DrawingFrame* frame, | |
| 165 const RenderPassDrawQuad* quad, | 158 const RenderPassDrawQuad* quad, |
| 166 const gfx::Transform& contents_device_transform, | 159 const gfx::Transform& contents_device_transform, |
| 167 const FilterOperations* filters, | 160 const FilterOperations* filters, |
| 168 const FilterOperations* background_filters, | 161 const FilterOperations* background_filters, |
| 169 const gfx::QuadF* clip_region, | 162 const gfx::QuadF* clip_region, |
| 170 bool use_aa, | 163 bool use_aa, |
| 171 gfx::Rect* unclipped_rect); | 164 gfx::Rect* unclipped_rect); |
| 172 std::unique_ptr<ScopedResource> GetBackdropTexture( | 165 std::unique_ptr<ScopedResource> GetBackdropTexture( |
| 173 DrawingFrame* frame, | |
| 174 const gfx::Rect& bounding_rect); | 166 const gfx::Rect& bounding_rect); |
| 175 | 167 |
| 176 static bool ShouldApplyBackgroundFilters( | 168 static bool ShouldApplyBackgroundFilters( |
| 177 const RenderPassDrawQuad* quad, | 169 const RenderPassDrawQuad* quad, |
| 178 const FilterOperations* background_filters); | 170 const FilterOperations* background_filters); |
| 179 sk_sp<SkImage> ApplyBackgroundFilters( | 171 sk_sp<SkImage> ApplyBackgroundFilters( |
| 180 const RenderPassDrawQuad* quad, | 172 const RenderPassDrawQuad* quad, |
| 181 const FilterOperations& background_filters, | 173 const FilterOperations& background_filters, |
| 182 ScopedResource* background_texture, | 174 ScopedResource* background_texture, |
| 183 const gfx::RectF& rect, | 175 const gfx::RectF& rect, |
| 184 const gfx::RectF& unclipped_rect); | 176 const gfx::RectF& unclipped_rect); |
| 185 | 177 |
| 186 const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass) override; | 178 const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass) override; |
| 187 | 179 |
| 188 void DrawRenderPassQuad(DrawingFrame* frame, | 180 void DrawRenderPassQuad(const RenderPassDrawQuad* quadi, |
| 189 const RenderPassDrawQuad* quadi, | |
| 190 const gfx::QuadF* clip_region); | 181 const gfx::QuadF* clip_region); |
| 191 void DrawRenderPassQuadInternal(DrawRenderPassDrawQuadParams* params); | 182 void DrawRenderPassQuadInternal(DrawRenderPassDrawQuadParams* params); |
| 192 void DrawSolidColorQuad(const DrawingFrame* frame, | 183 void DrawSolidColorQuad(const SolidColorDrawQuad* quad, |
| 193 const SolidColorDrawQuad* quad, | |
| 194 const gfx::QuadF* clip_region); | 184 const gfx::QuadF* clip_region); |
| 195 void DrawStreamVideoQuad(const DrawingFrame* frame, | 185 void DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, |
| 196 const StreamVideoDrawQuad* quad, | |
| 197 const gfx::QuadF* clip_region); | 186 const gfx::QuadF* clip_region); |
| 198 void DrawTextureQuad(const DrawingFrame* frame, | 187 void DrawTextureQuad(const TextureDrawQuad* quad, |
| 199 const TextureDrawQuad* quad, | |
| 200 const gfx::QuadF* clip_region); | 188 const gfx::QuadF* clip_region); |
| 201 void EnqueueTextureQuad(const DrawingFrame* frame, | 189 void EnqueueTextureQuad(const TextureDrawQuad* quad, |
| 202 const TextureDrawQuad* quad, | |
| 203 const gfx::QuadF* clip_region); | 190 const gfx::QuadF* clip_region); |
| 204 void FlushTextureQuadCache(BoundGeometry flush_binding); | 191 void FlushTextureQuadCache(BoundGeometry flush_binding); |
| 205 void DrawTileQuad(const DrawingFrame* frame, | 192 void DrawTileQuad(const TileDrawQuad* quad, const gfx::QuadF* clip_region); |
| 206 const TileDrawQuad* quad, | 193 void DrawContentQuad(const ContentDrawQuadBase* quad, |
| 207 const gfx::QuadF* clip_region); | |
| 208 void DrawContentQuad(const DrawingFrame* frame, | |
| 209 const ContentDrawQuadBase* quad, | |
| 210 ResourceId resource_id, | 194 ResourceId resource_id, |
| 211 const gfx::QuadF* clip_region); | 195 const gfx::QuadF* clip_region); |
| 212 void DrawContentQuadAA(const DrawingFrame* frame, | 196 void DrawContentQuadAA(const ContentDrawQuadBase* quad, |
| 213 const ContentDrawQuadBase* quad, | |
| 214 ResourceId resource_id, | 197 ResourceId resource_id, |
| 215 const gfx::Transform& device_transform, | 198 const gfx::Transform& device_transform, |
| 216 const gfx::QuadF& aa_quad, | 199 const gfx::QuadF& aa_quad, |
| 217 const gfx::QuadF* clip_region); | 200 const gfx::QuadF* clip_region); |
| 218 void DrawContentQuadNoAA(const DrawingFrame* frame, | 201 void DrawContentQuadNoAA(const ContentDrawQuadBase* quad, |
| 219 const ContentDrawQuadBase* quad, | |
| 220 ResourceId resource_id, | 202 ResourceId resource_id, |
| 221 const gfx::QuadF* clip_region); | 203 const gfx::QuadF* clip_region); |
| 222 void DrawYUVVideoQuad(const DrawingFrame* frame, | 204 void DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, |
| 223 const YUVVideoDrawQuad* quad, | |
| 224 const gfx::QuadF* clip_region); | 205 const gfx::QuadF* clip_region); |
| 225 | 206 |
| 226 void SetShaderOpacity(const DrawQuad* quad); | 207 void SetShaderOpacity(const DrawQuad* quad); |
| 227 void SetShaderQuadF(const gfx::QuadF& quad); | 208 void SetShaderQuadF(const gfx::QuadF& quad); |
| 228 void SetShaderMatrix(const gfx::Transform& transform); | 209 void SetShaderMatrix(const gfx::Transform& transform); |
| 229 void SetShaderColor(SkColor color, float opacity); | 210 void SetShaderColor(SkColor color, float opacity); |
| 230 void DrawQuadGeometryClippedByQuadF(const DrawingFrame* frame, | 211 void DrawQuadGeometryClippedByQuadF(const gfx::Transform& draw_transform, |
| 231 const gfx::Transform& draw_transform, | |
| 232 const gfx::RectF& quad_rect, | 212 const gfx::RectF& quad_rect, |
| 233 const gfx::QuadF& clipping_region_quad, | 213 const gfx::QuadF& clipping_region_quad, |
| 234 const float uv[8]); | 214 const float uv[8]); |
| 235 void DrawQuadGeometry(const gfx::Transform& projection_matrix, | 215 void DrawQuadGeometry(const gfx::Transform& projection_matrix, |
| 236 const gfx::Transform& draw_transform, | 216 const gfx::Transform& draw_transform, |
| 237 const gfx::RectF& quad_rect); | 217 const gfx::RectF& quad_rect); |
| 238 void SetUseProgram(const Program* program); | 218 void SetUseProgram(const Program* program); |
| 239 | 219 |
| 240 bool MakeContextCurrent(); | 220 bool MakeContextCurrent(); |
| 241 | 221 |
| 242 void InitializeSharedObjects(); | 222 void InitializeSharedObjects(); |
| 243 void CleanupSharedObjects(); | 223 void CleanupSharedObjects(); |
| 244 | 224 |
| 245 typedef base::Callback<void(std::unique_ptr<CopyOutputRequest> copy_request, | 225 typedef base::Callback<void(std::unique_ptr<CopyOutputRequest> copy_request, |
| 246 bool success)> | 226 bool success)> |
| 247 AsyncGetFramebufferPixelsCleanupCallback; | 227 AsyncGetFramebufferPixelsCleanupCallback; |
| 248 void FinishedReadback(unsigned source_buffer, | 228 void FinishedReadback(unsigned source_buffer, |
| 249 unsigned query, | 229 unsigned query, |
| 250 const gfx::Size& size); | 230 const gfx::Size& size); |
| 251 | 231 |
| 252 void ReinitializeGLState(); | 232 void ReinitializeGLState(); |
| 253 void RestoreGLState(); | 233 void RestoreGLState(); |
| 254 | 234 |
| 255 void ScheduleCALayers(DrawingFrame* frame); | 235 void ScheduleCALayers(); |
| 256 void ScheduleOverlays(DrawingFrame* frame); | 236 void ScheduleOverlays(); |
| 257 | 237 |
| 258 // Copies the contents of the render pass draw quad, including filter effects, | 238 // Copies the contents of the render pass draw quad, including filter effects, |
| 259 // to an overlay resource, returned in |resource|. The resource is allocated | 239 // to an overlay resource, returned in |resource|. The resource is allocated |
| 260 // from |overlay_resource_pool_|. | 240 // from |overlay_resource_pool_|. |
| 261 // The resulting Resource may be larger than the original quad. The new size | 241 // The resulting Resource may be larger than the original quad. The new size |
| 262 // and position is placed in |new_bounds|. | 242 // and position is placed in |new_bounds|. |
| 263 void CopyRenderPassDrawQuadToOverlayResource( | 243 void CopyRenderPassDrawQuadToOverlayResource( |
| 264 const CALayerOverlay* ca_layer_overlay, | 244 const CALayerOverlay* ca_layer_overlay, |
| 265 Resource** resource, | 245 Resource** resource, |
| 266 DrawingFrame* frame, | |
| 267 gfx::RectF* new_bounds); | 246 gfx::RectF* new_bounds); |
| 268 | 247 |
| 269 // Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null | 248 // Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null |
| 270 // |rpdq| parameter. | 249 // |rpdq| parameter. |
| 271 void ScheduleRenderPassDrawQuad(const CALayerOverlay* ca_layer_overlay, | 250 void ScheduleRenderPassDrawQuad(const CALayerOverlay* ca_layer_overlay); |
| 272 DrawingFrame* external_frame); | |
| 273 | 251 |
| 274 // Setup/flush all pending overdraw feedback to framebuffer. | 252 // Setup/flush all pending overdraw feedback to framebuffer. |
| 275 void SetupOverdrawFeedback(); | 253 void SetupOverdrawFeedback(); |
| 276 void FlushOverdrawFeedback(const DrawingFrame* frame, | 254 void FlushOverdrawFeedback(const gfx::Rect& output_rect); |
| 277 const gfx::Rect& output_rect); | |
| 278 // Process overdraw feedback from query. | 255 // Process overdraw feedback from query. |
| 279 using OverdrawFeedbackCallback = base::Callback<void(unsigned, int)>; | 256 using OverdrawFeedbackCallback = base::Callback<void(unsigned, int)>; |
| 280 void ProcessOverdrawFeedback(std::vector<int>* overdraw, | 257 void ProcessOverdrawFeedback(std::vector<int>* overdraw, |
| 281 size_t num_expected_results, | 258 size_t num_expected_results, |
| 282 int max_result, | 259 int max_result, |
| 283 unsigned query, | 260 unsigned query, |
| 284 int multiplier); | 261 int multiplier); |
| 285 | 262 |
| 286 using OverlayResourceLock = | 263 using OverlayResourceLock = |
| 287 std::unique_ptr<ResourceProvider::ScopedReadLockGL>; | 264 std::unique_ptr<ResourceProvider::ScopedReadLockGL>; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 gfx::Size offscreen_stencil_renderbuffer_size_; | 347 gfx::Size offscreen_stencil_renderbuffer_size_; |
| 371 | 348 |
| 372 base::WeakPtrFactory<GLRenderer> weak_ptr_factory_; | 349 base::WeakPtrFactory<GLRenderer> weak_ptr_factory_; |
| 373 | 350 |
| 374 DISALLOW_COPY_AND_ASSIGN(GLRenderer); | 351 DISALLOW_COPY_AND_ASSIGN(GLRenderer); |
| 375 }; | 352 }; |
| 376 | 353 |
| 377 } // namespace cc | 354 } // namespace cc |
| 378 | 355 |
| 379 #endif // CC_OUTPUT_GL_RENDERER_H_ | 356 #endif // CC_OUTPUT_GL_RENDERER_H_ |
| OLD | NEW |