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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
| 14 #include "cc/output/copy_output_request.h" |
14 #include "cc/quads/draw_quad.h" | 15 #include "cc/quads/draw_quad.h" |
15 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
16 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
17 | 18 |
18 static gfx::Transform OrthoProjectionMatrix(float left, | 19 static gfx::Transform OrthoProjectionMatrix(float left, |
19 float right, | 20 float right, |
20 float bottom, | 21 float bottom, |
21 float top) { | 22 float top) { |
22 // Use the standard formula to map the clipping frustum to the cube from | 23 // Use the standard formula to map the clipping frustum to the cube from |
23 // [-1, -1, -1] to [1, 1, 1]. | 24 // [-1, -1, -1] to [1, 1, 1]. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 DrawingFrame frame; | 195 DrawingFrame frame; |
195 frame.root_render_pass = root_render_pass; | 196 frame.root_render_pass = root_render_pass; |
196 frame.root_damage_rect = | 197 frame.root_damage_rect = |
197 Capabilities().using_partial_swap && client_->AllowPartialSwap() ? | 198 Capabilities().using_partial_swap && client_->AllowPartialSwap() ? |
198 root_render_pass->damage_rect : root_render_pass->output_rect; | 199 root_render_pass->damage_rect : root_render_pass->output_rect; |
199 frame.root_damage_rect.Intersect(gfx::Rect(ViewportSize())); | 200 frame.root_damage_rect.Intersect(gfx::Rect(ViewportSize())); |
200 | 201 |
201 BeginDrawingFrame(&frame); | 202 BeginDrawingFrame(&frame); |
202 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { | 203 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { |
203 DrawRenderPass(&frame, render_passes_in_draw_order->at(i)); | 204 RenderPass* pass = render_passes_in_draw_order->at(i); |
| 205 DrawRenderPass(&frame, pass); |
204 | 206 |
205 const RenderPass* pass = frame.current_render_pass; | 207 for (ScopedPtrVector<CopyOutputRequest>::iterator it = |
206 for (size_t i = 0; i < pass->copy_callbacks.size(); ++i) { | 208 pass->copy_requests.begin(); |
| 209 it != pass->copy_requests.end(); |
| 210 ++it) { |
207 if (i > 0) { | 211 if (i > 0) { |
208 // Doing a readback is destructive of our state on Mac, so make sure | 212 // Doing a readback is destructive of our state on Mac, so make sure |
209 // we restore the state between readbacks. http://crbug.com/99393. | 213 // we restore the state between readbacks. http://crbug.com/99393. |
210 UseRenderPass(&frame, pass); | 214 UseRenderPass(&frame, pass); |
211 } | 215 } |
212 CopyCurrentRenderPassToBitmap(&frame, pass->copy_callbacks[i]); | 216 CopyCurrentRenderPassToBitmap(&frame, pass->copy_requests.take(it)); |
213 } | 217 } |
214 } | 218 } |
215 FinishDrawingFrame(&frame); | 219 FinishDrawingFrame(&frame); |
216 | 220 |
217 render_passes_in_draw_order->clear(); | 221 render_passes_in_draw_order->clear(); |
218 } | 222 } |
219 | 223 |
220 gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass( | 224 gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass( |
221 const DrawingFrame* frame) { | 225 const DrawingFrame* frame) { |
222 gfx::RectF render_pass_scissor = frame->current_render_pass->output_rect; | 226 gfx::RectF render_pass_scissor = frame->current_render_pass->output_rect; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 363 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
360 return render_pass->output_rect.size(); | 364 return render_pass->output_rect.size(); |
361 } | 365 } |
362 | 366 |
363 // static | 367 // static |
364 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { | 368 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { |
365 return GL_RGBA; | 369 return GL_RGBA; |
366 } | 370 } |
367 | 371 |
368 } // namespace cc | 372 } // namespace cc |
OLD | NEW |