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

Unified Diff: src/core/SkRemote.cpp

Issue 1417703003: SkRemote: shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « src/core/SkRemote.h ('k') | src/core/SkRemote_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRemote.cpp
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp
index 8efeb8b8451f766dacc295c0d487e427fad741ea..7c662d323343e90798f79c8a9a495825fd09448c 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);
}
« no previous file with comments | « src/core/SkRemote.h ('k') | src/core/SkRemote_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698