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 <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
13 #include "cc/output/ca_layer_overlay.h" | 13 #include "cc/output/ca_layer_overlay.h" |
14 #include "cc/output/overlay_processor.h" | 14 #include "cc/output/overlay_processor.h" |
15 #include "cc/output/renderer.h" | 15 #include "cc/output/renderer.h" |
16 #include "cc/quads/tile_draw_quad.h" | 16 #include "cc/quads/tile_draw_quad.h" |
17 #include "cc/resources/resource_provider.h" | 17 #include "cc/resources/resource_provider.h" |
18 #include "cc/resources/scoped_resource.h" | 18 #include "cc/resources/scoped_resource.h" |
19 #include "gpu/command_buffer/common/texture_in_use_response.h" | 19 #include "gpu/command_buffer/common/texture_in_use_response.h" |
20 #include "ui/gfx/geometry/quad_f.h" | 20 #include "ui/gfx/geometry/quad_f.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 class DrawPolygon; | 23 class DrawPolygon; |
24 class ResourceProvider; | 24 class ResourceProvider; |
25 typedef std::vector<std::unique_ptr<RenderPass>> RenderPassList; | |
26 | |
27 class CC_EXPORT DirectRendererClient { | |
28 public: | |
29 virtual void SetFullRootLayerDamage() = 0; | |
30 }; | |
25 | 31 |
26 // This is the base class for code shared between the GL and software | 32 // This is the base class for code shared between the GL and software |
27 // renderer implementations. "Direct" refers to the fact that it does not | 33 // renderer implementations. "Direct" refers to the fact that it does not |
28 // delegate rendering to another compositor. | 34 // delegate rendering to another compositor. |
29 class CC_EXPORT DirectRenderer : public Renderer { | 35 class CC_EXPORT DirectRenderer { |
30 public: | 36 public: |
31 ~DirectRenderer() override; | 37 DirectRenderer(DirectRendererClient* client, |
38 const RendererSettings* settings, | |
39 OutputSurface* output_surface, | |
40 ResourceProvider* resource_provider); | |
41 virtual ~DirectRenderer(); | |
32 | 42 |
33 void DecideRenderPassAllocationsForFrame( | 43 void DecideRenderPassAllocationsForFrame( |
34 const RenderPassList& render_passes_in_draw_order) override; | 44 const RenderPassList& render_passes_in_draw_order); |
35 bool HasAllocatedResourcesForTesting(RenderPassId id) const override; | 45 bool HasAllocatedResourcesForTesting(RenderPassId id) const; |
36 void DrawFrame(RenderPassList* render_passes_in_draw_order, | 46 void DrawFrame(RenderPassList* render_passes_in_draw_order, |
37 float device_scale_factor, | 47 float device_scale_factor, |
38 const gfx::ColorSpace& device_color_space, | 48 const gfx::ColorSpace& device_color_space, |
39 const gfx::Rect& device_viewport_rect, | 49 const gfx::Rect& device_viewport_rect, |
40 const gfx::Rect& device_clip_rect) override; | 50 const gfx::Rect& device_clip_rect); |
51 virtual void SwapBuffers(CompositorFrameMetadata metadata) = 0; | |
52 | |
53 virtual const RendererCapabilitiesImpl& Capabilities() const = 0; | |
54 | |
55 // DO THIS: protected: | |
enne (OOO)
2016/08/08 21:41:18
?
| |
41 virtual void SwapBuffersComplete() {} | 56 virtual void SwapBuffersComplete() {} |
42 virtual void DidReceiveTextureInUseResponses( | 57 virtual void DidReceiveTextureInUseResponses( |
43 const gpu::TextureInUseResponses& responses) {} | 58 const gpu::TextureInUseResponses& responses) {} |
44 | 59 |
45 // If a pass contains a single tile draw quad and can be drawn without | 60 // If a pass contains a single tile draw quad and can be drawn without |
46 // a render pass (e.g. applying a filter directly to the tile quad) | 61 // a render pass (e.g. applying a filter directly to the tile quad) |
47 // return that quad, otherwise return null. | 62 // return that quad, otherwise return null. |
48 virtual const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass); | 63 virtual const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass); |
49 | 64 |
50 struct CC_EXPORT DrawingFrame { | 65 struct CC_EXPORT DrawingFrame { |
(...skipping 27 matching lines...) Expand all Loading... | |
78 const gfx::Rect& render_pass_scissor, | 93 const gfx::Rect& render_pass_scissor, |
79 bool use_render_pass_scissor); | 94 bool use_render_pass_scissor); |
80 | 95 |
81 protected: | 96 protected: |
82 enum SurfaceInitializationMode { | 97 enum SurfaceInitializationMode { |
83 SURFACE_INITIALIZATION_MODE_PRESERVE, | 98 SURFACE_INITIALIZATION_MODE_PRESERVE, |
84 SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR, | 99 SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR, |
85 SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR, | 100 SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR, |
86 }; | 101 }; |
87 | 102 |
88 DirectRenderer(RendererClient* client, | |
89 const RendererSettings* settings, | |
90 OutputSurface* output_surface, | |
91 ResourceProvider* resource_provider); | |
92 | |
93 static gfx::RectF QuadVertexRect(); | 103 static gfx::RectF QuadVertexRect(); |
94 static void QuadRectTransform(gfx::Transform* quad_rect_transform, | 104 static void QuadRectTransform(gfx::Transform* quad_rect_transform, |
95 const gfx::Transform& quad_transform, | 105 const gfx::Transform& quad_transform, |
96 const gfx::RectF& quad_rect); | 106 const gfx::RectF& quad_rect); |
97 void InitializeViewport(DrawingFrame* frame, | 107 void InitializeViewport(DrawingFrame* frame, |
98 const gfx::Rect& draw_rect, | 108 const gfx::Rect& draw_rect, |
99 const gfx::Rect& viewport_rect, | 109 const gfx::Rect& viewport_rect, |
100 const gfx::Size& surface_size); | 110 const gfx::Size& surface_size); |
101 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame, | 111 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame, |
102 const gfx::Rect& draw_rect) const; | 112 const gfx::Rect& draw_rect) const; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 // with clip_region will be drawn. | 149 // with clip_region will be drawn. |
140 virtual void DoDrawQuad(DrawingFrame* frame, | 150 virtual void DoDrawQuad(DrawingFrame* frame, |
141 const DrawQuad* quad, | 151 const DrawQuad* quad, |
142 const gfx::QuadF* clip_region) = 0; | 152 const gfx::QuadF* clip_region) = 0; |
143 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; | 153 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; |
144 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; | 154 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; |
145 virtual void FinishDrawingQuadList(); | 155 virtual void FinishDrawingQuadList(); |
146 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0; | 156 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0; |
147 virtual void EnsureScissorTestEnabled() = 0; | 157 virtual void EnsureScissorTestEnabled() = 0; |
148 virtual void EnsureScissorTestDisabled() = 0; | 158 virtual void EnsureScissorTestDisabled() = 0; |
149 virtual void DiscardBackbuffer() {} | |
150 virtual void EnsureBackbuffer() {} | |
151 | 159 |
152 virtual void CopyCurrentRenderPassToBitmap( | 160 virtual void CopyCurrentRenderPassToBitmap( |
153 DrawingFrame* frame, | 161 DrawingFrame* frame, |
154 std::unique_ptr<CopyOutputRequest> request) = 0; | 162 std::unique_ptr<CopyOutputRequest> request) = 0; |
155 | 163 |
164 DirectRendererClient* const client_; | |
165 const RendererSettings* const settings_; | |
166 OutputSurface* const output_surface_; | |
167 ResourceProvider* const resource_provider_; | |
168 | |
156 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. | 169 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. |
157 std::unordered_map<RenderPassId, | 170 std::unordered_map<RenderPassId, |
158 std::unique_ptr<ScopedResource>, | 171 std::unique_ptr<ScopedResource>, |
159 RenderPassIdHash> | 172 RenderPassIdHash> |
160 render_pass_textures_; | 173 render_pass_textures_; |
161 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> | 174 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> |
162 render_pass_bypass_quads_; | 175 render_pass_bypass_quads_; |
163 OutputSurface* output_surface_; | |
164 ResourceProvider* resource_provider_; | |
165 std::unique_ptr<OverlayProcessor> overlay_processor_; | 176 std::unique_ptr<OverlayProcessor> overlay_processor_; |
166 | 177 |
167 // For use in coordinate conversion, this stores the output rect, viewport | 178 // For use in coordinate conversion, this stores the output rect, viewport |
168 // rect (= unflipped version of glViewport rect), the size of target | 179 // rect (= unflipped version of glViewport rect), the size of target |
169 // framebuffer, and the current window space viewport. During a draw, this | 180 // framebuffer, and the current window space viewport. During a draw, this |
170 // stores the values for the current render pass; in between draws, they | 181 // stores the values for the current render pass; in between draws, they |
171 // retain the values for the root render pass of the last draw. | 182 // retain the values for the root render pass of the last draw. |
172 gfx::Rect current_draw_rect_; | 183 gfx::Rect current_draw_rect_; |
173 gfx::Rect current_viewport_rect_; | 184 gfx::Rect current_viewport_rect_; |
174 gfx::Size current_surface_size_; | 185 gfx::Size current_surface_size_; |
175 gfx::Rect current_window_space_viewport_; | 186 gfx::Rect current_window_space_viewport_; |
176 | 187 |
177 private: | 188 private: |
178 gfx::Size enlarge_pass_texture_amount_; | 189 gfx::Size enlarge_pass_texture_amount_; |
179 | 190 |
180 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 191 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
181 }; | 192 }; |
182 | 193 |
183 } // namespace cc | 194 } // namespace cc |
184 | 195 |
185 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 196 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
OLD | NEW |