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

Unified Diff: gm/imagefiltersgraph.cpp

Issue 498453003: use globals to register custom effects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/imagefiltersbase.cpp ('k') | no next file » | 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 bd6af3ff20fb9c1bba50b6fc0db29d54cafdac2d..37ed885dd731fc7989247d1a91b7dfb2ad8033b9 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -25,6 +25,18 @@
// perform a draw and this one does.
class SimpleOffsetFilter : public SkImageFilter {
public:
+ class Registrar {
+ public:
+ Registrar() {
+ SkFlattenable::Register("SimpleOffsetFilter",
+#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
+ SimpleOffsetFilter::DeepCreateProc,
+#else
+ SimpleOffsetFilter::CreateProc,
+#endif
+ SimpleOffsetFilter::GetFlattenableType());
+ }
+ };
static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input) {
return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input));
}
@@ -73,20 +85,15 @@ protected:
private:
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
- : SkImageFilter(1, &input), fDX(dx), fDY(dy) {
- static bool gOnce;
- if (!gOnce) {
- gOnce = true;
- SkFlattenable::Register("SimpleOffsetFilter", this->getFactory(),
- this->GetFlattenableType());
- }
- }
+ : SkImageFilter(1, &input), fDX(dx), fDY(dy) {}
SkScalar fDX, fDY;
typedef SkImageFilter INHERITED;
};
+static SimpleOffsetFilter::Registrar gReg;
+
SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar dx = buffer.readScalar();
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698