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

Unified Diff: gm/imagesource2.cpp

Issue 1343123002: Convert unit tests, GMs from SkBitmapSource to SkImagesource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagesource2.cpp
diff --git a/gm/bitmapsource2.cpp b/gm/imagesource2.cpp
similarity index 64%
rename from gm/bitmapsource2.cpp
rename to gm/imagesource2.cpp
index f65bafd2bc46169bfd4b4fdd1db6752a145f86f4..7f9c2b5d433f7ef8bf5a46f56f4e600af6c91e5a 100644
--- a/gm/bitmapsource2.cpp
+++ b/gm/imagesource2.cpp
@@ -6,28 +6,30 @@
*/
#include "gm.h"
-#include "SkBitmapSource.h"
+#include "SkImage.h"
+#include "SkImageSource.h"
+#include "SkSurface.h"
namespace skiagm {
-// This GM reproduces the issue in crbug.com/472795. The SkBitmapSource image
+// This GM reproduces the issue in crbug.com/472795. The SkImageSource image
// is shifted for high quality mode between cpu and gpu.
-class BitmapSourceGM : public GM {
+class ImageSourceGM : public GM {
public:
- BitmapSourceGM(const char* suffix, SkFilterQuality filter) : fSuffix(suffix), fFilter(filter) {
+ ImageSourceGM(const char* suffix, SkFilterQuality filter) : fSuffix(suffix), fFilter(filter) {
this->setBGColor(0xFFFFFFFF);
}
protected:
SkString onShortName() override {
- SkString name("bitmapsrc2_");
+ SkString name("imagesrc2_");
name.append(fSuffix);
return name;
}
SkISize onISize() override { return SkISize::Make(256, 256); }
- // Create a bitmap with high frequency vertical stripes
+ // Create an image with high frequency vertical stripes
void onOnceBeforeDraw() override {
static const SkPMColor gColors[] = {
SK_ColorRED, SK_ColorGRAY,
@@ -39,9 +41,8 @@ protected:
SK_ColorWHITE, SK_ColorGRAY,
};
- fBM.allocN32Pixels(kImageSize, kImageSize, true);
-
- SkCanvas canvas(fBM);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kImageSize, kImageSize));
+ SkCanvas* canvas = surface->getCanvas();
int curColor = 0;
@@ -50,10 +51,12 @@ protected:
SkIntToScalar(3), SkIntToScalar(kImageSize));
SkPaint p;
p.setColor(gColors[curColor]);
- canvas.drawRect(r, p);
+ canvas->drawRect(r, p);
curColor = (curColor+1) % SK_ARRAY_COUNT(gColors);
}
+
+ fImage.reset(surface->newImageSnapshot());
}
void onDraw(SkCanvas* canvas) override {
@@ -61,7 +64,8 @@ protected:
SkIntToScalar(kImageSize), SkIntToScalar(kImageSize));
SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f);
- SkAutoTUnref<SkImageFilter> filter(SkBitmapSource::Create(fBM, srcRect, dstRect, fFilter));
+ SkAutoTUnref<SkImageFilter> filter(
+ SkImageSource::Create(fImage, srcRect, dstRect, fFilter));
SkPaint p;
p.setImageFilter(filter);
@@ -75,15 +79,15 @@ private:
SkString fSuffix;
SkFilterQuality fFilter;
- SkBitmap fBM;
+ SkAutoTUnref<SkImage> fImage;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return new BitmapSourceGM("none", kNone_SkFilterQuality);)
-DEF_GM(return new BitmapSourceGM("low", kLow_SkFilterQuality);)
-DEF_GM(return new BitmapSourceGM("med", kMedium_SkFilterQuality);)
-DEF_GM(return new BitmapSourceGM("high", kHigh_SkFilterQuality);)
+DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);)
+DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);)
+DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);)
+DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);)
}
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698