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" | |
17 #include "cc/raster/task_graph_runner.h" | 16 #include "cc/raster/task_graph_runner.h" |
18 #include "cc/resources/resource_provider.h" | 17 #include "cc/resources/resource_provider.h" |
19 #include "cc/resources/scoped_resource.h" | 18 #include "cc/resources/scoped_resource.h" |
20 #include "ui/gfx/geometry/quad_f.h" | 19 #include "ui/gfx/geometry/quad_f.h" |
21 | 20 |
22 namespace cc { | 21 namespace cc { |
23 class DrawPolygon; | 22 class DrawPolygon; |
24 class ResourceProvider; | 23 class ResourceProvider; |
25 | 24 |
26 // This is the base class for code shared between the GL and software | 25 // 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 | 26 // renderer implementations. "Direct" refers to the fact that it does not |
28 // delegate rendering to another compositor. | 27 // delegate rendering to another compositor. |
29 class CC_EXPORT DirectRenderer : public Renderer { | 28 class CC_EXPORT DirectRenderer : public Renderer { |
30 public: | 29 public: |
31 ~DirectRenderer() override; | 30 ~DirectRenderer() override; |
32 | 31 |
33 void DecideRenderPassAllocationsForFrame( | 32 void DecideRenderPassAllocationsForFrame( |
34 const RenderPassList& render_passes_in_draw_order) override; | 33 const RenderPassList& render_passes_in_draw_order) override; |
35 bool HasAllocatedResourcesForTesting(RenderPassId id) const override; | 34 bool HasAllocatedResourcesForTesting(RenderPassId id) const override; |
36 void DrawFrame(RenderPassList* render_passes_in_draw_order, | 35 void DrawFrame(RenderPassList* render_passes_in_draw_order, |
37 float device_scale_factor, | 36 float device_scale_factor, |
38 const gfx::Rect& device_viewport_rect, | 37 const gfx::Rect& device_viewport_rect, |
39 const gfx::Rect& device_clip_rect, | 38 const gfx::Rect& device_clip_rect, |
40 bool disable_picture_quad_image_filtering) override; | 39 bool disable_picture_quad_image_filtering) override; |
41 virtual void SwapBuffersComplete() {} | 40 virtual void SwapBuffersComplete() {} |
42 | 41 |
43 // If a pass contains a single tile draw quad and can be drawn without | |
44 // a render pass (e.g. applying a filter directly to the tile quad) | |
45 // return that quad, otherwise return null. | |
46 virtual const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass); | |
47 | |
48 struct CC_EXPORT DrawingFrame { | 42 struct CC_EXPORT DrawingFrame { |
49 DrawingFrame(); | 43 DrawingFrame(); |
50 ~DrawingFrame(); | 44 ~DrawingFrame(); |
51 | 45 |
52 const RenderPassList* render_passes_in_draw_order; | 46 const RenderPassList* render_passes_in_draw_order; |
53 const RenderPass* root_render_pass; | 47 const RenderPass* root_render_pass; |
54 const RenderPass* current_render_pass; | 48 const RenderPass* current_render_pass; |
55 const ScopedResource* current_texture; | 49 const ScopedResource* current_texture; |
56 | 50 |
57 gfx::Rect root_damage_rect; | 51 gfx::Rect root_damage_rect; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 145 |
152 virtual void CopyCurrentRenderPassToBitmap( | 146 virtual void CopyCurrentRenderPassToBitmap( |
153 DrawingFrame* frame, | 147 DrawingFrame* frame, |
154 std::unique_ptr<CopyOutputRequest> request) = 0; | 148 std::unique_ptr<CopyOutputRequest> request) = 0; |
155 | 149 |
156 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. | 150 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. |
157 std::unordered_map<RenderPassId, | 151 std::unordered_map<RenderPassId, |
158 std::unique_ptr<ScopedResource>, | 152 std::unique_ptr<ScopedResource>, |
159 RenderPassIdHash> | 153 RenderPassIdHash> |
160 render_pass_textures_; | 154 render_pass_textures_; |
161 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> | |
162 render_pass_bypass_quads_; | |
163 OutputSurface* output_surface_; | 155 OutputSurface* output_surface_; |
164 ResourceProvider* resource_provider_; | 156 ResourceProvider* resource_provider_; |
165 std::unique_ptr<OverlayProcessor> overlay_processor_; | 157 std::unique_ptr<OverlayProcessor> overlay_processor_; |
166 | 158 |
167 // For use in coordinate conversion, this stores the output rect, viewport | 159 // For use in coordinate conversion, this stores the output rect, viewport |
168 // rect (= unflipped version of glViewport rect), the size of target | 160 // rect (= unflipped version of glViewport rect), the size of target |
169 // framebuffer, and the current window space viewport. During a draw, this | 161 // framebuffer, and the current window space viewport. During a draw, this |
170 // stores the values for the current render pass; in between draws, they | 162 // 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. | 163 // retain the values for the root render pass of the last draw. |
172 gfx::Rect current_draw_rect_; | 164 gfx::Rect current_draw_rect_; |
173 gfx::Rect current_viewport_rect_; | 165 gfx::Rect current_viewport_rect_; |
174 gfx::Size current_surface_size_; | 166 gfx::Size current_surface_size_; |
175 gfx::Rect current_window_space_viewport_; | 167 gfx::Rect current_window_space_viewport_; |
176 | 168 |
177 private: | 169 private: |
178 gfx::Size enlarge_pass_texture_amount_; | 170 gfx::Size enlarge_pass_texture_amount_; |
179 | 171 |
180 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 172 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
181 }; | 173 }; |
182 | 174 |
183 } // namespace cc | 175 } // namespace cc |
184 | 176 |
185 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 177 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
OLD | NEW |