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

Side by Side Diff: src/gpu/effects/GrDisableColorXP.cpp

Issue 860383007: Move GrXferProcessor subclasses into cpp files (Closed) Base URL: https://skia.googlesource.com/skia.git@playDstCpy
Patch Set: Rebase Created 5 years, 10 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 | « src/gpu/effects/GrDisableColorXP.h ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "effects/GrDisableColorXP.h" 8 #include "effects/GrDisableColorXP.h"
9 #include "GrProcessor.h" 9 #include "GrProcessor.h"
10 #include "gl/GrGLXferProcessor.h" 10 #include "gl/GrGLXferProcessor.h"
11 #include "gl/builders/GrGLFragmentShaderBuilder.h" 11 #include "gl/builders/GrGLFragmentShaderBuilder.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "gl/builders/GrGLProgramBuilder.h"
13 13
14 class GrGLDisableColorXP : public GrGLXferProcessor { 14 /**
15 * This xfer processor disables color writing. Thus color and coverage and ignor ed and no blending
16 * occurs. This XP is usful for things like stenciling.
17 */
18 class DisableColorXP : public GrXferProcessor {
15 public: 19 public:
16 GrGLDisableColorXP(const GrProcessor&) {} 20 static GrXferProcessor* Create() {
21 return SkNEW(DisableColorXP);
22 }
17 23
18 ~GrGLDisableColorXP() SK_OVERRIDE {} 24 ~DisableColorXP() SK_OVERRIDE {};
25
26 const char* name() const SK_OVERRIDE { return "Disable Color"; }
27
28 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
29
30 bool hasSecondaryOutput() const SK_OVERRIDE { return false; }
31
32 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
33 const GrProcOptInfo& coveragePOI,
34 bool doesStencilWrite,
35 GrColor* color,
36 const GrDrawTargetCaps& caps) SK_ OVERRIDE {
37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC overage_OptFlag;
38 }
39
40 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE;
41
42 private:
43 DisableColorXP();
44
45 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con st SK_OVERRIDE;
46
47 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE {
48 return true;
49 }
50
51 typedef GrXferProcessor INHERITED;
52 };
53
54 ///////////////////////////////////////////////////////////////////////////////
55
56 class GLDisableColorXP : public GrGLXferProcessor {
57 public:
58 GLDisableColorXP(const GrProcessor&) {}
59
60 ~GLDisableColorXP() SK_OVERRIDE {}
19 61
20 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde r*) {} 62 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde r*) {}
21 63
22 private: 64 private:
23 void onEmitCode(const EmitArgs& args) SK_OVERRIDE { 65 void onEmitCode(const EmitArgs& args) SK_OVERRIDE {
24 // This emit code should be empty. However, on the nexus 6 there is a dr iver bug where if 66 // This emit code should be empty. However, on the nexus 6 there is a dr iver bug where if
25 // you do not give gl_FragColor a value, the gl context is lost and we e nd up drawing 67 // you do not give gl_FragColor a value, the gl context is lost and we e nd up drawing
26 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. 68 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0.
27 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 69 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
28 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); 70 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
29 } 71 }
30 72
31 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE RRIDE {} 73 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE RRIDE {}
32 74
33 typedef GrGLXferProcessor INHERITED; 75 typedef GrGLXferProcessor INHERITED;
34 }; 76 };
35 77
36 /////////////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////////////
37 79
38 GrDisableColorXP::GrDisableColorXP() { 80 DisableColorXP::DisableColorXP() {
39 this->initClassID<GrDisableColorXP>(); 81 this->initClassID<DisableColorXP>();
40 } 82 }
41 83
42 void GrDisableColorXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyB uilder* b) const { 84 void DisableColorXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBui lder* b) const {
43 GrGLDisableColorXP::GenKey(*this, caps, b); 85 GLDisableColorXP::GenKey(*this, caps, b);
44 } 86 }
45 87
46 GrGLXferProcessor* GrDisableColorXP::createGLInstance() const { 88 GrGLXferProcessor* DisableColorXP::createGLInstance() const {
47 return SkNEW_ARGS(GrGLDisableColorXP, (*this)); 89 return SkNEW_ARGS(GLDisableColorXP, (*this));
48 } 90 }
49 91
50 void GrDisableColorXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const { 92 void DisableColorXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
51 blendInfo->fWriteColor = false; 93 blendInfo->fWriteColor = false;
52 } 94 }
53 95
54 /////////////////////////////////////////////////////////////////////////////// 96 ///////////////////////////////////////////////////////////////////////////////
55 97
56 GrDisableColorXPFactory::GrDisableColorXPFactory() { 98 GrDisableColorXPFactory::GrDisableColorXPFactory() {
57 this->initClassID<GrDisableColorXPFactory>(); 99 this->initClassID<GrDisableColorXPFactory>();
58 } 100 }
59 101
60 GrXferProcessor* 102 GrXferProcessor*
61 GrDisableColorXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI, 103 GrDisableColorXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI,
62 const GrProcOptInfo& covPOI, 104 const GrProcOptInfo& covPOI,
63 const GrDeviceCoordTexture* dstCo py) const { 105 const GrDeviceCoordTexture* dstCo py) const {
64 return GrDisableColorXP::Create(); 106 return DisableColorXP::Create();
65 } 107 }
66 108
67 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); 109 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);
68 110
69 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, 111 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random,
70 GrContext*, 112 GrContext*,
71 const GrDrawTargetCaps&, 113 const GrDrawTargetCaps&,
72 GrTexture*[]) { 114 GrTexture*[]) {
73 return GrDisableColorXPFactory::Create(); 115 return GrDisableColorXPFactory::Create();
74 } 116 }
75 117
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.h ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698