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 : root_render_pass(NULL), current_render_pass(NULL), current_texture(NULL) { |
62 current_render_pass(NULL), | 62 } |
63 current_texture(NULL), | |
64 offscreen_context_provider(NULL) {} | |
65 | 63 |
66 DirectRenderer::DrawingFrame::~DrawingFrame() {} | 64 DirectRenderer::DrawingFrame::~DrawingFrame() {} |
67 | 65 |
68 // | 66 // |
69 // static | 67 // static |
70 gfx::RectF DirectRenderer::QuadVertexRect() { | 68 gfx::RectF DirectRenderer::QuadVertexRect() { |
71 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 69 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
72 } | 70 } |
73 | 71 |
74 // static | 72 // static |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) { | 189 if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) { |
192 scoped_ptr<ScopedResource> texture = | 190 scoped_ptr<ScopedResource> texture = |
193 ScopedResource::Create(resource_provider_); | 191 ScopedResource::Create(resource_provider_); |
194 render_pass_textures_.set(render_passes_in_draw_order[i]->id, | 192 render_pass_textures_.set(render_passes_in_draw_order[i]->id, |
195 texture.Pass()); | 193 texture.Pass()); |
196 } | 194 } |
197 } | 195 } |
198 } | 196 } |
199 | 197 |
200 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, | 198 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, |
201 ContextProvider* offscreen_context_provider, | |
202 float device_scale_factor, | 199 float device_scale_factor, |
203 const gfx::Rect& device_viewport_rect, | 200 const gfx::Rect& device_viewport_rect, |
204 const gfx::Rect& device_clip_rect, | 201 const gfx::Rect& device_clip_rect, |
205 bool disable_picture_quad_image_filtering) { | 202 bool disable_picture_quad_image_filtering) { |
206 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); | 203 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); |
207 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount", | 204 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount", |
208 render_passes_in_draw_order->size()); | 205 render_passes_in_draw_order->size()); |
209 | 206 |
210 const RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 207 const RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
211 DCHECK(root_render_pass); | 208 DCHECK(root_render_pass); |
212 | 209 |
213 DrawingFrame frame; | 210 DrawingFrame frame; |
214 frame.root_render_pass = root_render_pass; | 211 frame.root_render_pass = root_render_pass; |
215 frame.root_damage_rect = Capabilities().using_partial_swap | 212 frame.root_damage_rect = Capabilities().using_partial_swap |
216 ? root_render_pass->damage_rect | 213 ? root_render_pass->damage_rect |
217 : root_render_pass->output_rect; | 214 : root_render_pass->output_rect; |
218 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); | 215 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); |
219 frame.device_viewport_rect = device_viewport_rect; | 216 frame.device_viewport_rect = device_viewport_rect; |
220 frame.device_clip_rect = device_clip_rect; | 217 frame.device_clip_rect = device_clip_rect; |
221 frame.offscreen_context_provider = offscreen_context_provider; | |
222 frame.disable_picture_quad_image_filtering = | 218 frame.disable_picture_quad_image_filtering = |
223 disable_picture_quad_image_filtering; | 219 disable_picture_quad_image_filtering; |
224 | 220 |
225 overlay_processor_->ProcessForOverlays(render_passes_in_draw_order, | 221 overlay_processor_->ProcessForOverlays(render_passes_in_draw_order, |
226 &frame.overlay_list); | 222 &frame.overlay_list); |
227 | 223 |
228 EnsureBackbuffer(); | 224 EnsureBackbuffer(); |
229 | 225 |
230 // Only reshape when we know we are going to draw. Otherwise, the reshape | 226 // Only reshape when we know we are going to draw. Otherwise, the reshape |
231 // can leave the window at the wrong size if we never draw and the proper | 227 // can leave the window at the wrong size if we never draw and the proper |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 ScopedResource* texture = render_pass_textures_.get(id); | 449 ScopedResource* texture = render_pass_textures_.get(id); |
454 return texture && texture->id(); | 450 return texture && texture->id(); |
455 } | 451 } |
456 | 452 |
457 // static | 453 // static |
458 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 454 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
459 return render_pass->output_rect.size(); | 455 return render_pass->output_rect.size(); |
460 } | 456 } |
461 | 457 |
462 } // namespace cc | 458 } // namespace cc |
OLD | NEW |