Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: cc/direct_renderer.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/direct_renderer.h" 5 #include "cc/direct_renderer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/math_util.h" 10 #include "cc/math_util.h"
11 #include "ui/gfx/rect_conversions.h" 11 #include "ui/gfx/rect_conversions.h"
12 #include <public/WebTransformationMatrix.h> 12 #include "ui/gfx/transform.h"
13 13
14 using WebKit::WebTransformationMatrix; 14 using gfx::Transform;
15 15
16 static WebTransformationMatrix orthoProjectionMatrix(float left, float right, fl oat bottom, float top) 16 static Transform orthoProjectionMatrix(float left, float right, float bottom, fl oat top)
17 { 17 {
18 // Use the standard formula to map the clipping frustum to the cube from 18 // Use the standard formula to map the clipping frustum to the cube from
19 // [-1, -1, -1] to [1, 1, 1]. 19 // [-1, -1, -1] to [1, 1, 1].
20 float deltaX = right - left; 20 float deltaX = right - left;
21 float deltaY = top - bottom; 21 float deltaY = top - bottom;
22 WebTransformationMatrix proj; 22 Transform proj;
23 if (!deltaX || !deltaY) 23 if (!deltaX || !deltaY)
24 return proj; 24 return proj;
25 proj.setM11(2.0f / deltaX); 25 proj.matrix().setDouble(0, 0, 2.0f / deltaX);
26 proj.setM41(-(right + left) / deltaX); 26 proj.matrix().setDouble(0, 3, -(right + left) / deltaX);
27 proj.setM22(2.0f / deltaY); 27 proj.matrix().setDouble(1, 1, 2.0f / deltaY);
28 proj.setM42(-(top + bottom) / deltaY); 28 proj.matrix().setDouble(1, 3, -(top + bottom) / deltaY);
29 29
30 // Z component of vertices is always set to zero as we don't use the depth b uffer 30 // Z component of vertices is always set to zero as we don't use the depth b uffer
31 // while drawing. 31 // while drawing.
32 proj.setM33(0); 32 proj.matrix().setDouble(2, 2, 0);
33 33
34 return proj; 34 return proj;
35 } 35 }
36 36
37 static WebTransformationMatrix windowMatrix(int x, int y, int width, int height) 37 static Transform windowMatrix(int x, int y, int width, int height)
38 { 38 {
39 WebTransformationMatrix canvas; 39 Transform canvas;
40 40
41 // Map to window position and scale up to pixel coordinates. 41 // Map to window position and scale up to pixel coordinates.
42 canvas.translate3d(x, y, 0); 42 canvas.PreconcatTranslate3d(x, y, 0);
43 canvas.scale3d(width, height, 0); 43 canvas.PreconcatScale3d(width, height, 0);
44 44
45 // Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1]) 45 // Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1])
46 canvas.translate3d(0.5, 0.5, 0.5); 46 canvas.PreconcatTranslate3d(0.5, 0.5, 0.5);
47 canvas.scale3d(0.5, 0.5, 0.5); 47 canvas.PreconcatScale3d(0.5, 0.5, 0.5);
48 48
49 return canvas; 49 return canvas;
50 } 50 }
51 51
52 namespace cc { 52 namespace cc {
53 53
54 DirectRenderer::DrawingFrame::DrawingFrame() 54 DirectRenderer::DrawingFrame::DrawingFrame()
55 : rootRenderPass(0) 55 : rootRenderPass(0)
56 , currentRenderPass(0) 56 , currentRenderPass(0)
57 , currentTexture(0) 57 , currentTexture(0)
58 , flippedY(false) 58 , flippedY(false)
59 { 59 {
60 } 60 }
61 61
62 DirectRenderer::DrawingFrame::~DrawingFrame() 62 DirectRenderer::DrawingFrame::~DrawingFrame()
63 { 63 {
64 } 64 }
65 65
66 // 66 //
67 // static 67 // static
68 gfx::RectF DirectRenderer::quadVertexRect() 68 gfx::RectF DirectRenderer::quadVertexRect()
69 { 69 {
70 return gfx::RectF(-0.5, -0.5, 1, 1); 70 return gfx::RectF(-0.5, -0.5, 1, 1);
71 } 71 }
72 72
73 // static 73 // static
74 void DirectRenderer::quadRectTransform(WebKit::WebTransformationMatrix* quadRect Transform, const WebKit::WebTransformationMatrix& quadTransform, const gfx::Rect F& quadRect) 74 void DirectRenderer::quadRectTransform(gfx::Transform* quadRectTransform, const gfx::Transform& quadTransform, const gfx::RectF& quadRect)
75 { 75 {
76 *quadRectTransform = quadTransform; 76 *quadRectTransform = quadTransform;
77 quadRectTransform->translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * qu adRect.height() + quadRect.y()); 77 quadRectTransform->PreconcatTranslate(0.5 * quadRect.width() + quadRect.x(), 0.5 * quadRect.height() + quadRect.y());
78 quadRectTransform->scaleNonUniform(quadRect.width(), quadRect.height()); 78 quadRectTransform->PreconcatScale(quadRect.width(), quadRect.height());
79 } 79 }
80 80
81 // static 81 // static
82 void DirectRenderer::initializeMatrices(DrawingFrame& frame, const gfx::Rect& dr awRect, bool flipY) 82 void DirectRenderer::initializeMatrices(DrawingFrame& frame, const gfx::Rect& dr awRect, bool flipY)
83 { 83 {
84 if (flipY) 84 if (flipY)
85 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ri ght(), drawRect.bottom(), drawRect.y()); 85 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ri ght(), drawRect.bottom(), drawRect.y());
86 else 86 else
87 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ri ght(), drawRect.y(), drawRect.bottom()); 87 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ri ght(), drawRect.y(), drawRect.bottom());
88 frame.windowMatrix = windowMatrix(0, 0, drawRect.width(), drawRect.height()) ; 88 frame.windowMatrix = windowMatrix(0, 0, drawRect.width(), drawRect.height()) ;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende rPass) 172 void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende rPass)
173 { 173 {
174 TRACE_EVENT0("cc", "DirectRenderer::drawRenderPass"); 174 TRACE_EVENT0("cc", "DirectRenderer::drawRenderPass");
175 if (!useRenderPass(frame, renderPass)) 175 if (!useRenderPass(frame, renderPass))
176 return; 176 return;
177 177
178 frame.scissorRectInRenderPassSpace = frame.currentRenderPass->output_rect; 178 frame.scissorRectInRenderPassSpace = frame.currentRenderPass->output_rect;
179 if (frame.rootDamageRect != frame.rootRenderPass->output_rect) { 179 if (frame.rootDamageRect != frame.rootRenderPass->output_rect) {
180 WebTransformationMatrix inverseTransformToRoot = frame.currentRenderPass ->transform_to_root_target.inverse(); 180 Transform inverseTransformToRoot = MathUtil::inverse(frame.currentRender Pass->transform_to_root_target);
181 gfx::RectF damageRectInRenderPassSpace = MathUtil::projectClippedRect(in verseTransformToRoot, frame.rootDamageRect); 181 gfx::RectF damageRectInRenderPassSpace = MathUtil::projectClippedRect(in verseTransformToRoot, frame.rootDamageRect);
182 frame.scissorRectInRenderPassSpace.Intersect(damageRectInRenderPassSpace ); 182 frame.scissorRectInRenderPassSpace.Intersect(damageRectInRenderPassSpace );
183 } 183 }
184 184
185 setScissorTestRect(moveScissorToWindowSpace(frame, frame.scissorRectInRender PassSpace)); 185 setScissorTestRect(moveScissorToWindowSpace(frame, frame.scissorRectInRender PassSpace));
186 clearFramebuffer(frame); 186 clearFramebuffer(frame);
187 187
188 const QuadList& quadList = renderPass->quad_list; 188 const QuadList& quadList = renderPass->quad_list;
189 for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { 189 for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) {
190 gfx::RectF quadScissorRect = gfx::IntersectRects(frame.scissorRectInRender PassSpace, (*it)->clippedRectInTarget()); 190 gfx::RectF quadScissorRect = gfx::IntersectRects(frame.scissorRectInRender PassSpace, (*it)->clippedRectInTarget());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return pass->output_rect.size(); 231 return pass->output_rect.size();
232 } 232 }
233 233
234 // static 234 // static
235 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*) 235 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*)
236 { 236 {
237 return GL_RGBA; 237 return GL_RGBA;
238 } 238 }
239 239
240 } // namespace cc 240 } // namespace cc
OLDNEW
« no previous file with comments | « cc/direct_renderer.h ('k') | cc/draw_quad.h » ('j') | cc/float_quad_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698