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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 *quad_rect_transform = quad_transform; | 75 *quad_rect_transform = quad_transform; |
76 quad_rect_transform->Translate(0.5 * quad_rect.width() + quad_rect.x(), | 76 quad_rect_transform->Translate(0.5 * quad_rect.width() + quad_rect.x(), |
77 0.5 * quad_rect.height() + quad_rect.y()); | 77 0.5 * quad_rect.height() + quad_rect.y()); |
78 quad_rect_transform->Scale(quad_rect.width(), quad_rect.height()); | 78 quad_rect_transform->Scale(quad_rect.width(), quad_rect.height()); |
79 } | 79 } |
80 | 80 |
81 void DirectRenderer::InitializeViewport(DrawingFrame* frame, | 81 void DirectRenderer::InitializeViewport(DrawingFrame* frame, |
82 const gfx::Rect& draw_rect, | 82 const gfx::Rect& draw_rect, |
83 const gfx::Rect& viewport_rect, | 83 const gfx::Rect& viewport_rect, |
84 const gfx::Size& surface_size) { | 84 const gfx::Size& surface_size) { |
85 bool flip_y = FlippedFramebuffer(); | |
86 | |
87 DCHECK_GE(viewport_rect.x(), 0); | 85 DCHECK_GE(viewport_rect.x(), 0); |
88 DCHECK_GE(viewport_rect.y(), 0); | 86 DCHECK_GE(viewport_rect.y(), 0); |
89 DCHECK_LE(viewport_rect.right(), surface_size.width()); | 87 DCHECK_LE(viewport_rect.right(), surface_size.width()); |
90 DCHECK_LE(viewport_rect.bottom(), surface_size.height()); | 88 DCHECK_LE(viewport_rect.bottom(), surface_size.height()); |
| 89 bool flip_y = FlippedFramebuffer(frame); |
91 if (flip_y) { | 90 if (flip_y) { |
92 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), | 91 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), |
93 draw_rect.right(), | 92 draw_rect.right(), |
94 draw_rect.bottom(), | 93 draw_rect.bottom(), |
95 draw_rect.y()); | 94 draw_rect.y()); |
96 } else { | 95 } else { |
97 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), | 96 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), |
98 draw_rect.right(), | 97 draw_rect.right(), |
99 draw_rect.y(), | 98 draw_rect.y(), |
100 draw_rect.bottom()); | 99 draw_rect.bottom()); |
101 } | 100 } |
102 | 101 |
103 gfx::Rect window_rect = viewport_rect; | 102 gfx::Rect window_rect = viewport_rect; |
104 if (flip_y) | 103 if (flip_y) |
105 window_rect.set_y(surface_size.height() - viewport_rect.bottom()); | 104 window_rect.set_y(surface_size.height() - viewport_rect.bottom()); |
106 frame->window_matrix = window_matrix(window_rect.x(), | 105 frame->window_matrix = window_matrix(window_rect.x(), |
107 window_rect.y(), | 106 window_rect.y(), |
108 window_rect.width(), | 107 window_rect.width(), |
109 window_rect.height()); | 108 window_rect.height()); |
110 SetDrawViewport(window_rect); | 109 SetDrawViewport(window_rect); |
111 | 110 |
112 current_draw_rect_ = draw_rect; | 111 current_draw_rect_ = draw_rect; |
113 current_viewport_rect_ = viewport_rect; | 112 current_viewport_rect_ = viewport_rect; |
114 current_surface_size_ = surface_size; | 113 current_surface_size_ = surface_size; |
115 } | 114 } |
116 | 115 |
117 gfx::Rect DirectRenderer::MoveFromDrawToWindowSpace( | 116 gfx::Rect DirectRenderer::MoveFromDrawToWindowSpace( |
| 117 const DrawingFrame* frame, |
118 const gfx::Rect& draw_rect) const { | 118 const gfx::Rect& draw_rect) const { |
119 gfx::Rect window_rect = draw_rect; | 119 gfx::Rect window_rect = draw_rect; |
120 window_rect -= current_draw_rect_.OffsetFromOrigin(); | 120 window_rect -= current_draw_rect_.OffsetFromOrigin(); |
121 window_rect += current_viewport_rect_.OffsetFromOrigin(); | 121 window_rect += current_viewport_rect_.OffsetFromOrigin(); |
122 if (FlippedFramebuffer()) | 122 if (FlippedFramebuffer(frame)) |
123 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); | 123 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); |
124 return window_rect; | 124 return window_rect; |
125 } | 125 } |
126 | 126 |
127 DirectRenderer::DirectRenderer(RendererClient* client, | 127 DirectRenderer::DirectRenderer(RendererClient* client, |
128 const LayerTreeSettings* settings, | 128 const LayerTreeSettings* settings, |
129 OutputSurface* output_surface, | 129 OutputSurface* output_surface, |
130 ResourceProvider* resource_provider) | 130 ResourceProvider* resource_provider) |
131 : Renderer(client, settings), | 131 : Renderer(client, settings), |
132 output_surface_(output_surface), | 132 output_surface_(output_surface), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 bool DirectRenderer::NeedDeviceClip(const DrawingFrame* frame) const { | 272 bool DirectRenderer::NeedDeviceClip(const DrawingFrame* frame) const { |
273 if (frame->current_render_pass != frame->root_render_pass) | 273 if (frame->current_render_pass != frame->root_render_pass) |
274 return false; | 274 return false; |
275 | 275 |
276 return !frame->device_clip_rect.Contains(frame->device_viewport_rect); | 276 return !frame->device_clip_rect.Contains(frame->device_viewport_rect); |
277 } | 277 } |
278 | 278 |
279 gfx::Rect DirectRenderer::DeviceClipRectInWindowSpace(const DrawingFrame* frame) | 279 gfx::Rect DirectRenderer::DeviceClipRectInWindowSpace(const DrawingFrame* frame) |
280 const { | 280 const { |
281 gfx::Rect device_clip_rect = frame->device_clip_rect; | 281 gfx::Rect device_clip_rect = frame->device_clip_rect; |
282 if (FlippedFramebuffer()) | 282 if (FlippedFramebuffer(frame)) |
283 device_clip_rect.set_y(current_surface_size_.height() - | 283 device_clip_rect.set_y(current_surface_size_.height() - |
284 device_clip_rect.bottom()); | 284 device_clip_rect.bottom()); |
285 return device_clip_rect; | 285 return device_clip_rect; |
286 } | 286 } |
287 | 287 |
288 void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame, | 288 void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame, |
289 const DrawQuad& quad) { | 289 const DrawQuad& quad) { |
290 if (quad.isClipped()) { | 290 if (quad.isClipped()) { |
291 SetScissorTestRectInDrawSpace(frame, quad.clipRect()); | 291 SetScissorTestRectInDrawSpace(frame, quad.clipRect()); |
292 return; | 292 return; |
(...skipping 21 matching lines...) Expand all Loading... |
314 return; | 314 return; |
315 } | 315 } |
316 | 316 |
317 *should_skip_quad = false; | 317 *should_skip_quad = false; |
318 SetScissorTestRectInDrawSpace(frame, quad_scissor_rect); | 318 SetScissorTestRectInDrawSpace(frame, quad_scissor_rect); |
319 } | 319 } |
320 | 320 |
321 void DirectRenderer::SetScissorTestRectInDrawSpace( | 321 void DirectRenderer::SetScissorTestRectInDrawSpace( |
322 const DrawingFrame* frame, | 322 const DrawingFrame* frame, |
323 const gfx::Rect& draw_space_rect) { | 323 const gfx::Rect& draw_space_rect) { |
324 gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect); | 324 gfx::Rect window_space_rect = |
| 325 MoveFromDrawToWindowSpace(frame, draw_space_rect); |
325 if (NeedDeviceClip(frame)) | 326 if (NeedDeviceClip(frame)) |
326 window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame)); | 327 window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame)); |
327 SetScissorTestRect(window_space_rect); | 328 SetScissorTestRect(window_space_rect); |
328 } | 329 } |
329 | 330 |
330 void DirectRenderer::FinishDrawingQuadList() {} | 331 void DirectRenderer::FinishDrawingQuadList() {} |
331 | 332 |
332 void DirectRenderer::DrawRenderPass(DrawingFrame* frame, | 333 void DirectRenderer::DrawRenderPass(DrawingFrame* frame, |
333 const RenderPass* render_pass) { | 334 const RenderPass* render_pass) { |
334 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass"); | 335 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 ScopedResource* texture = render_pass_textures_.get(id); | 420 ScopedResource* texture = render_pass_textures_.get(id); |
420 return texture && texture->id(); | 421 return texture && texture->id(); |
421 } | 422 } |
422 | 423 |
423 // static | 424 // static |
424 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 425 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
425 return render_pass->output_rect.size(); | 426 return render_pass->output_rect.size(); |
426 } | 427 } |
427 | 428 |
428 } // namespace cc | 429 } // namespace cc |
OLD | NEW |