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

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: 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/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return true; 162 return true;
161 } 163 }
162 164
163 LOG(FATAL) << "Invalid resource type."; 165 LOG(FATAL) << "Invalid resource type.";
164 return false; 166 return false;
165 } 167 }
166 168
167 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) 169 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
168 { 170 {
169 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); 171 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad");
170 WebTransformationMatrix quadRectMatrix; 172 Transform quadRectMatrix;
171 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 173 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
172 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); 174 Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windowMatr ix * frame.projectionMatrix * quadRectMatrix);
173 SkMatrix skDeviceMatrix; 175 SkMatrix skDeviceMatrix;
174 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); 176 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform);
175 m_skCurrentCanvas->setMatrix(skDeviceMatrix); 177 m_skCurrentCanvas->setMatrix(skDeviceMatrix);
176 178
177 m_skCurrentPaint.reset(); 179 m_skCurrentPaint.reset();
178 if (!isScaleAndTranslate(skDeviceMatrix)) { 180 if (!isScaleAndTranslate(skDeviceMatrix)) {
179 m_skCurrentPaint.setAntiAlias(true); 181 m_skCurrentPaint.setAntiAlias(true);
180 m_skCurrentPaint.setFilterBitmap(true); 182 m_skCurrentPaint.setFilterBitmap(true);
181 } 183 }
182 184
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 360 }
359 361
360 void SoftwareRenderer::setVisible(bool visible) 362 void SoftwareRenderer::setVisible(bool visible)
361 { 363 {
362 if (m_visible == visible) 364 if (m_visible == visible)
363 return; 365 return;
364 m_visible = visible; 366 m_visible = visible;
365 } 367 }
366 368
367 } // namespace cc 369 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698