diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkRemote.cpp | 29 | ||||
-rw-r--r-- | src/core/SkRemote.h | 19 | ||||
-rw-r--r-- | src/core/SkRemote_protocol.h | 1 |
3 files changed, 38 insertions, 11 deletions
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp index 8efeb8b845..7c662d3233 100644 --- a/src/core/SkRemote.cpp +++ b/src/core/SkRemote.cpp @@ -101,6 +101,7 @@ namespace SkRemote { , fNextMisc (Type::kMisc) , fNextPath (Type::kPath) , fNextStroke (Type::kStroke) + , fNextShader (Type::kShader) , fNextXfermode(Type::kXfermode) {} void cleanup(Encoder*) override {} @@ -123,6 +124,13 @@ namespace SkRemote { bool lookup(const Stroke&, ID* id, LookupScope* ls) override { return Helper(&fNextStroke, id, ls); } + bool lookup(const SkShader* shader, ID* id, LookupScope* ls) override { + if (!shader) { + *id = ID(Type::kShader); + return true; // Null IDs are always defined. + } + return Helper(&fNextShader, id, ls); + } bool lookup(const SkXfermode* xfermode, ID* id, LookupScope* ls) override { if (!xfermode) { *id = ID(Type::kXfermode); @@ -135,6 +143,7 @@ namespace SkRemote { fNextMisc, fNextPath, fNextStroke, + fNextShader, fNextXfermode; }; return new NeverCache; @@ -197,6 +206,7 @@ namespace SkRemote { , fNextMisc (Type::kMisc) , fNextPath (Type::kPath) , fNextStroke (Type::kStroke) + , fNextShader (Type::kShader) , fNextXfermode(Type::kXfermode) {} @@ -206,6 +216,7 @@ namespace SkRemote { fMisc .foreach(undef); fPath .foreach(undef); fStroke .foreach(undef); + fShader .foreach(undef); fXfermode.foreach(undef); } @@ -222,6 +233,9 @@ namespace SkRemote { bool lookup(const Stroke& stroke, ID* id, LookupScope*) override { return always_cache_lookup(stroke, &fStroke, &fNextStroke, id); } + bool lookup(const SkShader* shader, ID* id, LookupScope*) override { + return always_cache_lookup(shader, &fShader, &fNextShader, id); + } bool lookup(const SkXfermode* xfermode, ID* id, LookupScope*) override { return always_cache_lookup(xfermode, &fXfermode, &fNextXfermode, id); } @@ -230,12 +244,14 @@ namespace SkRemote { SkTHashMap<Misc, ID, MiscHash> fMisc; SkTHashMap<SkPath, ID> fPath; SkTHashMap<Stroke, ID> fStroke; + RefKeyMap<SkShader, Type::kShader> fShader; RefKeyMap<SkXfermode, Type::kXfermode> fXfermode; ID fNextMatrix, fNextMisc, fNextPath, fNextStroke, + fNextShader, fNextXfermode; }; return new AlwaysCache; @@ -293,13 +309,14 @@ namespace SkRemote { LookupScope ls(fCache, fEncoder); ID p = ls.lookup(path), m = ls.lookup(Misc::CreateFrom(paint)), + s = ls.lookup(paint.getShader()), x = ls.lookup(paint.getXfermode()); if (paint.getStyle() == SkPaint::kFill_Style) { - fEncoder->fillPath(p, m, x); + fEncoder->fillPath(p, m, s, x); } else { // TODO: handle kStrokeAndFill_Style - fEncoder->strokePath(p, m, x, ls.lookup(Stroke::CreateFrom(paint))); + fEncoder->strokePath(p, m, s, x, ls.lookup(Stroke::CreateFrom(paint))); } } @@ -363,6 +380,7 @@ namespace SkRemote { void Server::define(ID id, const Misc& v) { fMisc .set(id, v); } void Server::define(ID id, const SkPath& v) { fPath .set(id, v); } void Server::define(ID id, const Stroke& v) { fStroke .set(id, v); } + void Server::define(ID id, SkShader* v) { fShader .set(id, v); } void Server::define(ID id, SkXfermode* v) { fXfermode.set(id, v); } void Server::undefine(ID id) { @@ -371,6 +389,7 @@ namespace SkRemote { case Type::kMisc: return fMisc .remove(id); case Type::kPath: return fPath .remove(id); case Type::kStroke: return fStroke .remove(id); + case Type::kShader: return fShader .remove(id); case Type::kXfermode: return fXfermode.remove(id); case Type::kNone: SkASSERT(false); @@ -385,18 +404,20 @@ namespace SkRemote { void Server::clipPath(ID path, SkRegion::Op op, bool aa) { fCanvas->clipPath(fPath.find(path), op, aa); } - void Server::fillPath(ID path, ID misc, ID xfermode) { + void Server::fillPath(ID path, ID misc, ID shader, ID xfermode) { SkPaint paint; paint.setStyle(SkPaint::kFill_Style); fMisc.find(misc).applyTo(&paint); + paint.setShader (fShader .find(shader)); paint.setXfermode(fXfermode.find(xfermode)); fCanvas->drawPath(fPath.find(path), paint); } - void Server::strokePath(ID path, ID misc, ID xfermode, ID stroke) { + void Server::strokePath(ID path, ID misc, ID shader, ID xfermode, ID stroke) { SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); fMisc .find(misc ).applyTo(&paint); fStroke.find(stroke).applyTo(&paint); + paint.setShader (fShader .find(shader)); paint.setXfermode(fXfermode.find(xfermode)); fCanvas->drawPath(fPath.find(path), paint); } diff --git a/src/core/SkRemote.h b/src/core/SkRemote.h index ed99c0f866..6e95f3a158 100644 --- a/src/core/SkRemote.h +++ b/src/core/SkRemote.h @@ -11,6 +11,7 @@ #include "SkCanvas.h" #include "SkPaint.h" #include "SkRemote_protocol.h" +#include "SkShader.h" #include "SkTHash.h" #include "SkTypes.h" @@ -45,6 +46,7 @@ namespace SkRemote { virtual void define(ID, const Misc&) = 0; virtual void define(ID, const SkPath&) = 0; virtual void define(ID, const Stroke&) = 0; + virtual void define(ID, SkShader*) = 0; virtual void define(ID, SkXfermode*) = 0; virtual void undefine(ID) = 0; @@ -54,12 +56,12 @@ namespace SkRemote { virtual void setMatrix(ID matrix) = 0; - // TODO: struct CommonIDs { ID misc; ID xfermode; ... } + // TODO: struct CommonIDs { ID misc, shader, xfermode; ... } // for IDs that affect both fill + stroke? - virtual void clipPath(ID path, SkRegion::Op, bool aa) = 0; - virtual void fillPath(ID path, ID misc, ID xfermode) = 0; - virtual void strokePath(ID path, ID misc, ID xfermode, ID stroke) = 0; + virtual void clipPath(ID path, SkRegion::Op, bool aa) = 0; + virtual void fillPath(ID path, ID misc, ID shader, ID xfermode) = 0; + virtual void strokePath(ID path, ID misc, ID shader, ID xfermode, ID stroke) = 0; }; class LookupScope; @@ -84,6 +86,7 @@ namespace SkRemote { virtual bool lookup(const Misc&, ID*, LookupScope*) = 0; virtual bool lookup(const SkPath&, ID*, LookupScope*) = 0; virtual bool lookup(const Stroke&, ID*, LookupScope*) = 0; + virtual bool lookup(const SkShader*, ID*, LookupScope*) = 0; virtual bool lookup(const SkXfermode*, ID*, LookupScope*) = 0; virtual void cleanup(Encoder*) = 0; @@ -134,6 +137,7 @@ namespace SkRemote { void define(ID, const Misc&) override; void define(ID, const SkPath&) override; void define(ID, const Stroke&) override; + void define(ID, SkShader*) override; void define(ID, SkXfermode*) override; void undefine(ID) override; @@ -143,9 +147,9 @@ namespace SkRemote { void setMatrix(ID matrix) override; - void clipPath(ID path, SkRegion::Op, bool aa) override; - void fillPath(ID path, ID misc, ID xfermode) override; - void strokePath(ID path, ID misc, ID xfermode, ID stroke) override; + void clipPath(ID path, SkRegion::Op, bool aa) override; + void fillPath(ID path, ID misc, ID shader, ID xfermode) override; + void strokePath(ID path, ID misc, ID shader, ID xfermode, ID stroke) override; // Maps ID -> T. template <typename T, Type kType> @@ -218,6 +222,7 @@ namespace SkRemote { IDMap<Misc , Type::kMisc > fMisc; IDMap<SkPath , Type::kPath > fPath; IDMap<Stroke , Type::kStroke> fStroke; + ReffedIDMap<SkShader, Type::kShader> fShader; ReffedIDMap<SkXfermode, Type::kXfermode> fXfermode; SkCanvas* fCanvas; diff --git a/src/core/SkRemote_protocol.h b/src/core/SkRemote_protocol.h index 23fa60cfc9..d34a4b6c4b 100644 --- a/src/core/SkRemote_protocol.h +++ b/src/core/SkRemote_protocol.h @@ -21,6 +21,7 @@ namespace SkRemote { kMisc, kPath, kStroke, + kShader, kXfermode, }; |