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

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: Patch for landing 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
« no previous file with comments | « cc/shared_quad_state.cc ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
28 29
29 namespace cc { 30 namespace cc {
30 31
31 namespace { 32 namespace {
32 33
33 void toSkMatrix(SkMatrix* flattened, const WebTransformationMatrix& m) 34 void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m)
34 { 35 {
35 // Convert from 4x4 to 3x3 by dropping the third row and column. 36 // Convert from 4x4 to 3x3 by dropping the third row and column.
36 flattened->set(0, SkDoubleToScalar(m.m11())); 37 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0)));
37 flattened->set(1, SkDoubleToScalar(m.m21())); 38 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1)));
38 flattened->set(2, SkDoubleToScalar(m.m41())); 39 flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3)));
39 flattened->set(3, SkDoubleToScalar(m.m12())); 40 flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0)));
40 flattened->set(4, SkDoubleToScalar(m.m22())); 41 flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1)));
41 flattened->set(5, SkDoubleToScalar(m.m42())); 42 flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3)));
42 flattened->set(6, SkDoubleToScalar(m.m14())); 43 flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0)));
43 flattened->set(7, SkDoubleToScalar(m.m24())); 44 flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1)));
44 flattened->set(8, SkDoubleToScalar(m.m44())); 45 flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3)));
45 } 46 }
46 47
47 bool isScaleAndTranslate(const SkMatrix& matrix) 48 bool isScaleAndTranslate(const SkMatrix& matrix)
48 { 49 {
49 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && 50 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) &&
50 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && 51 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) &&
51 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && 52 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) &&
52 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && 53 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) &&
53 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); 54 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f);
54 } 55 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return true; 178 return true;
178 } 179 }
179 180
180 LOG(FATAL) << "Invalid resource type."; 181 LOG(FATAL) << "Invalid resource type.";
181 return false; 182 return false;
182 } 183 }
183 184
184 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) 185 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
185 { 186 {
186 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); 187 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad");
187 WebTransformationMatrix quadRectMatrix; 188 gfx::Transform quadRectMatrix;
188 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 189 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
189 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); 190 gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windo wMatrix * frame.projectionMatrix * quadRectMatrix);
190 SkMatrix skDeviceMatrix; 191 SkMatrix skDeviceMatrix;
191 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); 192 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform);
192 m_skCurrentCanvas->setMatrix(skDeviceMatrix); 193 m_skCurrentCanvas->setMatrix(skDeviceMatrix);
193 194
194 m_skCurrentPaint.reset(); 195 m_skCurrentPaint.reset();
195 if (!isScaleAndTranslate(skDeviceMatrix)) { 196 if (!isScaleAndTranslate(skDeviceMatrix)) {
196 m_skCurrentPaint.setAntiAlias(true); 197 m_skCurrentPaint.setAntiAlias(true);
197 m_skCurrentPaint.setFilterBitmap(true); 198 m_skCurrentPaint.setFilterBitmap(true);
198 } 199 }
199 200
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 376 }
376 377
377 void SoftwareRenderer::setVisible(bool visible) 378 void SoftwareRenderer::setVisible(bool visible)
378 { 379 {
379 if (m_visible == visible) 380 if (m_visible == visible)
380 return; 381 return;
381 m_visible = visible; 382 m_visible = visible;
382 } 383 }
383 384
384 } // namespace cc 385 } // namespace cc
OLDNEW
« no previous file with comments | « cc/shared_quad_state.cc ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698