Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 class RendererSettings; | 33 class RendererSettings; |
| 34 class ResourceProvider; | 34 class ResourceProvider; |
| 35 class ScopedResource; | 35 class ScopedResource; |
| 36 | 36 |
| 37 // 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 |
| 38 // renderer implementations. "Direct" refers to the fact that it does not | 38 // renderer implementations. "Direct" refers to the fact that it does not |
| 39 // delegate rendering to another compositor (see historical DelegatingRenderer | 39 // delegate rendering to another compositor (see historical DelegatingRenderer |
| 40 // for reference). | 40 // for reference). |
| 41 class CC_EXPORT DirectRenderer { | 41 class CC_EXPORT DirectRenderer { |
| 42 public: | 42 public: |
| 43 struct Capabilities { | |
|
enne (OOO)
2016/08/17 17:48:42
Where does this get used?
danakj
2016/08/17 18:16:41
I think I was going to do this but then I didn't s
| |
| 44 bool using_partial_swap = false; | |
| 45 }; | |
| 46 | |
| 43 DirectRenderer(const RendererSettings* settings, | 47 DirectRenderer(const RendererSettings* settings, |
| 44 OutputSurface* output_surface, | 48 OutputSurface* output_surface, |
| 45 ResourceProvider* resource_provider); | 49 ResourceProvider* resource_provider); |
| 46 virtual ~DirectRenderer(); | 50 virtual ~DirectRenderer(); |
| 47 | 51 |
| 52 void Initialize(); | |
| 53 | |
| 54 bool use_partial_swap() const { return use_partial_swap_; } | |
| 55 | |
| 48 void SetVisible(bool visible); | 56 void SetVisible(bool visible); |
| 49 void DecideRenderPassAllocationsForFrame( | 57 void DecideRenderPassAllocationsForFrame( |
| 50 const RenderPassList& render_passes_in_draw_order); | 58 const RenderPassList& render_passes_in_draw_order); |
| 51 bool HasAllocatedResourcesForTesting(RenderPassId id) const; | 59 bool HasAllocatedResourcesForTesting(RenderPassId id) const; |
| 52 void DrawFrame(RenderPassList* render_passes_in_draw_order, | 60 void DrawFrame(RenderPassList* render_passes_in_draw_order, |
| 53 float device_scale_factor, | 61 float device_scale_factor, |
| 54 const gfx::ColorSpace& device_color_space, | 62 const gfx::ColorSpace& device_color_space, |
| 55 const gfx::Rect& device_viewport_rect, | 63 const gfx::Rect& device_viewport_rect, |
| 56 const gfx::Rect& device_clip_rect); | 64 const gfx::Rect& device_clip_rect); |
| 57 | 65 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 RenderPass* render_pass); | 141 RenderPass* render_pass); |
| 134 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 142 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 135 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 143 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 136 | 144 |
| 137 void DoDrawPolygon(const DrawPolygon& poly, | 145 void DoDrawPolygon(const DrawPolygon& poly, |
| 138 DrawingFrame* frame, | 146 DrawingFrame* frame, |
| 139 const gfx::Rect& render_pass_scissor, | 147 const gfx::Rect& render_pass_scissor, |
| 140 bool use_render_pass_scissor); | 148 bool use_render_pass_scissor); |
| 141 | 149 |
| 142 // Private interface implemented by subclasses for use by DirectRenderer. | 150 // Private interface implemented by subclasses for use by DirectRenderer. |
| 151 virtual bool CanPartialSwap() = 0; | |
| 143 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; | 152 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; |
| 144 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 153 virtual bool BindFramebufferToTexture(DrawingFrame* frame, |
| 145 const ScopedResource* resource) = 0; | 154 const ScopedResource* resource) = 0; |
| 146 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; | 155 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; |
| 147 virtual void PrepareSurfaceForPass( | 156 virtual void PrepareSurfaceForPass( |
| 148 DrawingFrame* frame, | 157 DrawingFrame* frame, |
| 149 SurfaceInitializationMode initialization_mode, | 158 SurfaceInitializationMode initialization_mode, |
| 150 const gfx::Rect& render_pass_scissor) = 0; | 159 const gfx::Rect& render_pass_scissor) = 0; |
| 151 // |clip_region| is a (possibly null) pointer to a quad in the same | 160 // |clip_region| is a (possibly null) pointer to a quad in the same |
| 152 // space as the quad. When non-null only the area of the quad that overlaps | 161 // space as the quad. When non-null only the area of the quad that overlaps |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 168 virtual void CopyCurrentRenderPassToBitmap( | 177 virtual void CopyCurrentRenderPassToBitmap( |
| 169 DrawingFrame* frame, | 178 DrawingFrame* frame, |
| 170 std::unique_ptr<CopyOutputRequest> request) = 0; | 179 std::unique_ptr<CopyOutputRequest> request) = 0; |
| 171 | 180 |
| 172 const RendererSettings* const settings_; | 181 const RendererSettings* const settings_; |
| 173 OutputSurface* const output_surface_; | 182 OutputSurface* const output_surface_; |
| 174 ResourceProvider* const resource_provider_; | 183 ResourceProvider* const resource_provider_; |
| 175 // This can be replaced by test implementations. | 184 // This can be replaced by test implementations. |
| 176 std::unique_ptr<OverlayProcessor> overlay_processor_; | 185 std::unique_ptr<OverlayProcessor> overlay_processor_; |
| 177 | 186 |
| 187 // Whether it's valid to SwapBuffers with an empty rect. Trivially true when | |
| 188 // using partial swap. | |
| 189 bool allow_empty_swap_; | |
| 190 // Whether partial swap can be used. | |
| 191 bool use_partial_swap_; | |
| 192 | |
| 178 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. | 193 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. |
| 179 std::unordered_map<RenderPassId, | 194 std::unordered_map<RenderPassId, |
| 180 std::unique_ptr<ScopedResource>, | 195 std::unique_ptr<ScopedResource>, |
| 181 RenderPassIdHash> | 196 RenderPassIdHash> |
| 182 render_pass_textures_; | 197 render_pass_textures_; |
| 183 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> | 198 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> |
| 184 render_pass_bypass_quads_; | 199 render_pass_bypass_quads_; |
| 185 | 200 |
| 186 bool visible_; | 201 bool visible_; |
| 187 | 202 |
| 188 // For use in coordinate conversion, this stores the output rect, viewport | 203 // For use in coordinate conversion, this stores the output rect, viewport |
| 189 // rect (= unflipped version of glViewport rect), the size of target | 204 // rect (= unflipped version of glViewport rect), the size of target |
| 190 // framebuffer, and the current window space viewport. During a draw, this | 205 // framebuffer, and the current window space viewport. During a draw, this |
| 191 // stores the values for the current render pass; in between draws, they | 206 // stores the values for the current render pass; in between draws, they |
| 192 // retain the values for the root render pass of the last draw. | 207 // retain the values for the root render pass of the last draw. |
| 193 gfx::Rect current_draw_rect_; | 208 gfx::Rect current_draw_rect_; |
| 194 gfx::Rect current_viewport_rect_; | 209 gfx::Rect current_viewport_rect_; |
| 195 gfx::Size current_surface_size_; | 210 gfx::Size current_surface_size_; |
| 196 gfx::Rect current_window_space_viewport_; | 211 gfx::Rect current_window_space_viewport_; |
| 197 | 212 |
| 198 private: | 213 private: |
| 199 gfx::Size enlarge_pass_texture_amount_; | 214 gfx::Size enlarge_pass_texture_amount_; |
| 200 | 215 |
| 201 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 216 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
| 202 }; | 217 }; |
| 203 | 218 |
| 204 } // namespace cc | 219 } // namespace cc |
| 205 | 220 |
| 206 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 221 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
| OLD | NEW |