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

Unified Diff: gm/dcshader.cpp

Issue 816403007: Make DCShader serializable. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nl Created 5 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/dcshader.cpp
diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp
index 1871e4daab4f2731cbf4e26d80f2c4d958338b66..9e9a2c27ad15a65e781fea307c6647b1eb560292 100644
--- a/gm/dcshader.cpp
+++ b/gm/dcshader.cpp
@@ -13,9 +13,11 @@
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "Resources.h"
+#include "SkReadBuffer.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTypeface.h"
+#include "SkWriteBuffer.h"
namespace skiagm {
@@ -25,10 +27,11 @@ class DCShader : public SkShader {
public:
DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {}
- // This is a custom shader, so we don't need to make it
- // flattenable. Since this class is not part of the skia library,
- // it wouldn't deserialize without linking this library anyway.
- SK_DECLARE_NOT_FLATTENABLE_PROCS(DCShader)
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader);
+
+ void flatten(SkWriteBuffer& buf) const SK_OVERRIDE {
+ buf.writeMatrix(fDeviceMatrix);
+ }
bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
const SkMatrix* localMatrix, GrColor* color,
@@ -37,6 +40,12 @@ private:
const SkMatrix fDeviceMatrix;
};
+SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) {
+ SkMatrix matrix;
+ buf.readMatrix(&matrix);
+ return SkNEW_ARGS(DCShader, (matrix));
+}
+
class DCFP : public GrFragmentProcessor {
public:
DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698