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

Unified Diff: gm/imagefilterscropexpand.cpp

Issue 1343123002: Convert unit tests, GMs from SkBitmapSource to SkImagesource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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
Index: gm/imagefilterscropexpand.cpp
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index cfbf13a759fb53d0fc506ed1d121a1d1ed83f1c8..8014e3ae25525805bd40253f7e57461023a32660 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -11,16 +11,17 @@
#include "SkColorPriv.h"
#include "SkShader.h"
-#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
#include "SkColorMatrixFilter.h"
#include "SkDisplacementMapEffect.h"
#include "SkDropShadowImageFilter.h"
#include "SkGradientShader.h"
+#include "SkImageSource.h"
#include "SkMorphologyImageFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkMergeImageFilter.h"
#include "SkOffsetImageFilter.h"
+#include "SkSurface.h"
///////////////////////////////////////////////////////////////////////////////
@@ -57,13 +58,13 @@ protected:
}
}
robertphillips 2015/09/15 17:43:52 static SkImage* MakeGradientCircle(int width, int
f(malita) 2015/09/15 18:12:53 Done.
- void make_gradient_circle(int width, int height, SkBitmap* bitmap) {
+ SkImage* make_gradient_circle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
- bitmap->allocN32Pixels(width, height);
- SkCanvas canvas(*bitmap);
- canvas.clear(0x00000000);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->clear(0x00000000);
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
@@ -73,7 +74,9 @@ protected:
);
SkPaint paint;
paint.setShader(shader);
- canvas.drawCircle(x, y, radius, paint);
+ canvas->drawCircle(x, y, radius, paint);
+
+ return surface->newImageSnapshot();
}
static void draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rect, SkImageFilter* filter) {
@@ -98,12 +101,12 @@ protected:
SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
SkImageFilter::CropRect::kHasAll_CropEdge);
robertphillips 2015/09/15 17:43:52 gradientCircle ?
f(malita) 2015/09/15 18:12:53 Done.
- SkBitmap gradient_circle, checkerboard;
- make_gradient_circle(64, 64, &gradient_circle);
+ SkAutoTUnref<SkImage> gradient_circle(make_gradient_circle(64, 64));
+ SkBitmap checkerboard;
make_checkerboard(&checkerboard);
SkAutoTUnref<SkImageFilter> gradient_circle_source(
- SkBitmapSource::Create(gradient_circle));
+ SkImageSource::Create(gradient_circle));
SkAutoTUnref<SkImageFilter> noop_cropped(
SkOffsetImageFilter::Create(0, 0, nullptr, &crop_rect));
SkScalar sk255 = SkIntToScalar(255);

Powered by Google App Engine
This is Rietveld 408576698