Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: cc/output/direct_renderer.h

Issue 2194013002: cc: Delete the Renderer base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dcheck-delegating
Patch Set: delete-renderer-base-class: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/delegating_renderer.cc ('k') | cc/output/direct_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
8 #include <unordered_map> 9 #include <unordered_map>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
13 #include "cc/output/ca_layer_overlay.h" 14 #include "cc/output/ca_layer_overlay.h"
15 #include "cc/output/compositor_frame_metadata.h"
14 #include "cc/output/overlay_processor.h" 16 #include "cc/output/overlay_processor.h"
15 #include "cc/output/renderer.h" 17 #include "cc/output/renderer_capabilities_impl.h"
16 #include "cc/quads/tile_draw_quad.h" 18 #include "cc/quads/tile_draw_quad.h"
17 #include "cc/resources/resource_provider.h" 19 #include "cc/resources/resource_provider.h"
18 #include "cc/resources/scoped_resource.h"
19 #include "gpu/command_buffer/common/texture_in_use_response.h" 20 #include "gpu/command_buffer/common/texture_in_use_response.h"
20 #include "ui/gfx/geometry/quad_f.h" 21 #include "ui/gfx/geometry/quad_f.h"
22 #include "ui/gfx/geometry/rect.h"
23
24 namespace gfx {
25 class ColorSpace;
26 }
21 27
22 namespace cc { 28 namespace cc {
23 class DrawPolygon; 29 class DrawPolygon;
30 class OutputSurface;
31 class RenderPass;
32 class RenderPassId;
33 class RendererSettings;
24 class ResourceProvider; 34 class ResourceProvider;
35 class ScopedResource;
25 36
26 // This is the base class for code shared between the GL and software 37 // 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 38 // renderer implementations. "Direct" refers to the fact that it does not
28 // delegate rendering to another compositor. 39 // delegate rendering to another compositor (see historical DelegatingRenderer
29 class CC_EXPORT DirectRenderer : public Renderer { 40 // for reference).
41 class CC_EXPORT DirectRenderer {
30 public: 42 public:
31 ~DirectRenderer() override; 43 DirectRenderer(const RendererSettings* settings,
44 OutputSurface* output_surface,
45 ResourceProvider* resource_provider);
46 virtual ~DirectRenderer();
32 47
48 void SetVisible(bool visible);
33 void DecideRenderPassAllocationsForFrame( 49 void DecideRenderPassAllocationsForFrame(
34 const RenderPassList& render_passes_in_draw_order) override; 50 const RenderPassList& render_passes_in_draw_order);
35 bool HasAllocatedResourcesForTesting(RenderPassId id) const override; 51 bool HasAllocatedResourcesForTesting(RenderPassId id) const;
36 void DrawFrame(RenderPassList* render_passes_in_draw_order, 52 void DrawFrame(RenderPassList* render_passes_in_draw_order,
37 float device_scale_factor, 53 float device_scale_factor,
38 const gfx::ColorSpace& device_color_space, 54 const gfx::ColorSpace& device_color_space,
39 const gfx::Rect& device_viewport_rect, 55 const gfx::Rect& device_viewport_rect,
40 const gfx::Rect& device_clip_rect) override; 56 const gfx::Rect& device_clip_rect);
57
58 // Public interface implemented by subclasses.
59 virtual const RendererCapabilitiesImpl& Capabilities() const = 0;
60 virtual void SwapBuffers(CompositorFrameMetadata metadata) = 0;
41 virtual void SwapBuffersComplete() {} 61 virtual void SwapBuffersComplete() {}
42 virtual void DidReceiveTextureInUseResponses( 62 virtual void DidReceiveTextureInUseResponses(
43 const gpu::TextureInUseResponses& responses) {} 63 const gpu::TextureInUseResponses& responses) {}
44 64
45 // If a pass contains a single tile draw quad and can be drawn without 65 // Allow tests to enlarge the texture size of non-root render passes to
46 // a render pass (e.g. applying a filter directly to the tile quad) 66 // verify cases where the texture doesn't match the render pass size.
47 // return that quad, otherwise return null. 67 void SetEnlargePassTextureAmountForTesting(const gfx::Size& amount) {
48 virtual const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass); 68 enlarge_pass_texture_amount_ = amount;
69 }
49 70
71 // Public for tests that poke at internals.
50 struct CC_EXPORT DrawingFrame { 72 struct CC_EXPORT DrawingFrame {
51 DrawingFrame(); 73 DrawingFrame();
52 ~DrawingFrame(); 74 ~DrawingFrame();
53 75
54 const RenderPassList* render_passes_in_draw_order; 76 const RenderPassList* render_passes_in_draw_order = nullptr;
55 const RenderPass* root_render_pass; 77 const RenderPass* root_render_pass = nullptr;
56 const RenderPass* current_render_pass; 78 const RenderPass* current_render_pass = nullptr;
57 const ScopedResource* current_texture; 79 const ScopedResource* current_texture = nullptr;
58 80
59 gfx::Rect root_damage_rect; 81 gfx::Rect root_damage_rect;
60 gfx::Rect device_viewport_rect; 82 gfx::Rect device_viewport_rect;
61 gfx::Rect device_clip_rect; 83 gfx::Rect device_clip_rect;
62 84
63 gfx::Transform projection_matrix; 85 gfx::Transform projection_matrix;
64 gfx::Transform window_matrix; 86 gfx::Transform window_matrix;
65 87
66 OverlayCandidateList overlay_list; 88 OverlayCandidateList overlay_list;
67 CALayerOverlayList ca_layer_overlay_list; 89 CALayerOverlayList ca_layer_overlay_list;
68 }; 90 };
69 91
70 // Allow tests to enlarge the texture size of non-root render passes to 92 protected:
71 // verify cases where the texture doesn't match the render pass size. 93 friend class BspWalkActionDrawPolygon;
72 void SetEnlargePassTextureAmount(const gfx::Size& amount) {
73 enlarge_pass_texture_amount_ = amount;
74 }
75 94
76 void DoDrawPolygon(const DrawPolygon& poly,
77 DrawingFrame* frame,
78 const gfx::Rect& render_pass_scissor,
79 bool use_render_pass_scissor);
80
81 protected:
82 enum SurfaceInitializationMode { 95 enum SurfaceInitializationMode {
83 SURFACE_INITIALIZATION_MODE_PRESERVE, 96 SURFACE_INITIALIZATION_MODE_PRESERVE,
84 SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR, 97 SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR,
85 SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR, 98 SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR,
86 }; 99 };
87 100
88 DirectRenderer(const RendererSettings* settings,
89 OutputSurface* output_surface,
90 ResourceProvider* resource_provider);
91
92 static gfx::RectF QuadVertexRect(); 101 static gfx::RectF QuadVertexRect();
93 static void QuadRectTransform(gfx::Transform* quad_rect_transform, 102 static void QuadRectTransform(gfx::Transform* quad_rect_transform,
94 const gfx::Transform& quad_transform, 103 const gfx::Transform& quad_transform,
95 const gfx::RectF& quad_rect); 104 const gfx::RectF& quad_rect);
96 void InitializeViewport(DrawingFrame* frame, 105 void InitializeViewport(DrawingFrame* frame,
97 const gfx::Rect& draw_rect, 106 const gfx::Rect& draw_rect,
98 const gfx::Rect& viewport_rect, 107 const gfx::Rect& viewport_rect,
99 const gfx::Size& surface_size); 108 const gfx::Size& surface_size);
100 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame, 109 gfx::Rect MoveFromDrawToWindowSpace(const DrawingFrame* frame,
101 const gfx::Rect& draw_rect) const; 110 const gfx::Rect& draw_rect) const;
(...skipping 16 matching lines...) Expand all
118 127
119 void FlushPolygons(std::deque<std::unique_ptr<DrawPolygon>>* poly_list, 128 void FlushPolygons(std::deque<std::unique_ptr<DrawPolygon>>* poly_list,
120 DrawingFrame* frame, 129 DrawingFrame* frame,
121 const gfx::Rect& render_pass_scissor, 130 const gfx::Rect& render_pass_scissor,
122 bool use_render_pass_scissor); 131 bool use_render_pass_scissor);
123 void DrawRenderPassAndExecuteCopyRequests(DrawingFrame* frame, 132 void DrawRenderPassAndExecuteCopyRequests(DrawingFrame* frame,
124 RenderPass* render_pass); 133 RenderPass* render_pass);
125 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); 134 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass);
126 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); 135 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass);
127 136
137 void DoDrawPolygon(const DrawPolygon& poly,
138 DrawingFrame* frame,
139 const gfx::Rect& render_pass_scissor,
140 bool use_render_pass_scissor);
141
142 // Private interface implemented by subclasses for use by DirectRenderer.
128 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; 143 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0;
129 virtual bool BindFramebufferToTexture(DrawingFrame* frame, 144 virtual bool BindFramebufferToTexture(DrawingFrame* frame,
130 const ScopedResource* resource) = 0; 145 const ScopedResource* resource) = 0;
131 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; 146 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0;
132 virtual void PrepareSurfaceForPass( 147 virtual void PrepareSurfaceForPass(
133 DrawingFrame* frame, 148 DrawingFrame* frame,
134 SurfaceInitializationMode initialization_mode, 149 SurfaceInitializationMode initialization_mode,
135 const gfx::Rect& render_pass_scissor) = 0; 150 const gfx::Rect& render_pass_scissor) = 0;
136 // clip_region is a (possibly null) pointer to a quad in the same 151 // |clip_region| is a (possibly null) pointer to a quad in the same
137 // space as the quad. When non-null only the area of the quad that overlaps 152 // space as the quad. When non-null only the area of the quad that overlaps
138 // with clip_region will be drawn. 153 // with clip_region will be drawn.
139 virtual void DoDrawQuad(DrawingFrame* frame, 154 virtual void DoDrawQuad(DrawingFrame* frame,
140 const DrawQuad* quad, 155 const DrawQuad* quad,
141 const gfx::QuadF* clip_region) = 0; 156 const gfx::QuadF* clip_region) = 0;
142 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; 157 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0;
143 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; 158 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0;
144 virtual void FinishDrawingQuadList(); 159 // If a pass contains a single tile draw quad and can be drawn without
160 // a render pass (e.g. applying a filter directly to the tile quad)
161 // return that quad, otherwise return null.
162 virtual const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass);
163 virtual void FinishDrawingQuadList() {}
145 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0; 164 virtual bool FlippedFramebuffer(const DrawingFrame* frame) const = 0;
146 virtual void EnsureScissorTestEnabled() = 0; 165 virtual void EnsureScissorTestEnabled() = 0;
147 virtual void EnsureScissorTestDisabled() = 0; 166 virtual void EnsureScissorTestDisabled() = 0;
148 167 virtual void DidChangeVisibility() = 0;
149 virtual void CopyCurrentRenderPassToBitmap( 168 virtual void CopyCurrentRenderPassToBitmap(
150 DrawingFrame* frame, 169 DrawingFrame* frame,
151 std::unique_ptr<CopyOutputRequest> request) = 0; 170 std::unique_ptr<CopyOutputRequest> request) = 0;
152 171
172 const RendererSettings* const settings_;
173 OutputSurface* const output_surface_;
174 ResourceProvider* const resource_provider_;
175 // This can be replaced by test implementations.
176 std::unique_ptr<OverlayProcessor> overlay_processor_;
177
153 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. 178 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill.
154 std::unordered_map<RenderPassId, 179 std::unordered_map<RenderPassId,
155 std::unique_ptr<ScopedResource>, 180 std::unique_ptr<ScopedResource>,
156 RenderPassIdHash> 181 RenderPassIdHash>
157 render_pass_textures_; 182 render_pass_textures_;
158 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> 183 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash>
159 render_pass_bypass_quads_; 184 render_pass_bypass_quads_;
160 OutputSurface* output_surface_; 185
161 ResourceProvider* resource_provider_; 186 bool visible_;
162 std::unique_ptr<OverlayProcessor> overlay_processor_;
163 187
164 // For use in coordinate conversion, this stores the output rect, viewport 188 // For use in coordinate conversion, this stores the output rect, viewport
165 // rect (= unflipped version of glViewport rect), the size of target 189 // rect (= unflipped version of glViewport rect), the size of target
166 // framebuffer, and the current window space viewport. During a draw, this 190 // framebuffer, and the current window space viewport. During a draw, this
167 // stores the values for the current render pass; in between draws, they 191 // stores the values for the current render pass; in between draws, they
168 // retain the values for the root render pass of the last draw. 192 // retain the values for the root render pass of the last draw.
169 gfx::Rect current_draw_rect_; 193 gfx::Rect current_draw_rect_;
170 gfx::Rect current_viewport_rect_; 194 gfx::Rect current_viewport_rect_;
171 gfx::Size current_surface_size_; 195 gfx::Size current_surface_size_;
172 gfx::Rect current_window_space_viewport_; 196 gfx::Rect current_window_space_viewport_;
173 197
174 private: 198 private:
175 gfx::Size enlarge_pass_texture_amount_; 199 gfx::Size enlarge_pass_texture_amount_;
176 200
177 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); 201 DISALLOW_COPY_AND_ASSIGN(DirectRenderer);
178 }; 202 };
179 203
180 } // namespace cc 204 } // namespace cc
181 205
182 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ 206 #endif // CC_OUTPUT_DIRECT_RENDERER_H_
OLDNEW
« no previous file with comments | « cc/output/delegating_renderer.cc ('k') | cc/output/direct_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698