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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCRendererSoftware.h" | 7 #include "CCRendererSoftware.h" |
8 | 8 |
9 #include "CCDebugBorderDrawQuad.h" | 9 #include "CCDebugBorderDrawQuad.h" |
10 #include "CCSolidColorDrawQuad.h" | 10 #include "CCSolidColorDrawQuad.h" |
11 #include "CCTextureDrawQuad.h" | 11 #include "CCTextureDrawQuad.h" |
12 #include "CCTileDrawQuad.h" | 12 #include "CCTileDrawQuad.h" |
13 #include "CCRenderPassDrawQuad.h" | 13 #include "CCRenderPassDrawQuad.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
16 #include "third_party/skia/include/core/SkMatrix.h" | 16 #include "third_party/skia/include/core/SkMatrix.h" |
17 #include "third_party/skia/include/core/SkShader.h" | 17 #include "third_party/skia/include/core/SkShader.h" |
18 #include "third_party/skia/include/effects/SkLayerRasterizer.h" | 18 #include "third_party/skia/include/effects/SkLayerRasterizer.h" |
19 #include <public/WebImage.h> | 19 #include <public/WebImage.h> |
20 #include <public/WebSize.h> | 20 #include <public/WebSize.h> |
21 #include <public/WebTransformationMatrix.h> | 21 #include <public/WebTransformationMatrix.h> |
22 #include <limits> | |
22 | 23 |
23 using WebKit::WebCompositorSoftwareOutputDevice; | 24 using WebKit::WebCompositorSoftwareOutputDevice; |
24 using WebKit::WebImage; | 25 using WebKit::WebImage; |
25 using WebKit::WebSize; | 26 using WebKit::WebSize; |
26 using WebKit::WebTransformationMatrix; | 27 using WebKit::WebTransformationMatrix; |
27 | 28 |
28 namespace cc { | 29 namespace cc { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
(...skipping 14 matching lines...) Expand all Loading... | |
46 flattened->set(1, m.m21()); | 47 flattened->set(1, m.m21()); |
47 flattened->set(2, m.m41()); | 48 flattened->set(2, m.m41()); |
48 flattened->set(3, m.m12()); | 49 flattened->set(3, m.m12()); |
49 flattened->set(4, m.m22()); | 50 flattened->set(4, m.m22()); |
50 flattened->set(5, m.m42()); | 51 flattened->set(5, m.m42()); |
51 flattened->set(6, m.m14()); | 52 flattened->set(6, m.m14()); |
52 flattened->set(7, m.m24()); | 53 flattened->set(7, m.m24()); |
53 flattened->set(8, m.m44()); | 54 flattened->set(8, m.m44()); |
54 } | 55 } |
55 | 56 |
57 bool isZero(float f) | |
aelias_OOO_until_Jul13
2012/10/12 21:26:56
No need for this method. You can use SkScalarNear
| |
58 { | |
59 return abs(f) < std::numeric_limits<float>::epsilon(); | |
danakj
2012/10/12 21:24:37
thanks! i think this should be std::abs() as well
| |
60 } | |
61 | |
62 bool isScaleAndTranslate(const SkMatrix& matrix) | |
63 { | |
64 return isZero(matrix[SkMatrix::kMSkewX]) && | |
65 isZero(matrix[SkMatrix::kMSkewY]) && | |
66 isZero(matrix[SkMatrix::kMPersp0]) && | |
67 isZero(matrix[SkMatrix::kMPersp1]) && | |
68 isZero(matrix[SkMatrix::kMPersp2] - 1.0f); | |
69 } | |
70 | |
56 } // anonymous namespace | 71 } // anonymous namespace |
57 | 72 |
58 PassOwnPtr<CCRendererSoftware> CCRendererSoftware::create(CCRendererClient* clie nt, CCResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* out putDevice) | 73 PassOwnPtr<CCRendererSoftware> CCRendererSoftware::create(CCRendererClient* clie nt, CCResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* out putDevice) |
59 { | 74 { |
60 return adoptPtr(new CCRendererSoftware(client, resourceProvider, outputDevic e)); | 75 return adoptPtr(new CCRendererSoftware(client, resourceProvider, outputDevic e)); |
61 } | 76 } |
62 | 77 |
63 CCRendererSoftware::CCRendererSoftware(CCRendererClient* client, CCResourceProvi der* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) | 78 CCRendererSoftware::CCRendererSoftware(CCRendererClient* client, CCResourceProvi der* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) |
64 : CCDirectRenderer(client, resourceProvider) | 79 : CCDirectRenderer(client, resourceProvider) |
65 , m_visible(true) | 80 , m_visible(true) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 void CCRendererSoftware::drawQuad(DrawingFrame& frame, const CCDrawQuad* quad) | 186 void CCRendererSoftware::drawQuad(DrawingFrame& frame, const CCDrawQuad* quad) |
172 { | 187 { |
173 WebTransformationMatrix quadRectMatrix; | 188 WebTransformationMatrix quadRectMatrix; |
174 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->quadRect()); | 189 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->quadRect()); |
175 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); | 190 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); |
176 SkMatrix skDeviceMatrix; | 191 SkMatrix skDeviceMatrix; |
177 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); | 192 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); |
178 m_skCurrentCanvas->setMatrix(skDeviceMatrix); | 193 m_skCurrentCanvas->setMatrix(skDeviceMatrix); |
179 | 194 |
180 m_skCurrentPaint.reset(); | 195 m_skCurrentPaint.reset(); |
196 if (!isScaleAndTranslate(skDeviceMatrix)) { | |
197 m_skCurrentPaint.setAntiAlias(true); | |
198 m_skCurrentPaint.setFilterBitmap(true); | |
199 } | |
181 if (quad->needsBlending()) { | 200 if (quad->needsBlending()) { |
182 m_skCurrentPaint.setAlpha(quad->opacity() * 255); | 201 m_skCurrentPaint.setAlpha(quad->opacity() * 255); |
183 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 202 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
184 } else { | 203 } else { |
185 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrc_Mode); | 204 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrc_Mode); |
186 } | 205 } |
187 | 206 |
188 switch (quad->material()) { | 207 switch (quad->material()) { |
189 case CCDrawQuad::DebugBorder: | 208 case CCDrawQuad::DebugBorder: |
190 drawDebugBorderQuad(frame, CCDebugBorderDrawQuad::materialCast(quad)); | 209 drawDebugBorderQuad(frame, CCDebugBorderDrawQuad::materialCast(quad)); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 } | 355 } |
337 | 356 |
338 void CCRendererSoftware::setVisible(bool visible) | 357 void CCRendererSoftware::setVisible(bool visible) |
339 { | 358 { |
340 if (m_visible == visible) | 359 if (m_visible == visible) |
341 return; | 360 return; |
342 m_visible = visible; | 361 m_visible = visible; |
343 } | 362 } |
344 | 363 |
345 } | 364 } |
OLD | NEW |