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

Unified Diff: gm/bigtileimagefilter.cpp

Issue 1363913002: Remove SkBitmapSource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: immutable bitmap 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 | « bench/LightingBench.cpp ('k') | gm/bitmapsource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/bigtileimagefilter.cpp
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index 3c55b714109c36e60ba75edafa1c3631eb8f30ad..20c462b7449cbecbcb9c399ea1ccc318171c75c5 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -5,21 +5,24 @@
* found in the LICENSE file.
*/
-#include "SkBitmapSource.h"
+#include "SkImageSource.h"
+#include "SkSurface.h"
#include "SkTileImageFilter.h"
#include "gm.h"
-static void create_circle_texture(SkBitmap* bm, SkColor color) {
- SkCanvas canvas(*bm);
- canvas.clear(0xFF000000);
+static SkImage* create_circle_texture(int size, SkColor color) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(size, size));
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->clear(0xFF000000);
SkPaint paint;
paint.setColor(color);
paint.setStrokeWidth(3);
paint.setStyle(SkPaint::kStroke_Style);
- canvas.drawCircle(SkScalarHalf(bm->width()), SkScalarHalf(bm->height()),
- SkScalarHalf(bm->width()), paint);
+ canvas->drawCircle(SkScalarHalf(size), SkScalarHalf(size), SkScalarHalf(size), paint);
+
+ return surface->newImageSnapshot();
}
namespace skiagm {
@@ -41,11 +44,8 @@ protected:
}
void onOnceBeforeDraw() override {
- fRedBitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
- create_circle_texture(&fRedBitmap, SK_ColorRED);
-
- fGreenBitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
- create_circle_texture(&fGreenBitmap, SK_ColorGREEN);
+ fRedImage.reset(create_circle_texture(kBitmapSize, SK_ColorRED));
+ fGreenImage.reset(create_circle_texture(kBitmapSize, SK_ColorGREEN));
}
void onDraw(SkCanvas* canvas) override {
@@ -55,11 +55,11 @@ protected:
SkPaint p;
SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
- SkAutoTUnref<SkBitmapSource> bms(SkBitmapSource::Create(fRedBitmap));
+ SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fRedImage));
SkAutoTUnref<SkTileImageFilter> tif(SkTileImageFilter::Create(
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)),
- bms));
+ imageSource));
p.setImageFilter(tif);
canvas->saveLayer(&bound, &p);
@@ -84,8 +84,8 @@ protected:
SkRect bound3 = SkRect::MakeXYWH(320, 320,
SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize));
- canvas->drawBitmapRect(fGreenBitmap, bound2, bound3, nullptr,
- SkCanvas::kStrict_SrcRectConstraint);
+ canvas->drawImageRect(fGreenImage, bound2, bound3, nullptr,
+ SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
}
}
@@ -95,8 +95,8 @@ private:
static const int kHeight = 512;
static const int kBitmapSize = 64;
- SkBitmap fRedBitmap;
- SkBitmap fGreenBitmap;
+ SkAutoTUnref<SkImage> fRedImage;
+ SkAutoTUnref<SkImage> fGreenImage;
typedef GM INHERITED;
};
« no previous file with comments | « bench/LightingBench.cpp ('k') | gm/bitmapsource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698