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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const gfx::Transform& quad_transform, | 73 const gfx::Transform& quad_transform, |
74 const gfx::RectF& quad_rect) { | 74 const gfx::RectF& quad_rect) { |
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 // static | 81 // static |
82 void DirectRenderer::InitializeMatrices(DrawingFrame* frame, | 82 void DirectRenderer::InitializeMatrices(DrawingFrame* frame, |
| 83 gfx::Vector2d offset, |
83 gfx::Rect draw_rect, | 84 gfx::Rect draw_rect, |
84 bool flip_y) { | 85 bool flip_y) { |
85 if (flip_y) { | 86 if (flip_y) { |
86 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), | 87 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), |
87 draw_rect.right(), | 88 draw_rect.right(), |
88 draw_rect.bottom(), | 89 draw_rect.bottom(), |
89 draw_rect.y()); | 90 draw_rect.y()); |
90 } else { | 91 } else { |
91 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), | 92 frame->projection_matrix = OrthoProjectionMatrix(draw_rect.x(), |
92 draw_rect.right(), | 93 draw_rect.right(), |
93 draw_rect.y(), | 94 draw_rect.y(), |
94 draw_rect.bottom()); | 95 draw_rect.bottom()); |
95 } | 96 } |
96 frame->window_matrix = | 97 |
97 window_matrix(0, 0, draw_rect.width(), draw_rect.height()); | 98 frame->window_matrix = window_matrix( |
| 99 offset.x(), offset.y(), draw_rect.width(), draw_rect.height()); |
98 frame->flipped_y = flip_y; | 100 frame->flipped_y = flip_y; |
99 } | 101 } |
100 | 102 |
101 // static | |
102 gfx::Rect DirectRenderer::MoveScissorToWindowSpace( | 103 gfx::Rect DirectRenderer::MoveScissorToWindowSpace( |
103 const DrawingFrame* frame, const gfx::RectF& scissor_rect) { | 104 const DrawingFrame* frame, const gfx::RectF& scissor_rect) { |
104 gfx::Rect scissor_rect_in_canvas_space = gfx::ToEnclosingRect(scissor_rect); | 105 gfx::Rect scissor_rect_in_canvas_space = gfx::ToEnclosingRect(scissor_rect); |
105 // The scissor coordinates must be supplied in viewport space so we need to | 106 // The scissor coordinates must be supplied in viewport space so we need to |
106 // offset by the relative position of the top left corner of the current | 107 // offset by the relative position of the top left corner of the current |
107 // render pass. | 108 // render pass. |
108 gfx::Rect framebuffer_output_rect = frame->current_render_pass->output_rect; | 109 gfx::Rect framebuffer_output_rect = frame->current_render_pass->output_rect; |
109 scissor_rect_in_canvas_space.set_x( | 110 scissor_rect_in_canvas_space.set_x( |
110 scissor_rect_in_canvas_space.x() - framebuffer_output_rect.x()); | 111 scissor_rect_in_canvas_space.x() - framebuffer_output_rect.x()); |
111 if (frame->flipped_y && !frame->current_texture) { | 112 if (frame->flipped_y && !frame->current_texture) { |
112 scissor_rect_in_canvas_space.set_y( | 113 scissor_rect_in_canvas_space.set_y( |
113 framebuffer_output_rect.height() - | 114 framebuffer_output_rect.height() - |
114 (scissor_rect_in_canvas_space.bottom() - framebuffer_output_rect.y())); | 115 (scissor_rect_in_canvas_space.bottom() - framebuffer_output_rect.y())); |
115 } else { | 116 } else { |
116 scissor_rect_in_canvas_space.set_y( | 117 scissor_rect_in_canvas_space.set_y( |
117 scissor_rect_in_canvas_space.y() - framebuffer_output_rect.y()); | 118 scissor_rect_in_canvas_space.y() - framebuffer_output_rect.y()); |
118 } | 119 } |
| 120 if (!frame->current_texture) |
| 121 scissor_rect_in_canvas_space.Offset(client_->DeviceViewportOffset()); |
119 return scissor_rect_in_canvas_space; | 122 return scissor_rect_in_canvas_space; |
120 } | 123 } |
121 | 124 |
122 DirectRenderer::DirectRenderer(RendererClient* client, | 125 DirectRenderer::DirectRenderer(RendererClient* client, |
123 ResourceProvider* resource_provider) | 126 ResourceProvider* resource_provider) |
124 : Renderer(client), | 127 : Renderer(client), |
125 resource_provider_(resource_provider) {} | 128 resource_provider_(resource_provider) {} |
126 | 129 |
127 DirectRenderer::~DirectRenderer() {} | 130 DirectRenderer::~DirectRenderer() {} |
128 | 131 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 319 } |
317 } | 320 } |
318 | 321 |
319 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, | 322 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, |
320 const RenderPass* render_pass) { | 323 const RenderPass* render_pass) { |
321 frame->current_render_pass = render_pass; | 324 frame->current_render_pass = render_pass; |
322 frame->current_texture = NULL; | 325 frame->current_texture = NULL; |
323 | 326 |
324 if (render_pass == frame->root_render_pass) { | 327 if (render_pass == frame->root_render_pass) { |
325 BindFramebufferToOutputSurface(frame); | 328 BindFramebufferToOutputSurface(frame); |
326 InitializeMatrices(frame, render_pass->output_rect, FlippedFramebuffer()); | 329 InitializeMatrices(frame, |
| 330 client_->DeviceViewportOffset(), |
| 331 render_pass->output_rect, |
| 332 FlippedFramebuffer()); |
327 SetDrawViewportSize(render_pass->output_rect.size()); | 333 SetDrawViewportSize(render_pass->output_rect.size()); |
328 return true; | 334 return true; |
329 } | 335 } |
330 | 336 |
331 if (!resource_provider_) | 337 if (!resource_provider_) |
332 return false; | 338 return false; |
333 | 339 |
334 CachedResource* texture = render_pass_textures_.get(render_pass->id); | 340 CachedResource* texture = render_pass_textures_.get(render_pass->id); |
335 DCHECK(texture); | 341 DCHECK(texture); |
336 | 342 |
(...skipping 22 matching lines...) Expand all Loading... |
359 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 365 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
360 return render_pass->output_rect.size(); | 366 return render_pass->output_rect.size(); |
361 } | 367 } |
362 | 368 |
363 // static | 369 // static |
364 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { | 370 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { |
365 return GL_RGBA; | 371 return GL_RGBA; |
366 } | 372 } |
367 | 373 |
368 } // namespace cc | 374 } // namespace cc |
OLD | NEW |