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

Unified Diff: gm/imagefiltersgraph.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/imagefilterscropexpand.cpp ('k') | gm/imagefiltersscaled.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersgraph.cpp
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index 3f9fe3fa95167192a4909025c7b599f4a3d37021..3ef2a1e589dc6cef561cf932dfceb7a9d26a565e 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -9,11 +9,12 @@
#include "SkArithmeticMode.h"
#include "SkDevice.h"
-#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkColorMatrixFilter.h"
+#include "SkImage.h"
+#include "SkImageSource.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMergeImageFilter.h"
@@ -107,24 +108,17 @@ protected:
return SkString("imagefiltersgraph");
}
- void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint) {
- canvas->save();
- canvas->clipRect(SkRect::MakeXYWH(0, 0,
- SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
- canvas->drawBitmap(bitmap, 0, 0, &paint);
- canvas->restore();
- }
-
SkISize onISize() override { return SkISize::Make(500, 150); }
void onOnceBeforeDraw() override {
- fBitmap = sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e");
+ fImage.reset(SkImage::NewFromBitmap(
+ sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e")));
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
{
- SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBitmap));
+ SkAutoTUnref<SkImageFilter> bitmapSource(SkImageSource::Create(fImage));
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode));
SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitmapSource));
@@ -152,7 +146,7 @@ protected:
SkPaint paint;
paint.setImageFilter(blendColor);
- drawClippedBitmap(canvas, fBitmap, paint);
+ DrawClippedImage(canvas, fImage, paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -171,7 +165,7 @@ protected:
SkPaint paint;
paint.setImageFilter(arithFilter);
- drawClippedBitmap(canvas, fBitmap, paint);
+ DrawClippedImage(canvas, fImage, paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -185,7 +179,7 @@ protected:
SkPaint paint;
paint.setImageFilter(blend);
- drawClippedBitmap(canvas, fBitmap, paint);
+ DrawClippedImage(canvas, fImage, paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -210,8 +204,16 @@ protected:
}
private:
+ static void DrawClippedImage(SkCanvas* canvas, const SkImage* image, const SkPaint& paint) {
+ canvas->save();
+ canvas->clipRect(SkRect::MakeIWH(image->width(), image->height()));
+ canvas->drawImage(image, 0, 0, &paint);
+ canvas->restore();
+ }
+
+ SkAutoTUnref<SkImage> fImage;
+
typedef GM INHERITED;
- SkBitmap fBitmap;
};
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « gm/imagefilterscropexpand.cpp ('k') | gm/imagefiltersscaled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698