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 #include "cc/output/direct_renderer.h" | 5 #include "cc/output/direct_renderer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 // Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1]) | 51 // Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1]) |
| 52 canvas.Translate3d(0.5, 0.5, 0.5); | 52 canvas.Translate3d(0.5, 0.5, 0.5); |
| 53 canvas.Scale3d(0.5, 0.5, 0.5); | 53 canvas.Scale3d(0.5, 0.5, 0.5); |
| 54 | 54 |
| 55 return canvas; | 55 return canvas; |
| 56 } | 56 } |
| 57 | 57 |
| 58 namespace cc { | 58 namespace cc { |
| 59 | 59 |
| 60 DirectRenderer::DrawingFrame::DrawingFrame() | 60 DirectRenderer::DrawingFrame::DrawingFrame() |
| 61 : root_render_pass(NULL), | 61 : render_passes_in_draw_order(NULL), |
| 62 root_render_pass(NULL), | |
| 62 current_render_pass(NULL), | 63 current_render_pass(NULL), |
| 63 current_texture(NULL), | 64 current_texture(NULL), |
| 64 offscreen_context_provider(NULL) {} | 65 offscreen_context_provider(NULL) {} |
| 65 | 66 |
| 66 DirectRenderer::DrawingFrame::~DrawingFrame() {} | 67 DirectRenderer::DrawingFrame::~DrawingFrame() {} |
| 67 | 68 |
| 68 // | 69 // |
| 69 // static | 70 // static |
| 70 gfx::RectF DirectRenderer::QuadVertexRect() { | 71 gfx::RectF DirectRenderer::QuadVertexRect() { |
| 71 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 72 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); | 127 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); |
| 127 return window_rect; | 128 return window_rect; |
| 128 } | 129 } |
| 129 | 130 |
| 130 DirectRenderer::DirectRenderer(RendererClient* client, | 131 DirectRenderer::DirectRenderer(RendererClient* client, |
| 131 const LayerTreeSettings* settings, | 132 const LayerTreeSettings* settings, |
| 132 OutputSurface* output_surface, | 133 OutputSurface* output_surface, |
| 133 ResourceProvider* resource_provider) | 134 ResourceProvider* resource_provider) |
| 134 : Renderer(client, settings), | 135 : Renderer(client, settings), |
| 135 output_surface_(output_surface), | 136 output_surface_(output_surface), |
| 136 resource_provider_(resource_provider) {} | 137 resource_provider_(resource_provider), |
| 138 overlay_processor_( | |
| 139 new OverlayProcessor(output_surface, resource_provider)) { | |
| 140 overlay_processor_->Initialize(); | |
| 141 } | |
| 137 | 142 |
| 138 DirectRenderer::~DirectRenderer() {} | 143 DirectRenderer::~DirectRenderer() {} |
| 139 | 144 |
| 140 bool DirectRenderer::CanReadPixels() const { return true; } | 145 bool DirectRenderer::CanReadPixels() const { return true; } |
| 141 | 146 |
| 142 void DirectRenderer::SetEnlargePassTextureAmountForTesting( | 147 void DirectRenderer::SetEnlargePassTextureAmountForTesting( |
| 143 const gfx::Vector2d& amount) { | 148 const gfx::Vector2d& amount) { |
| 144 enlarge_pass_texture_amount_ = amount; | 149 enlarge_pass_texture_amount_ = amount; |
| 145 } | 150 } |
| 146 | 151 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 frame.root_damage_rect = Capabilities().using_partial_swap | 216 frame.root_damage_rect = Capabilities().using_partial_swap |
| 212 ? root_render_pass->damage_rect | 217 ? root_render_pass->damage_rect |
| 213 : root_render_pass->output_rect; | 218 : root_render_pass->output_rect; |
| 214 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); | 219 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); |
| 215 frame.device_viewport_rect = device_viewport_rect; | 220 frame.device_viewport_rect = device_viewport_rect; |
| 216 frame.device_clip_rect = device_clip_rect; | 221 frame.device_clip_rect = device_clip_rect; |
| 217 frame.offscreen_context_provider = offscreen_context_provider; | 222 frame.offscreen_context_provider = offscreen_context_provider; |
| 218 frame.disable_picture_quad_image_filtering = | 223 frame.disable_picture_quad_image_filtering = |
| 219 disable_picture_quad_image_filtering; | 224 disable_picture_quad_image_filtering; |
| 220 | 225 |
| 226 if (overlay_processor_->ProcessForOverlays(render_passes_in_draw_order)) | |
| 227 frame.render_passes_in_draw_order = render_passes_in_draw_order; | |
|
enne (OOO)
2014/03/21 18:15:49
This variable is a little awkward. It says render
enne (OOO)
2014/03/21 18:16:08
(Er, sorry, I see that it's not just used as a boo
alexst (slow to review)
2014/03/21 18:37:41
It's not useful unless overlays are present, so it
piman
2014/03/21 21:45:12
Do you have a CL that shows how it will be used? Y
alexst (slow to review)
2014/03/24 12:46:45
I'll add more code so this makes more sense. I was
| |
| 228 | |
| 221 EnsureBackbuffer(); | 229 EnsureBackbuffer(); |
| 222 | 230 |
| 223 // Only reshape when we know we are going to draw. Otherwise, the reshape | 231 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 224 // can leave the window at the wrong size if we never draw and the proper | 232 // can leave the window at the wrong size if we never draw and the proper |
| 225 // viewport size is never set. | 233 // viewport size is never set. |
| 226 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); | 234 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); |
| 227 | 235 |
| 228 BeginDrawingFrame(&frame); | 236 BeginDrawingFrame(&frame); |
| 229 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { | 237 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { |
| 230 RenderPass* pass = render_passes_in_draw_order->at(i); | 238 RenderPass* pass = render_passes_in_draw_order->at(i); |
| 239 if (pass->overlay_state == RenderPass::SIMPLE_OVERLAY) | |
| 240 continue; | |
| 241 | |
| 231 DrawRenderPass(&frame, pass); | 242 DrawRenderPass(&frame, pass); |
| 232 | 243 |
| 233 for (ScopedPtrVector<CopyOutputRequest>::iterator it = | 244 for (ScopedPtrVector<CopyOutputRequest>::iterator it = |
| 234 pass->copy_requests.begin(); | 245 pass->copy_requests.begin(); |
| 235 it != pass->copy_requests.end(); | 246 it != pass->copy_requests.end(); |
| 236 ++it) { | 247 ++it) { |
| 237 if (i > 0) { | 248 if (i > 0) { |
| 238 // Doing a readback is destructive of our state on Mac, so make sure | 249 // Doing a readback is destructive of our state on Mac, so make sure |
| 239 // we restore the state between readbacks. http://crbug.com/99393. | 250 // we restore the state between readbacks. http://crbug.com/99393. |
| 240 UseRenderPass(&frame, pass); | 251 UseRenderPass(&frame, pass); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 ScopedResource* texture = render_pass_textures_.get(id); | 459 ScopedResource* texture = render_pass_textures_.get(id); |
| 449 return texture && texture->id(); | 460 return texture && texture->id(); |
| 450 } | 461 } |
| 451 | 462 |
| 452 // static | 463 // static |
| 453 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 464 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 454 return render_pass->output_rect.size(); | 465 return render_pass->output_rect.size(); |
| 455 } | 466 } |
| 456 | 467 |
| 457 } // namespace cc | 468 } // namespace cc |
| OLD | NEW |