diff options
author | mtklein <mtklein@chromium.org> | 2015-01-07 08:02:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-07 08:02:28 -0800 |
commit | 36a364a846dd5cee382069430f376286fe6c3af5 (patch) | |
tree | d66d7e69697602a081dc644dd1bbb27b4516aa13 | |
parent | ac8d8b8f13aaf8e63884029c9016eae7cf463534 (diff) |
Make DCShader serializable.
This allows a test pipeline like dcshader GM -> pipe -> gpu backend.
BUG=skia:
Review URL: https://codereview.chromium.org/816403007
-rw-r--r-- | gm/dcshader.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp index 1871e4daab..9e9a2c27ad 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) { |