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

Unified Diff: gm/lcdtext.cpp

Issue 741433003: Add an image filter row to GM:lcdtextprops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/lcdtext.cpp
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp
index 3fe9fa2fbc179c5f8e504aa7a6dd0b2fa9b0504f..61bf9fedc1f882de081114ef7ff32d7961e07135 100644
--- a/gm/lcdtext.cpp
+++ b/gm/lcdtext.cpp
@@ -12,6 +12,10 @@
#include "gm.h"
#include "SkCanvas.h"
+#include "SkPicture.h"
+#include "SkPictureImageFilter.h"
+#include "SkPictureRecorder.h"
+
class LcdTextGM : public skiagm::GM {
public:
LcdTextGM() {
@@ -137,6 +141,17 @@ class LcdTextProps : public skiagm::GM {
canvas->restore();
}
+ static SkSurface* MakeSurface(SkCanvas* canvas, const SkImageInfo& info, SkPixelGeometry geo) {
+ SkSurfaceProps props = SkSurfaceProps(0, geo);
+ SkSurface* surface = canvas->newSurface(info, &props);
+
+ if (!surface) {
+ surface = SkSurface::NewRaster(info, &props);
+ }
+
+ return surface;
+ }
+
protected:
SkString onShortName() SK_OVERRIDE {
return SkString("lcdtextprops");
@@ -155,15 +170,29 @@ protected:
};
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
+ SkPictureRecorder recorder;
reed1 2014/11/19 16:39:24 maybe we can move this building-the-paint into the
f(malita) 2014/11/19 17:08:59 Done.
+ DrawText(recorder.beginRecording(SkIntToScalar(info.width()),
+ SkIntToScalar(info.height())));
+ SkAutoTUnref<SkPicture> pic(recorder.endRecording());
+ SkAutoTUnref<SkImageFilter> filter(SkPictureImageFilter::Create(pic.get()));
+ SkPaint filterPaint;
+ filterPaint.setImageFilter(filter.get());
+
for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) {
- SkSurfaceProps props = SkSurfaceProps(0, geos[i]);
- SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props));
- if (!surf) {
- surf.reset(SkSurface::NewRaster(info, &props));
- }
+ SkAutoTUnref<SkSurface> surf(MakeSurface(canvas, info, geos[i]));
DrawText(surf->getCanvas());
surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL);
}
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) {
+ SkAutoTUnref<SkSurface> surf(MakeSurface(canvas, info, geos[i]));
+ surf->getCanvas()->saveLayer(NULL, &filterPaint);
+ surf->getCanvas()->restore();
+ surf->draw(canvas,
+ SkIntToScalar(i * (info.width() + 10)),
+ SkIntToScalar(info.height() + 10),
+ NULL);
+ }
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698