| OLD | NEW |
| 1 // Copyright 2012 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 #ifndef CC_OUTPUT_DIRECT_RENDERER_H_ | 5 #ifndef CC_OUTPUT_DIRECT_RENDERER_H_ |
| 6 #define CC_OUTPUT_DIRECT_RENDERER_H_ | 6 #define CC_OUTPUT_DIRECT_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/base/scoped_ptr_deque.h" | |
| 13 #include "cc/output/overlay_processor.h" | 12 #include "cc/output/overlay_processor.h" |
| 14 #include "cc/output/renderer.h" | 13 #include "cc/output/renderer.h" |
| 15 #include "cc/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
| 16 #include "cc/resources/scoped_resource.h" | 15 #include "cc/resources/scoped_resource.h" |
| 17 #include "cc/resources/task_graph_runner.h" | |
| 18 #include "ui/gfx/geometry/quad_f.h" | |
| 19 | 16 |
| 20 namespace cc { | 17 namespace cc { |
| 21 | 18 |
| 22 class DrawPolygon; | |
| 23 class ResourceProvider; | 19 class ResourceProvider; |
| 24 | 20 |
| 25 // This is the base class for code shared between the GL and software | 21 // This is the base class for code shared between the GL and software |
| 26 // renderer implementations. "Direct" refers to the fact that it does not | 22 // renderer implementations. "Direct" refers to the fact that it does not |
| 27 // delegate rendering to another compositor. | 23 // delegate rendering to another compositor. |
| 28 class CC_EXPORT DirectRenderer : public Renderer { | 24 class CC_EXPORT DirectRenderer : public Renderer { |
| 29 public: | 25 public: |
| 30 ~DirectRenderer() override; | 26 ~DirectRenderer() override; |
| 31 | 27 |
| 32 void DecideRenderPassAllocationsForFrame( | 28 void DecideRenderPassAllocationsForFrame( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 53 | 49 |
| 54 gfx::Transform projection_matrix; | 50 gfx::Transform projection_matrix; |
| 55 gfx::Transform window_matrix; | 51 gfx::Transform window_matrix; |
| 56 | 52 |
| 57 bool disable_picture_quad_image_filtering; | 53 bool disable_picture_quad_image_filtering; |
| 58 | 54 |
| 59 OverlayCandidateList overlay_list; | 55 OverlayCandidateList overlay_list; |
| 60 }; | 56 }; |
| 61 | 57 |
| 62 void SetEnlargePassTextureAmountForTesting(const gfx::Vector2d& amount); | 58 void SetEnlargePassTextureAmountForTesting(const gfx::Vector2d& amount); |
| 63 void DoDrawPolygon(const DrawPolygon& poly, | |
| 64 DrawingFrame* frame, | |
| 65 const gfx::Rect& render_pass_scissor, | |
| 66 bool using_scissor_as_optimization); | |
| 67 | 59 |
| 68 protected: | 60 protected: |
| 69 DirectRenderer(RendererClient* client, | 61 DirectRenderer(RendererClient* client, |
| 70 const RendererSettings* settings, | 62 const RendererSettings* settings, |
| 71 OutputSurface* output_surface, | 63 OutputSurface* output_surface, |
| 72 ResourceProvider* resource_provider); | 64 ResourceProvider* resource_provider); |
| 73 | 65 |
| 74 static gfx::RectF QuadVertexRect(); | 66 static gfx::RectF QuadVertexRect(); |
| 75 static void QuadRectTransform(gfx::Transform* quad_rect_transform, | 67 static void QuadRectTransform(gfx::Transform* quad_rect_transform, |
| 76 const gfx::Transform& quad_transform, | 68 const gfx::Transform& quad_transform, |
| 77 const gfx::RectF& quad_rect); | 69 const gfx::RectF& quad_rect); |
| 78 void InitializeViewport(DrawingFrame* frame, | 70 void InitializeViewport(DrawingFrame* frame, |
| 79 const gfx::Rect& draw_rect, | 71 const gfx::Rect& draw_rect, |
| 80 const gfx::Rect& viewport_rect, | 72 const gfx::Rect& viewport_rect, |
| 81 const gfx::Size& surface_size); | 73 const gfx::Size& surface_size); |
| 82 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame, | 74 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame, |
| 83 const gfx::Rect& draw_rect) const; | 75 const gfx::Rect& draw_rect) const; |
| 84 | 76 |
| 85 bool NeedDeviceClip(const DrawingFrame* frame) const; | 77 bool NeedDeviceClip(const DrawingFrame* frame) const; |
| 86 gfx::Rect DeviceClipRectInWindowSpace(const DrawingFrame* frame) const; | 78 gfx::Rect DeviceClipRectInWindowSpace(const DrawingFrame* frame) const; |
| 87 static gfx::Rect ComputeScissorRectForRenderPass(const DrawingFrame* frame); | 79 static gfx::Rect ComputeScissorRectForRenderPass(const DrawingFrame* frame); |
| 88 void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); | 80 void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); |
| 89 bool ShouldSkipQuad(const DrawQuad& quad, | |
| 90 const gfx::Rect& render_pass_scissor); | |
| 91 void SetScissorStateForQuadWithRenderPassScissor( | 81 void SetScissorStateForQuadWithRenderPassScissor( |
| 92 const DrawingFrame* frame, | 82 const DrawingFrame* frame, |
| 93 const DrawQuad& quad, | 83 const DrawQuad& quad, |
| 94 const gfx::Rect& render_pass_scissor); | 84 const gfx::Rect& render_pass_scissor, |
| 85 bool* should_skip_quad); |
| 95 void SetScissorTestRectInDrawSpace(const DrawingFrame* frame, | 86 void SetScissorTestRectInDrawSpace(const DrawingFrame* frame, |
| 96 const gfx::Rect& draw_space_rect); | 87 const gfx::Rect& draw_space_rect); |
| 97 | 88 |
| 98 static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); | 89 static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); |
| 99 | 90 |
| 100 void FlushPolygons(ScopedPtrDeque<DrawPolygon>* poly_list, | |
| 101 DrawingFrame* frame, | |
| 102 const gfx::Rect& render_pass_scissor, | |
| 103 bool using_scissor_as_optimization); | |
| 104 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 91 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 105 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 92 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 106 | 93 |
| 107 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; | 94 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; |
| 108 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 95 virtual bool BindFramebufferToTexture(DrawingFrame* frame, |
| 109 const ScopedResource* resource, | 96 const ScopedResource* resource, |
| 110 const gfx::Rect& target_rect) = 0; | 97 const gfx::Rect& target_rect) = 0; |
| 111 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) = 0; | 98 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) = 0; |
| 112 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; | 99 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; |
| 113 virtual void DiscardPixels(bool has_external_stencil_test, | 100 virtual void DiscardPixels(bool has_external_stencil_test, |
| 114 bool draw_rect_covers_full_surface) = 0; | 101 bool draw_rect_covers_full_surface) = 0; |
| 115 virtual void ClearFramebuffer(DrawingFrame* frame, | 102 virtual void ClearFramebuffer(DrawingFrame* frame, |
| 116 bool has_external_stencil_test) = 0; | 103 bool has_external_stencil_test) = 0; |
| 117 // clip_region is a (possibly null) pointer to a quad in the same | 104 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) = 0; |
| 118 // space as the quad. When non-null only the area of the quad that overlaps | |
| 119 // with clip_region will be drawn. | |
| 120 virtual void DoDrawQuad(DrawingFrame* frame, | |
| 121 const DrawQuad* quad, | |
| 122 const gfx::QuadF* clip_region) = 0; | |
| 123 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; | 105 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; |
| 124 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; | 106 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; |
| 125 virtual void FinishDrawingQuadList(); | 107 virtual void FinishDrawingQuadList(); |
| 126 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0; | 108 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0; |
| 127 virtual void EnsureScissorTestEnabled() = 0; | 109 virtual void EnsureScissorTestEnabled() = 0; |
| 128 virtual void EnsureScissorTestDisabled() = 0; | 110 virtual void EnsureScissorTestDisabled() = 0; |
| 129 virtual void DiscardBackbuffer() {} | 111 virtual void DiscardBackbuffer() {} |
| 130 virtual void EnsureBackbuffer() {} | 112 virtual void EnsureBackbuffer() {} |
| 131 | 113 |
| 132 virtual void CopyCurrentRenderPassToBitmap( | 114 virtual void CopyCurrentRenderPassToBitmap( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 149 | 131 |
| 150 private: | 132 private: |
| 151 gfx::Vector2d enlarge_pass_texture_amount_; | 133 gfx::Vector2d enlarge_pass_texture_amount_; |
| 152 | 134 |
| 153 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 135 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
| 154 }; | 136 }; |
| 155 | 137 |
| 156 } // namespace cc | 138 } // namespace cc |
| 157 | 139 |
| 158 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 140 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
| OLD | NEW |