OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" | 6 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" |
7 | 7 |
8 #include "platform/graphics/paint/DisplayItem.h" | 8 #include "platform/graphics/paint/DisplayItem.h" |
9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
10 #include "platform/graphics/paint/PaintArtifact.h" | 10 #include "platform/graphics/paint/PaintArtifact.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 onDrawRect(rect, paint, this); | 54 onDrawRect(rect, paint, this); |
55 } | 55 } |
56 | 56 |
57 SaveLayerStrategy willSaveLayer(const SkRect* rect, const SkPaint* paint, Sa
veFlags saveFlags) override | 57 SaveLayerStrategy willSaveLayer(const SkRect* rect, const SkPaint* paint, Sa
veFlags saveFlags) override |
58 { | 58 { |
59 willSaveLayer(paint->getAlpha(), this); | 59 willSaveLayer(paint->getAlpha(), this); |
60 return SaveLayerStrategy::kFullLayer_SaveLayerStrategy; | 60 return SaveLayerStrategy::kFullLayer_SaveLayerStrategy; |
61 } | 61 } |
62 }; | 62 }; |
63 | 63 |
64 class DummyRectClient { | 64 class DummyRectClient : public DisplayItemClient { |
65 public: | 65 public: |
66 DummyRectClient(const SkRect& rect, SkColor color) : m_rect(rect), m_color(c
olor) {} | 66 DummyRectClient(const SkRect& rect, SkColor color) : m_rect(rect), m_color(c
olor) {} |
67 const SkRect& rect() const { return m_rect; } | 67 const SkRect& rect() const { return m_rect; } |
68 SkColor color() const { return m_color; } | 68 SkColor color() const { return m_color; } |
69 PassRefPtr<SkPicture> makePicture() const { return pictureWithRect(m_rect, m
_color); } | 69 PassRefPtr<SkPicture> makePicture() const { return pictureWithRect(m_rect, m
_color); } |
70 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } | 70 String debugName() const final { return "<dummy>"; } |
71 String debugName() const { return "<dummy>"; } | |
72 | 71 |
73 private: | 72 private: |
74 SkRect m_rect; | 73 SkRect m_rect; |
75 SkColor m_color; | 74 SkColor m_color; |
76 }; | 75 }; |
77 | 76 |
78 TEST(PaintArtifactToSkCanvasTest, Empty) | 77 TEST(PaintArtifactToSkCanvasTest, Empty) |
79 { | 78 { |
80 MockCanvas canvas(kCanvasWidth, kCanvasHeight); | 79 MockCanvas canvas(kCanvasWidth, kCanvasHeight); |
81 EXPECT_CALL(canvas, onDrawRect(_, _, _)).Times(0); | 80 EXPECT_CALL(canvas, onDrawRect(_, _, _)).Times(0); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 totalClip.setRect(SkIRect::MakeXYWH(100, 100, 100, 100)); | 284 totalClip.setRect(SkIRect::MakeXYWH(100, 100, 100, 100)); |
286 totalClip.op(SkIRect::MakeXYWH(150, 150, 100, 100), SkRegion::kIntersect_Op)
; | 285 totalClip.op(SkIRect::MakeXYWH(150, 150, 100, 100), SkRegion::kIntersect_Op)
; |
287 EXPECT_CALL(canvas, onDrawRect(client1.rect(), Property(&SkPaint::getColor,
client1.color()), | 286 EXPECT_CALL(canvas, onDrawRect(client1.rect(), Property(&SkPaint::getColor,
client1.color()), |
288 ResultOf(&getCanvasClipAsRegion, Eq(totalClip)))); | 287 ResultOf(&getCanvasClipAsRegion, Eq(totalClip)))); |
289 | 288 |
290 paintArtifactToSkCanvas(artifact, &canvas); | 289 paintArtifactToSkCanvas(artifact, &canvas); |
291 } | 290 } |
292 | 291 |
293 } // namespace | 292 } // namespace |
294 } // namespace blink | 293 } // namespace blink |
OLD | NEW |