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

Side by Side Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/layout/ImageQualityController.h" 5 #include "core/layout/ImageQualityController.h"
6 6
7 #include "core/layout/LayoutImage.h" 7 #include "core/layout/LayoutImage.h"
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/PaintController.h" 10 #include "platform/graphics/paint/PaintController.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 #if !USE(LOW_QUALITY_IMAGE_INTERPOLATION) 51 #if !USE(LOW_QUALITY_IMAGE_INTERPOLATION)
52 52
53 class TestImageAnimated : public Image { 53 class TestImageAnimated : public Image {
54 public: 54 public:
55 bool maybeAnimated() override { return true; } 55 bool maybeAnimated() override { return true; }
56 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 56 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
57 IntSize size() const override { return IntSize(); } 57 IntSize size() const override { return IntSize(); }
58 void destroyDecodedData() override { } 58 void destroyDecodedData() override { }
59 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 59 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
60 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 60 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
61 }; 61 };
62 62
63 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated) 63 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated)
64 { 64 {
65 setBodyInnerHTML("<img src='myimage'></img>"); 65 setBodyInnerHTML("<img src='myimage'></img>");
66 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct()); 66 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct());
67 67
68 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated); 68 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated);
69 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img , testImage.get(), nullptr, LayoutSize())); 69 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img , testImage.get(), nullptr, LayoutSize()));
70 } 70 }
71 71
72 class TestImageWithContrast : public Image { 72 class TestImageWithContrast : public Image {
73 public: 73 public:
74 bool maybeAnimated() override { return true; } 74 bool maybeAnimated() override { return true; }
75 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 75 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
76 IntSize size() const override { return IntSize(); } 76 IntSize size() const override { return IntSize(); }
77 void destroyDecodedData() override { } 77 void destroyDecodedData() override { }
78 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 78 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
79 79
80 bool isBitmapImage() const override { return true; } 80 bool isBitmapImage() const override { return true; }
81 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 81 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
82 }; 82 };
83 83
84 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast) 84 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast)
85 { 85 {
86 setBodyInnerHTML("<img src='myimage' style='image-rendering: -webkit-optimiz e-contrast'></img>"); 86 setBodyInnerHTML("<img src='myimage' style='image-rendering: -webkit-optimiz e-contrast'></img>");
87 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct()); 87 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct());
88 88
89 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast ); 89 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast );
90 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, t estImage.get(), testImage.get(), LayoutSize())); 90 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, t estImage.get(), testImage.get(), LayoutSize()));
91 } 91 }
92 92
93 class TestImageLowQuality : public Image { 93 class TestImageLowQuality : public Image {
94 public: 94 public:
95 bool maybeAnimated() override { return true; } 95 bool maybeAnimated() override { return true; }
96 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 96 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
97 IntSize size() const override { return IntSize(1, 1); } 97 IntSize size() const override { return IntSize(1, 1); }
98 void destroyDecodedData() override { } 98 void destroyDecodedData() override { }
99 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 99 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
100 100
101 bool isBitmapImage() const override { return true; } 101 bool isBitmapImage() const override { return true; }
102 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 102 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
103 }; 103 };
104 104
105 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage) 105 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage)
106 { 106 {
107 setBodyInnerHTML("<img src='myimage'></img>"); 107 setBodyInnerHTML("<img src='myimage'></img>");
108 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct()); 108 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct());
109 109
110 RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality); 110 RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
111 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img , testImage.get(), testImage.get(), LayoutSize(1, 1))); 111 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img , testImage.get(), testImage.get(), LayoutSize(1, 1)));
112 } 112 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // This animation is far enough in the future to make the timer restart, sin ce it is half over. 241 // This animation is far enough in the future to make the timer restart, sin ce it is half over.
242 nextTime = 0.1 + ImageQualityController::cTimerRestartThreshold + 0.01; 242 nextTime = 0.1 + ImageQualityController::cTimerRestartThreshold + 0.01;
243 EXPECT_EQ(true, controller()->shouldPaintAtLowQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4), nextTime)); 243 EXPECT_EQ(true, controller()->shouldPaintAtLowQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4), nextTime));
244 // Now the timer has restarted, leading to a larger fire interval. 244 // Now the timer has restarted, leading to a larger fire interval.
245 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold, mockTimer->nextF ireInterval()); 245 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold, mockTimer->nextF ireInterval());
246 } 246 }
247 247
248 #endif 248 #endif
249 249
250 } // namespace blink 250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698