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

Unified Diff: gm/emboss.cpp

Issue 563563002: make set3DMask virtual, so we can safely notify the shadercontext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ad gm Created 6 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 | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/emboss.cpp
diff --git a/gm/emboss.cpp b/gm/emboss.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c2ee49723fc1414d5f730f75443062f395215bca
--- /dev/null
+++ b/gm/emboss.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkBlurMaskFilter.h"
+#include "SkCanvas.h"
+#include "SkColorFilter.h"
+
+#include "SkColorFilter.h"
+static SkBitmap make_bm() {
+ SkBitmap bm;
+ bm.allocN32Pixels(100, 100);
+
+ SkCanvas canvas(bm);
+ canvas.clear(0);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ canvas.drawCircle(50, 50, 50, paint);
+ return bm;
+}
+
+class EmbossGM : public skiagm::GM {
+public:
+ EmbossGM() {
+ }
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("emboss");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(600, 120);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ SkBitmap bm = make_bm();
+ canvas->drawBitmap(bm, 10, 10, &paint);
+
+ const SkScalar dir[] = { 1, 1, 1 };
+ paint.setMaskFilter(SkBlurMaskFilter::CreateEmboss(3, dir, 0.3f, 0.1f))->unref();
+ canvas->translate(bm.width() + SkIntToScalar(10), 0);
+ canvas->drawBitmap(bm, 10, 10, &paint);
+
+ // this combination of emboss+colorfilter used to crash -- so we exercise it to
+ // confirm that we have a fix.
+ paint.setColorFilter(SkColorFilter::CreateModeFilter(0xFFFF0000, SkXfermode::kSrcATop_Mode))->unref();
+ canvas->translate(bm.width() + SkIntToScalar(10), 0);
+ canvas->drawBitmap(bm, 10, 10, &paint);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(EmbossGM); )
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698