OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/testing/PictureMatchers.h" | 5 #include "platform/testing/PictureMatchers.h" |
6 | 6 |
7 #include "platform/geometry/FloatQuad.h" | 7 #include "platform/geometry/FloatQuad.h" |
8 #include "platform/geometry/FloatRect.h" | 8 #include "platform/geometry/FloatRect.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkPicture.h" | 10 #include "third_party/skia/include/core/SkPicture.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 SkPoint quad[4]; | 40 SkPoint quad[4]; |
41 getTotalMatrix().mapRectToQuad(quad, clippedRect); | 41 getTotalMatrix().mapRectToQuad(quad, clippedRect); |
42 QuadWithColor quadWithColor; | 42 QuadWithColor quadWithColor; |
43 quadWithColor.quad = FloatQuad(quad); | 43 quadWithColor.quad = FloatQuad(quad); |
44 | 44 |
45 unsigned paintAlpha = static_cast<unsigned>(paint.getAlpha()); | 45 unsigned paintAlpha = static_cast<unsigned>(paint.getAlpha()); |
46 SkPaint paintWithAlpha(paint); | 46 SkPaint paintWithAlpha(paint); |
47 paintWithAlpha.setAlpha(static_cast<U8CPU>(m_alpha * paintAlpha / 255)); | 47 paintWithAlpha.setAlpha(static_cast<U8CPU>(m_alpha * paintAlpha / 255)); |
48 quadWithColor.color = Color(paintWithAlpha.getColor()); | 48 quadWithColor.color = Color(paintWithAlpha.getColor()); |
49 m_quads.append(quadWithColor); | 49 m_quads.push_back(quadWithColor); |
50 SkCanvas::onDrawRect(clippedRect, paint); | 50 SkCanvas::onDrawRect(clippedRect, paint); |
51 } | 51 } |
52 | 52 |
53 SkCanvas::SaveLayerStrategy getSaveLayerStrategy( | 53 SkCanvas::SaveLayerStrategy getSaveLayerStrategy( |
54 const SaveLayerRec& rec) override { | 54 const SaveLayerRec& rec) override { |
55 m_saveCount++; | 55 m_saveCount++; |
56 unsigned layerAlpha = static_cast<unsigned>(rec.fPaint->getAlpha()); | 56 unsigned layerAlpha = static_cast<unsigned>(rec.fPaint->getAlpha()); |
57 if (layerAlpha < 255) { | 57 if (layerAlpha < 255) { |
58 DCHECK_EQ(m_alphaSaveLayerCount, -1); | 58 DCHECK_EQ(m_alphaSaveLayerCount, -1); |
59 m_alphaSaveLayerCount = m_saveCount; | 59 m_alphaSaveLayerCount = m_saveCount; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 rectsWithColor.push_back(RectWithColor(rect, color)); | 162 rectsWithColor.push_back(RectWithColor(rect, color)); |
163 return ::testing::MakeMatcher(new DrawsRectanglesMatcher(rectsWithColor)); | 163 return ::testing::MakeMatcher(new DrawsRectanglesMatcher(rectsWithColor)); |
164 } | 164 } |
165 | 165 |
166 ::testing::Matcher<const SkPicture&> drawsRectangles( | 166 ::testing::Matcher<const SkPicture&> drawsRectangles( |
167 const Vector<RectWithColor>& rectsWithColor) { | 167 const Vector<RectWithColor>& rectsWithColor) { |
168 return ::testing::MakeMatcher(new DrawsRectanglesMatcher(rectsWithColor)); | 168 return ::testing::MakeMatcher(new DrawsRectanglesMatcher(rectsWithColor)); |
169 } | 169 } |
170 | 170 |
171 } // namespace blink | 171 } // namespace blink |
OLD | NEW |