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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "gm.h" 9 #include "gm.h"
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrFragmentProcessor.h" 11 #include "GrFragmentProcessor.h"
12 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
13 #include "gl/GrGLProcessor.h" 13 #include "gl/GrGLProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
15 #include "Resources.h" 15 #include "Resources.h"
16 #include "SkReadBuffer.h"
16 #include "SkShader.h" 17 #include "SkShader.h"
17 #include "SkStream.h" 18 #include "SkStream.h"
18 #include "SkTypeface.h" 19 #include "SkTypeface.h"
20 #include "SkWriteBuffer.h"
19 21
20 namespace skiagm { 22 namespace skiagm {
21 23
22 /////////////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////////////
23 25
24 class DCShader : public SkShader { 26 class DCShader : public SkShader {
25 public: 27 public:
26 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} 28 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {}
27 29
28 // This is a custom shader, so we don't need to make it 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader);
29 // flattenable. Since this class is not part of the skia library, 31
30 // it wouldn't deserialize without linking this library anyway. 32 void flatten(SkWriteBuffer& buf) const SK_OVERRIDE {
31 SK_DECLARE_NOT_FLATTENABLE_PROCS(DCShader) 33 buf.writeMatrix(fDeviceMatrix);
34 }
32 35
33 bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& v iewM, 36 bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& v iewM,
34 const SkMatrix* localMatrix, GrColor* color, 37 const SkMatrix* localMatrix, GrColor* color,
35 GrFragmentProcessor** fp) const SK_OVERRIDE; 38 GrFragmentProcessor** fp) const SK_OVERRIDE;
36 private: 39 private:
37 const SkMatrix fDeviceMatrix; 40 const SkMatrix fDeviceMatrix;
38 }; 41 };
39 42
43 SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) {
44 SkMatrix matrix;
45 buf.readMatrix(&matrix);
46 return SkNEW_ARGS(DCShader, (matrix));
47 }
48
40 class DCFP : public GrFragmentProcessor { 49 class DCFP : public GrFragmentProcessor {
41 public: 50 public:
42 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) { 51 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) {
43 this->addCoordTransform(&fDeviceTransform); 52 this->addCoordTransform(&fDeviceTransform);
44 this->initClassID<DCFP>(); 53 this->initClassID<DCFP>();
45 } 54 }
46 55
47 void getGLProcessorKey(const GrGLCaps& caps, 56 void getGLProcessorKey(const GrGLCaps& caps,
48 GrProcessorKeyBuilder* b) const SK_OVERRIDE {} 57 GrProcessorKeyBuilder* b) const SK_OVERRIDE {}
49 58
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 }; 301 };
293 302
294 SkTArray<Prim*> fPrims; 303 SkTArray<Prim*> fPrims;
295 304
296 typedef GM INHERITED; 305 typedef GM INHERITED;
297 }; 306 };
298 307
299 DEF_GM( return SkNEW(DCShaderGM); ) 308 DEF_GM( return SkNEW(DCShaderGM); )
300 } 309 }
301 #endif 310 #endif
OLDNEW
« 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