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

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

Issue 1170553002: Apply coverage in XP base class when using dst reads (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: names Created 5 years, 6 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/GrCustomXfermode.cpp ('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 /** 14 /**
15 * This xfer processor disables color writing. Thus color and coverage and ignor ed and no blending 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. 16 * occurs. This XP is usful for things like stenciling.
17 */ 17 */
18 class DisableColorXP : public GrXferProcessor { 18 class DisableColorXP : public GrXferProcessor {
19 public: 19 public:
20 static GrXferProcessor* Create() { 20 static GrXferProcessor* Create() {
21 return SkNEW(DisableColorXP); 21 return SkNEW(DisableColorXP);
22 } 22 }
23 23
24 ~DisableColorXP() override {}; 24 ~DisableColorXP() override {};
25 25
26 const char* name() const override { return "Disable Color"; } 26 const char* name() const override { return "Disable Color"; }
27 27
28 GrGLXferProcessor* createGLInstance() const override; 28 GrGLXferProcessor* createGLInstance() const override;
29 29
30 bool hasSecondaryOutput() const override { return false; }
31
32 private: 30 private:
33 DisableColorXP(); 31 DisableColorXP();
34 32
35 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, 33 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
36 const GrProcOptInfo& coveragePO I, 34 const GrProcOptInfo& coveragePO I,
37 bool doesStencilWrite, 35 bool doesStencilWrite,
38 GrColor* color, 36 GrColor* color,
39 const GrCaps& caps) override { 37 const GrCaps& caps) override {
40 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC overage_OptFlag; 38 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC overage_OptFlag;
41 } 39 }
(...skipping 13 matching lines...) Expand all
55 53
56 class GLDisableColorXP : public GrGLXferProcessor { 54 class GLDisableColorXP : public GrGLXferProcessor {
57 public: 55 public:
58 GLDisableColorXP(const GrProcessor&) {} 56 GLDisableColorXP(const GrProcessor&) {}
59 57
60 ~GLDisableColorXP() override {} 58 ~GLDisableColorXP() override {}
61 59
62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der*) {} 60 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der*) {}
63 61
64 private: 62 private:
65 void onEmitCode(const EmitArgs& args) override { 63 void emitOutputsForBlendState(const EmitArgs& args) override {
66 // This emit code should be empty. However, on the nexus 6 there is a dr iver bug where if 64 // This emit code should be empty. However, on the nexus 6 there is a dr iver bug where if
67 // you do not give gl_FragColor a value, the gl context is lost and we e nd up drawing 65 // you do not give gl_FragColor a value, the gl context is lost and we e nd up drawing
68 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. 66 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0.
69 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 67 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
70 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); 68 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
71 } 69 }
72 70
73 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {} 71 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {}
74 72
75 typedef GrGLXferProcessor INHERITED; 73 typedef GrGLXferProcessor INHERITED;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 107
110 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); 108 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);
111 109
112 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, 110 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random,
113 GrContext*, 111 GrContext*,
114 const GrCaps&, 112 const GrCaps&,
115 GrTexture*[]) { 113 GrTexture*[]) {
116 return GrDisableColorXPFactory::Create(); 114 return GrDisableColorXPFactory::Create();
117 } 115 }
118 116
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698