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

Side by Side Diff: cc/software_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: Rebased to tip of tree and addressed feedback Created 8 years 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/software_renderer.h" 5 #include "cc/software_renderer.h"
6 6
7 #include <public/WebCompositorSoftwareOutputDevice.h>
8 #include <public/WebImage.h>
9 #include <public/WebSize.h>
10
7 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
8 #include "cc/debug_border_draw_quad.h" 12 #include "cc/debug_border_draw_quad.h"
13 #include "cc/math_util.h"
9 #include "cc/render_pass_draw_quad.h" 14 #include "cc/render_pass_draw_quad.h"
10 #include "cc/solid_color_draw_quad.h" 15 #include "cc/solid_color_draw_quad.h"
11 #include "cc/texture_draw_quad.h" 16 #include "cc/texture_draw_quad.h"
12 #include "cc/tile_draw_quad.h" 17 #include "cc/tile_draw_quad.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 18 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
15 #include "third_party/skia/include/core/SkMatrix.h" 20 #include "third_party/skia/include/core/SkMatrix.h"
16 #include "third_party/skia/include/core/SkShader.h" 21 #include "third_party/skia/include/core/SkShader.h"
17 #include "third_party/skia/include/effects/SkLayerRasterizer.h" 22 #include "third_party/skia/include/effects/SkLayerRasterizer.h"
18 #include "ui/gfx/rect_conversions.h" 23 #include "ui/gfx/rect_conversions.h"
19 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
20 #include <public/WebCompositorSoftwareOutputDevice.h> 25 #include "ui/gfx/transform.h"
21 #include <public/WebImage.h>
22 #include <public/WebSize.h>
23 #include <public/WebTransformationMatrix.h>
24 26
25 using WebKit::WebCompositorSoftwareOutputDevice; 27 using WebKit::WebCompositorSoftwareOutputDevice;
26 using WebKit::WebSize; 28 using WebKit::WebSize;
27 using WebKit::WebTransformationMatrix; 29 using gfx::Transform;
28 30
29 namespace cc { 31 namespace cc {
30 32
31 namespace { 33 namespace {
32 34
33 void toSkMatrix(SkMatrix* flattened, const WebTransformationMatrix& m) 35 void toSkMatrix(SkMatrix* flattened, const Transform& m)
34 { 36 {
35 // Convert from 4x4 to 3x3 by dropping the third row and column. 37 // Convert from 4x4 to 3x3 by dropping the third row and column.
36 flattened->set(0, SkDoubleToScalar(m.m11())); 38 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0)));
37 flattened->set(1, SkDoubleToScalar(m.m21())); 39 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1)));
38 flattened->set(2, SkDoubleToScalar(m.m41())); 40 flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3)));
39 flattened->set(3, SkDoubleToScalar(m.m12())); 41 flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0)));
40 flattened->set(4, SkDoubleToScalar(m.m22())); 42 flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1)));
41 flattened->set(5, SkDoubleToScalar(m.m42())); 43 flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3)));
42 flattened->set(6, SkDoubleToScalar(m.m14())); 44 flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0)));
43 flattened->set(7, SkDoubleToScalar(m.m24())); 45 flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1)));
44 flattened->set(8, SkDoubleToScalar(m.m44())); 46 flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3)));
45 } 47 }
46 48
47 bool isScaleAndTranslate(const SkMatrix& matrix) 49 bool isScaleAndTranslate(const SkMatrix& matrix)
48 { 50 {
49 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && 51 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) &&
50 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && 52 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) &&
51 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && 53 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) &&
52 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && 54 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) &&
53 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); 55 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f);
54 } 56 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return true; 179 return true;
178 } 180 }
179 181
180 LOG(FATAL) << "Invalid resource type."; 182 LOG(FATAL) << "Invalid resource type.";
181 return false; 183 return false;
182 } 184 }
183 185
184 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) 186 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
185 { 187 {
186 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); 188 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad");
187 WebTransformationMatrix quadRectMatrix; 189 Transform quadRectMatrix;
188 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 190 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
189 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); 191 Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windowMatr ix * frame.projectionMatrix * quadRectMatrix);
190 SkMatrix skDeviceMatrix; 192 SkMatrix skDeviceMatrix;
191 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); 193 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform);
192 m_skCurrentCanvas->setMatrix(skDeviceMatrix); 194 m_skCurrentCanvas->setMatrix(skDeviceMatrix);
193 195
194 m_skCurrentPaint.reset(); 196 m_skCurrentPaint.reset();
195 if (!isScaleAndTranslate(skDeviceMatrix)) { 197 if (!isScaleAndTranslate(skDeviceMatrix)) {
196 m_skCurrentPaint.setAntiAlias(true); 198 m_skCurrentPaint.setAntiAlias(true);
197 m_skCurrentPaint.setFilterBitmap(true); 199 m_skCurrentPaint.setFilterBitmap(true);
198 } 200 }
199 201
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 377 }
376 378
377 void SoftwareRenderer::setVisible(bool visible) 379 void SoftwareRenderer::setVisible(bool visible)
378 { 380 {
379 if (m_visible == visible) 381 if (m_visible == visible)
380 return; 382 return;
381 m_visible = visible; 383 m_visible = visible;
382 } 384 }
383 385
384 } // namespace cc 386 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698