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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/GrTextureDomain.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('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 "GrYUVtoRGBEffect.h" 8 #include "GrYUVtoRGBEffect.h"
9 9
10 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
(...skipping 26 matching lines...) Expand all
37 ((sizes[1].fWidth != sizes[0].fWidth) || 37 ((sizes[1].fWidth != sizes[0].fWidth) ||
38 (sizes[1].fHeight != sizes[0].fHeight) || 38 (sizes[1].fHeight != sizes[0].fHeight) ||
39 (sizes[2].fWidth != sizes[0].fWidth) || 39 (sizes[2].fWidth != sizes[0].fWidth) ||
40 (sizes[2].fHeight != sizes[0].fHeight)) ? 40 (sizes[2].fHeight != sizes[0].fHeight)) ?
41 GrTextureParams::kBilerp_FilterMode : 41 GrTextureParams::kBilerp_FilterMode :
42 GrTextureParams::kNone_FilterMode; 42 GrTextureParams::kNone_FilterMode;
43 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatr ix, 43 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatr ix,
44 uvFilterMode, colorSpace)); 44 uvFilterMode, colorSpace));
45 } 45 }
46 46
47 const char* name() const SK_OVERRIDE { return "YUV to RGB"; } 47 const char* name() const override { return "YUV to RGB"; }
48 48
49 SkYUVColorSpace getColorSpace() const { 49 SkYUVColorSpace getColorSpace() const {
50 return fColorSpace; 50 return fColorSpace;
51 } 51 }
52 52
53 class GLProcessor : public GrGLFragmentProcessor { 53 class GLProcessor : public GrGLFragmentProcessor {
54 public: 54 public:
55 static const GrGLfloat kJPEGConversionMatrix[16]; 55 static const GrGLfloat kJPEGConversionMatrix[16];
56 static const GrGLfloat kRec601ConversionMatrix[16]; 56 static const GrGLfloat kRec601ConversionMatrix[16];
57 57
58 // this class always generates the same code. 58 // this class always generates the same code.
59 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder*) {} 59 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder*) {}
60 60
61 GLProcessor(const GrProcessor&) {} 61 GLProcessor(const GrProcessor&) {}
62 62
63 virtual void emitCode(GrGLFPBuilder* builder, 63 virtual void emitCode(GrGLFPBuilder* builder,
64 const GrFragmentProcessor&, 64 const GrFragmentProcessor&,
65 const char* outputColor, 65 const char* outputColor,
66 const char* inputColor, 66 const char* inputColor,
67 const TransformedCoordsArray& coords, 67 const TransformedCoordsArray& coords,
68 const TextureSamplerArray& samplers) SK_OVERRIDE { 68 const TextureSamplerArray& samplers) override {
69 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 69 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
70 70
71 const char* yuvMatrix = NULL; 71 const char* yuvMatrix = NULL;
72 fMatrixUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility, 72 fMatrixUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility,
73 kMat44f_GrSLType, kDefault_GrSLPrec ision, 73 kMat44f_GrSLType, kDefault_GrSLPrec ision,
74 "YUVMatrix", &yuvMatrix); 74 "YUVMatrix", &yuvMatrix);
75 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor); 75 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor);
76 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord s[0].getType()); 76 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord s[0].getType());
77 fsBuilder->codeAppend(".r,\n\t\t"); 77 fsBuilder->codeAppend(".r,\n\t\t");
78 fsBuilder->appendTextureLookup(samplers[1], coords[1].c_str(), coord s[1].getType()); 78 fsBuilder->appendTextureLookup(samplers[1], coords[1].c_str(), coord s[1].getType());
79 fsBuilder->codeAppend(".r,\n\t\t"); 79 fsBuilder->codeAppend(".r,\n\t\t");
80 fsBuilder->appendTextureLookup(samplers[2], coords[2].c_str(), coord s[2].getType()); 80 fsBuilder->appendTextureLookup(samplers[2], coords[2].c_str(), coord s[2].getType());
81 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); 81 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix);
82 } 82 }
83 83
84 virtual void setData(const GrGLProgramDataManager& pdman, 84 virtual void setData(const GrGLProgramDataManager& pdman,
85 const GrProcessor& processor) SK_OVERRIDE { 85 const GrProcessor& processor) override {
86 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); 86 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
87 switch (yuvEffect.getColorSpace()) { 87 switch (yuvEffect.getColorSpace()) {
88 case kJPEG_SkYUVColorSpace: 88 case kJPEG_SkYUVColorSpace:
89 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); 89 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix);
90 break; 90 break;
91 case kRec601_SkYUVColorSpace: 91 case kRec601_SkYUVColorSpace:
92 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix); 92 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix);
93 break; 93 break;
94 } 94 }
95 } 95 }
96 96
97 private: 97 private:
98 GrGLProgramDataManager::UniformHandle fMatrixUni; 98 GrGLProgramDataManager::UniformHandle fMatrixUni;
99 99
100 typedef GrGLFragmentProcessor INHERITED; 100 typedef GrGLFragmentProcessor INHERITED;
101 }; 101 };
102 102
103 virtual void getGLProcessorKey(const GrGLCaps& caps, 103 virtual void getGLProcessorKey(const GrGLCaps& caps,
104 GrProcessorKeyBuilder* b) const SK_OVERRIDE { 104 GrProcessorKeyBuilder* b) const override {
105 GLProcessor::GenKey(*this, caps, b); 105 GLProcessor::GenKey(*this, caps, b);
106 } 106 }
107 107
108 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { 108 GrGLFragmentProcessor* createGLInstance() const override {
109 return SkNEW_ARGS(GLProcessor, (*this)); 109 return SkNEW_ARGS(GLProcessor, (*this));
110 } 110 }
111 111
112 private: 112 private:
113 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture , 113 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ,
114 SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMo de, 114 SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMo de,
115 SkYUVColorSpace colorSpace) 115 SkYUVColorSpace colorSpace)
116 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode) 116 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode)
117 , fYAccess(yTexture) 117 , fYAccess(yTexture)
118 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) 118 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode)
119 , fUAccess(uTexture, uvFilterMode) 119 , fUAccess(uTexture, uvFilterMode)
120 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) 120 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode)
121 , fVAccess(vTexture, uvFilterMode) 121 , fVAccess(vTexture, uvFilterMode)
122 , fColorSpace(colorSpace) { 122 , fColorSpace(colorSpace) {
123 this->initClassID<YUVtoRGBEffect>(); 123 this->initClassID<YUVtoRGBEffect>();
124 this->addCoordTransform(&fYTransform); 124 this->addCoordTransform(&fYTransform);
125 this->addTextureAccess(&fYAccess); 125 this->addTextureAccess(&fYAccess);
126 this->addCoordTransform(&fUTransform); 126 this->addCoordTransform(&fUTransform);
127 this->addTextureAccess(&fUAccess); 127 this->addTextureAccess(&fUAccess);
128 this->addCoordTransform(&fVTransform); 128 this->addCoordTransform(&fVTransform);
129 this->addTextureAccess(&fVAccess); 129 this->addTextureAccess(&fVAccess);
130 } 130 }
131 131
132 bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE { 132 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
133 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); 133 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>();
134 return fColorSpace == s.getColorSpace(); 134 return fColorSpace == s.getColorSpace();
135 } 135 }
136 136
137 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { 137 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
138 // YUV is opaque 138 // YUV is opaque
139 inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A, 139 inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A,
140 GrInvariantOutput::kWillNot_ReadInput); 140 GrInvariantOutput::kWillNot_ReadInput);
141 } 141 }
142 142
143 GrCoordTransform fYTransform; 143 GrCoordTransform fYTransform;
144 GrTextureAccess fYAccess; 144 GrTextureAccess fYAccess;
145 GrCoordTransform fUTransform; 145 GrCoordTransform fUTransform;
146 GrTextureAccess fUAccess; 146 GrTextureAccess fUAccess;
147 GrCoordTransform fVTransform; 147 GrCoordTransform fVTransform;
(...skipping 16 matching lines...) Expand all
164 } 164 }
165 165
166 ////////////////////////////////////////////////////////////////////////////// 166 //////////////////////////////////////////////////////////////////////////////
167 167
168 GrFragmentProcessor* 168 GrFragmentProcessor*
169 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture, 169 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
170 SkISize sizes[3], SkYUVColorSpace colorSpace) { 170 SkISize sizes[3], SkYUVColorSpace colorSpace) {
171 SkASSERT(yTexture && uTexture && vTexture && sizes); 171 SkASSERT(yTexture && uTexture && vTexture && sizes);
172 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e); 172 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e);
173 } 173 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698