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

Unified Diff: gm/imagealphathreshold.cpp

Issue 115633002: Add AlphaThreshold filter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 7 years 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/effects.gypi » ('j') | include/effects/SkAlphaThresholdFilter.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagealphathreshold.cpp
diff --git a/gm/imagemagnifier.cpp b/gm/imagealphathreshold.cpp
similarity index 63%
copy from gm/imagemagnifier.cpp
copy to gm/imagealphathreshold.cpp
index ae639d3b538b162b64a40b5604d041ddaea5d553..307c9c8c431449ffc0af5fe54971922d9612527b 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagealphathreshold.cpp
@@ -1,12 +1,12 @@
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2013 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 "SkMagnifierImageFilter.h"
+#include "SkAlphaThresholdFilter.h"
#include "SkRandom.h"
#define WIDTH 500
@@ -14,20 +14,19 @@
namespace skiagm {
-class ImageMagnifierGM : public GM {
+class ImageAlphaThresholdGM : public GM {
public:
- ImageMagnifierGM() {
+ ImageAlphaThresholdGM() {
this->setBGColor(0xFF000000);
}
protected:
virtual uint32_t onGetFlags() const SK_OVERRIDE {
- // Skip tiled drawing until https://code.google.com/p/skia/issues/detail?id=781 is fixed.
return this->INHERITED::onGetFlags() | GM::kSkipTiled_Flag;
}
virtual SkString onShortName() SK_OVERRIDE {
- return SkString("imagemagnifier");
+ return SkString("imagealphathreshold");
}
virtual SkISize onISize() SK_OVERRIDE {
@@ -35,13 +34,19 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkIRect rects[2];
+ rects[0] = SkIRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(150),
+ SkIntToScalar(WIDTH),
+ SkIntToScalar(HEIGHT - 300));
+ rects[1] = SkIRect::MakeXYWH(SkIntToScalar(150), SkIntToScalar(0),
+ SkIntToScalar(WIDTH - 300),
+ SkIntToScalar(HEIGHT));
+ SkRegion region;
+ region.setRects(rects, 2);
Wez 2013/12/17 06:39:04 So we need to plumb through the window shape throu
Zachary Kuznia 2013/12/18 00:06:27 Yes. I have a CL in Chromium that does this; I'll
+
SkPaint paint;
paint.setImageFilter(
- new SkMagnifierImageFilter(
- SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
- SkIntToScalar(WIDTH / 2),
- SkIntToScalar(HEIGHT / 2)),
- 100))->unref();
+ new SkAlphaThresholdFilter(region, 0, .2))->unref();
canvas->saveLayer(NULL, &paint);
paint.setAntiAlias(true);
const char* str = "The quick brown fox jumped over the lazy dog.";
@@ -63,7 +68,7 @@ private:
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory(void*) { return new ImageMagnifierGM; }
+static GM* MyFactory(void*) { return new ImageAlphaThresholdGM; }
static GMRegistry reg(MyFactory);
}
« no previous file with comments | « no previous file | gyp/effects.gypi » ('j') | include/effects/SkAlphaThresholdFilter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698