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

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

Issue 2727133002: Remove ColorBehavior argument to Image::imageForCurrentFrame (Closed)
Patch Set: Rebase Created 3 years, 9 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return false; 54 return false;
55 } 55 }
56 IntSize size() const override { return IntSize(); } 56 IntSize size() const override { return IntSize(); }
57 void destroyDecodedData() override {} 57 void destroyDecodedData() override {}
58 void draw(PaintCanvas*, 58 void draw(PaintCanvas*,
59 const PaintFlags&, 59 const PaintFlags&,
60 const FloatRect& dstRect, 60 const FloatRect& dstRect,
61 const FloatRect& srcRect, 61 const FloatRect& srcRect,
62 RespectImageOrientationEnum, 62 RespectImageOrientationEnum,
63 ImageClampingMode) override {} 63 ImageClampingMode) override {}
64 sk_sp<SkImage> imageForCurrentFrame(const ColorBehavior&) override { 64 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
65 return nullptr;
66 }
67 }; 65 };
68 66
69 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated) { 67 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated) {
70 setBodyInnerHTML("<img src='myimage'></img>"); 68 setBodyInnerHTML("<img src='myimage'></img>");
71 LayoutImage* img = 69 LayoutImage* img =
72 toLayoutImage(document().body()->firstChild()->layoutObject()); 70 toLayoutImage(document().body()->firstChild()->layoutObject());
73 71
74 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated); 72 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated);
75 EXPECT_EQ(InterpolationMedium, 73 EXPECT_EQ(InterpolationMedium,
76 controller()->chooseInterpolationQuality(*img, testImage.get(), 74 controller()->chooseInterpolationQuality(*img, testImage.get(),
77 nullptr, LayoutSize())); 75 nullptr, LayoutSize()));
78 } 76 }
79 77
80 class TestImageWithContrast : public Image { 78 class TestImageWithContrast : public Image {
81 public: 79 public:
82 bool maybeAnimated() override { return true; } 80 bool maybeAnimated() override { return true; }
83 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { 81 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override {
84 return false; 82 return false;
85 } 83 }
86 IntSize size() const override { return IntSize(); } 84 IntSize size() const override { return IntSize(); }
87 void destroyDecodedData() override {} 85 void destroyDecodedData() override {}
88 void draw(PaintCanvas*, 86 void draw(PaintCanvas*,
89 const PaintFlags&, 87 const PaintFlags&,
90 const FloatRect& dstRect, 88 const FloatRect& dstRect,
91 const FloatRect& srcRect, 89 const FloatRect& srcRect,
92 RespectImageOrientationEnum, 90 RespectImageOrientationEnum,
93 ImageClampingMode) override {} 91 ImageClampingMode) override {}
94 92
95 bool isBitmapImage() const override { return true; } 93 bool isBitmapImage() const override { return true; }
96 sk_sp<SkImage> imageForCurrentFrame(const ColorBehavior&) override { 94 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
97 return nullptr;
98 }
99 }; 95 };
100 96
101 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast) { 97 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast) {
102 setBodyInnerHTML( 98 setBodyInnerHTML(
103 "<img src='myimage' style='image-rendering: " 99 "<img src='myimage' style='image-rendering: "
104 "-webkit-optimize-contrast'></img>"); 100 "-webkit-optimize-contrast'></img>");
105 LayoutImage* img = 101 LayoutImage* img =
106 toLayoutImage(document().body()->firstChild()->layoutObject()); 102 toLayoutImage(document().body()->firstChild()->layoutObject());
107 103
108 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast); 104 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast);
(...skipping 11 matching lines...) Expand all
120 IntSize size() const override { return IntSize(1, 1); } 116 IntSize size() const override { return IntSize(1, 1); }
121 void destroyDecodedData() override {} 117 void destroyDecodedData() override {}
122 void draw(PaintCanvas*, 118 void draw(PaintCanvas*,
123 const PaintFlags&, 119 const PaintFlags&,
124 const FloatRect& dstRect, 120 const FloatRect& dstRect,
125 const FloatRect& srcRect, 121 const FloatRect& srcRect,
126 RespectImageOrientationEnum, 122 RespectImageOrientationEnum,
127 ImageClampingMode) override {} 123 ImageClampingMode) override {}
128 124
129 bool isBitmapImage() const override { return true; } 125 bool isBitmapImage() const override { return true; }
130 sk_sp<SkImage> imageForCurrentFrame(const ColorBehavior&) override { 126 sk_sp<SkImage> imageForCurrentFrame() override { return nullptr; }
131 return nullptr;
132 }
133 }; 127 };
134 128
135 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage) { 129 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage) {
136 setBodyInnerHTML("<img src='myimage'></img>"); 130 setBodyInnerHTML("<img src='myimage'></img>");
137 LayoutImage* img = 131 LayoutImage* img =
138 toLayoutImage(document().body()->firstChild()->layoutObject()); 132 toLayoutImage(document().body()->firstChild()->layoutObject());
139 133
140 RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality); 134 RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
141 EXPECT_EQ(InterpolationMedium, 135 EXPECT_EQ(InterpolationMedium,
142 controller()->chooseInterpolationQuality( 136 controller()->chooseInterpolationQuality(
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 *img, testImage.get(), testImage.get(), LayoutSize(4, 4), 338 *img, testImage.get(), testImage.get(), LayoutSize(4, 4),
345 nextTime)); 339 nextTime));
346 // Now the timer has restarted, leading to a larger fire interval. 340 // Now the timer has restarted, leading to a larger fire interval.
347 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold, 341 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold,
348 mockTimer->nextFireInterval()); 342 mockTimer->nextFireInterval());
349 } 343 }
350 344
351 #endif 345 #endif
352 346
353 } // namespace blink 347 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageData.cpp ('k') | third_party/WebKit/Source/core/svg/graphics/SVGImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698