| 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 27 matching lines...) Expand all Loading... |
| 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 DirectRenderer(const RendererSettings* settings, | 43 DirectRenderer(const RendererSettings* settings, |
| 44 OutputSurface* output_surface, | 44 OutputSurface* output_surface, |
| 45 ResourceProvider* resource_provider); | 45 ResourceProvider* resource_provider); |
| 46 virtual ~DirectRenderer(); | 46 virtual ~DirectRenderer(); |
| 47 | 47 |
| 48 void Initialize(); |
| 49 |
| 50 bool use_partial_swap() const { return use_partial_swap_; } |
| 51 |
| 48 void SetVisible(bool visible); | 52 void SetVisible(bool visible); |
| 49 void DecideRenderPassAllocationsForFrame( | 53 void DecideRenderPassAllocationsForFrame( |
| 50 const RenderPassList& render_passes_in_draw_order); | 54 const RenderPassList& render_passes_in_draw_order); |
| 51 bool HasAllocatedResourcesForTesting(RenderPassId id) const; | 55 bool HasAllocatedResourcesForTesting(RenderPassId id) const; |
| 52 void DrawFrame(RenderPassList* render_passes_in_draw_order, | 56 void DrawFrame(RenderPassList* render_passes_in_draw_order, |
| 53 float device_scale_factor, | 57 float device_scale_factor, |
| 54 const gfx::ColorSpace& device_color_space, | 58 const gfx::ColorSpace& device_color_space, |
| 55 const gfx::Rect& device_viewport_rect, | 59 const gfx::Rect& device_viewport_rect, |
| 56 const gfx::Rect& device_clip_rect); | 60 const gfx::Rect& device_clip_rect); |
| 57 | 61 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 RenderPass* render_pass); | 137 RenderPass* render_pass); |
| 134 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 138 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 135 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 139 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
| 136 | 140 |
| 137 void DoDrawPolygon(const DrawPolygon& poly, | 141 void DoDrawPolygon(const DrawPolygon& poly, |
| 138 DrawingFrame* frame, | 142 DrawingFrame* frame, |
| 139 const gfx::Rect& render_pass_scissor, | 143 const gfx::Rect& render_pass_scissor, |
| 140 bool use_render_pass_scissor); | 144 bool use_render_pass_scissor); |
| 141 | 145 |
| 142 // Private interface implemented by subclasses for use by DirectRenderer. | 146 // Private interface implemented by subclasses for use by DirectRenderer. |
| 147 virtual bool CanPartialSwap() = 0; |
| 143 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; | 148 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; |
| 144 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 149 virtual bool BindFramebufferToTexture(DrawingFrame* frame, |
| 145 const ScopedResource* resource) = 0; | 150 const ScopedResource* resource) = 0; |
| 146 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; | 151 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0; |
| 147 virtual void PrepareSurfaceForPass( | 152 virtual void PrepareSurfaceForPass( |
| 148 DrawingFrame* frame, | 153 DrawingFrame* frame, |
| 149 SurfaceInitializationMode initialization_mode, | 154 SurfaceInitializationMode initialization_mode, |
| 150 const gfx::Rect& render_pass_scissor) = 0; | 155 const gfx::Rect& render_pass_scissor) = 0; |
| 151 // |clip_region| is a (possibly null) pointer to a quad in the same | 156 // |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 | 157 // 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( | 173 virtual void CopyCurrentRenderPassToBitmap( |
| 169 DrawingFrame* frame, | 174 DrawingFrame* frame, |
| 170 std::unique_ptr<CopyOutputRequest> request) = 0; | 175 std::unique_ptr<CopyOutputRequest> request) = 0; |
| 171 | 176 |
| 172 const RendererSettings* const settings_; | 177 const RendererSettings* const settings_; |
| 173 OutputSurface* const output_surface_; | 178 OutputSurface* const output_surface_; |
| 174 ResourceProvider* const resource_provider_; | 179 ResourceProvider* const resource_provider_; |
| 175 // This can be replaced by test implementations. | 180 // This can be replaced by test implementations. |
| 176 std::unique_ptr<OverlayProcessor> overlay_processor_; | 181 std::unique_ptr<OverlayProcessor> overlay_processor_; |
| 177 | 182 |
| 183 // Whether it's valid to SwapBuffers with an empty rect. Trivially true when |
| 184 // using partial swap. |
| 185 bool allow_empty_swap_; |
| 186 // Whether partial swap can be used. |
| 187 bool use_partial_swap_; |
| 188 |
| 178 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. | 189 // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. |
| 179 std::unordered_map<RenderPassId, | 190 std::unordered_map<RenderPassId, |
| 180 std::unique_ptr<ScopedResource>, | 191 std::unique_ptr<ScopedResource>, |
| 181 RenderPassIdHash> | 192 RenderPassIdHash> |
| 182 render_pass_textures_; | 193 render_pass_textures_; |
| 183 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> | 194 std::unordered_map<RenderPassId, TileDrawQuad, RenderPassIdHash> |
| 184 render_pass_bypass_quads_; | 195 render_pass_bypass_quads_; |
| 185 | 196 |
| 186 bool visible_; | 197 bool visible_; |
| 187 | 198 |
| 188 // For use in coordinate conversion, this stores the output rect, viewport | 199 // For use in coordinate conversion, this stores the output rect, viewport |
| 189 // rect (= unflipped version of glViewport rect), the size of target | 200 // rect (= unflipped version of glViewport rect), the size of target |
| 190 // framebuffer, and the current window space viewport. During a draw, this | 201 // framebuffer, and the current window space viewport. During a draw, this |
| 191 // stores the values for the current render pass; in between draws, they | 202 // 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. | 203 // retain the values for the root render pass of the last draw. |
| 193 gfx::Rect current_draw_rect_; | 204 gfx::Rect current_draw_rect_; |
| 194 gfx::Rect current_viewport_rect_; | 205 gfx::Rect current_viewport_rect_; |
| 195 gfx::Size current_surface_size_; | 206 gfx::Size current_surface_size_; |
| 196 gfx::Rect current_window_space_viewport_; | 207 gfx::Rect current_window_space_viewport_; |
| 197 | 208 |
| 198 private: | 209 private: |
| 210 bool initialized_ = false; |
| 199 gfx::Size enlarge_pass_texture_amount_; | 211 gfx::Size enlarge_pass_texture_amount_; |
| 200 | 212 |
| 201 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 213 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
| 202 }; | 214 }; |
| 203 | 215 |
| 204 } // namespace cc | 216 } // namespace cc |
| 205 | 217 |
| 206 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 218 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
| OLD | NEW |