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

Side by Side Diff: gm/dcshader.cpp

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