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

Side by Side Diff: gm/dcshader.cpp

Issue 1316513002: Change SkShader;asFragmentProcessor signature to no longer take skpaint\grcolor* (Closed) Base URL: https://skia.googlesource.com/skia.git@things
Patch Set: Address comments, fix roll(?) Created 5 years, 3 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 | gyp/gpu.gypi » ('j') | 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 "effects/GrExtractAlphaFragmentProcessor.h"
13 #include "gl/GrGLProcessor.h" 14 #include "gl/GrGLProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 15 #include "gl/builders/GrGLProgramBuilder.h"
15 #include "Resources.h" 16 #include "Resources.h"
16 #include "SkReadBuffer.h" 17 #include "SkReadBuffer.h"
17 #include "SkShader.h" 18 #include "SkShader.h"
18 #include "SkStream.h" 19 #include "SkStream.h"
19 #include "SkTypeface.h" 20 #include "SkTypeface.h"
20 #include "SkWriteBuffer.h" 21 #include "SkWriteBuffer.h"
21 22
22 namespace skiagm { 23 namespace skiagm {
23 24
24 /////////////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////////////
25 26
26 class DCShader : public SkShader { 27 class DCShader : public SkShader {
27 public: 28 public:
28 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} 29 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {}
29 30
30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader); 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader);
31 32
32 void flatten(SkWriteBuffer& buf) const override { 33 void flatten(SkWriteBuffer& buf) const override {
33 buf.writeMatrix(fDeviceMatrix); 34 buf.writeMatrix(fDeviceMatrix);
34 } 35 }
35 36
36 bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& v iewM, 37 const GrFragmentProcessor* asFragmentProcessor(GrContext*,
37 const SkMatrix* localMatrix, GrColor* color, GrProc essorDataManager*, 38 const SkMatrix& viewM,
38 GrFragmentProcessor** fp) const override; 39 const SkMatrix* localMatrix,
40 SkFilterQuality,
41 GrProcessorDataManager*) cons t override;
39 42
40 #ifndef SK_IGNORE_TO_STRING 43 #ifndef SK_IGNORE_TO_STRING
41 void toString(SkString* str) const override { 44 void toString(SkString* str) const override {
42 str->appendf("DCShader: ()"); 45 str->appendf("DCShader: ()");
43 } 46 }
44 #endif 47 #endif
45 48
46 private: 49 private:
47 const SkMatrix fDeviceMatrix; 50 const SkMatrix fDeviceMatrix;
48 }; 51 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 90
88 private: 91 private:
89 void onGetGLProcessorKey(const GrGLSLCaps& caps, 92 void onGetGLProcessorKey(const GrGLSLCaps& caps,
90 GrProcessorKeyBuilder* b) const override {} 93 GrProcessorKeyBuilder* b) const override {}
91 94
92 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 95 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
93 96
94 GrCoordTransform fDeviceTransform; 97 GrCoordTransform fDeviceTransform;
95 }; 98 };
96 99
97 bool DCShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMat rix& viewM, 100 const GrFragmentProcessor* DCShader::asFragmentProcessor(
98 const SkMatrix* localMatrix, GrColor* color, 101 GrContext*,
99 GrProcessorDataManager* procDataManager, 102 const SkMatrix& viewM,
100 GrFragmentProcessor** fp) const { 103 const SkMatrix* localMatrix,
101 *fp = new DCFP(procDataManager, fDeviceMatrix); 104 SkFilterQuality,
102 *color = GrColorPackA4(paint.getAlpha()); 105 GrProcessorDataManager* procDat aManager) const {
103 return true; 106 SkAutoTUnref<const GrFragmentProcessor> inner(new DCFP(procDataManager, fDev iceMatrix));
107 return GrExtractAlphaFragmentProcessor::Create(inner);
104 } 108 }
105 109
106 class DCShaderGM : public GM { 110 class DCShaderGM : public GM {
107 public: 111 public:
108 DCShaderGM() { 112 DCShaderGM() {
109 this->setBGColor(sk_tool_utils::color_to_565(0xFFAABBCC)); 113 this->setBGColor(sk_tool_utils::color_to_565(0xFFAABBCC));
110 } 114 }
111 115
112 ~DCShaderGM() override { 116 ~DCShaderGM() override {
113 for (int i = 0; i < fPrims.count(); ++i) { 117 for (int i = 0; i < fPrims.count(); ++i) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 }; 291 };
288 292
289 SkTArray<Prim*> fPrims; 293 SkTArray<Prim*> fPrims;
290 294
291 typedef GM INHERITED; 295 typedef GM INHERITED;
292 }; 296 };
293 297
294 DEF_GM(return new DCShaderGM;) 298 DEF_GM(return new DCShaderGM;)
295 } 299 }
296 #endif 300 #endif
OLDNEW
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698