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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/GrXfermodeFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLFragmentProcessor.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"
11 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
12 #include "GrProcessor.h" 12 #include "GrProcessor.h"
13 #include "gl/GrGLFragmentProcessor.h" 13 #include "glsl/GrGLSLFragmentProcessor.h"
14 #include "glsl/GrGLSLFragmentShaderBuilder.h" 14 #include "glsl/GrGLSLFragmentShaderBuilder.h"
15 #include "glsl/GrGLSLProgramBuilder.h" 15 #include "glsl/GrGLSLProgramBuilder.h"
16 #include "glsl/GrGLSLProgramDataManager.h" 16 #include "glsl/GrGLSLProgramDataManager.h"
17 17
18 namespace { 18 namespace {
19 19
20 class YUVtoRGBEffect : public GrFragmentProcessor { 20 class YUVtoRGBEffect : public GrFragmentProcessor {
21 public: 21 public:
22 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture, 22 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
23 GrTexture* vTexture, const SkISize sizes[ 3], 23 GrTexture* vTexture, const SkISize sizes[ 3],
(...skipping 21 matching lines...) Expand all
45 return new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFil terMode, 45 return new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFil terMode,
46 colorSpace); 46 colorSpace);
47 } 47 }
48 48
49 const char* name() const override { return "YUV to RGB"; } 49 const char* name() const override { return "YUV to RGB"; }
50 50
51 SkYUVColorSpace getColorSpace() const { 51 SkYUVColorSpace getColorSpace() const {
52 return fColorSpace; 52 return fColorSpace;
53 } 53 }
54 54
55 class GLProcessor : public GrGLFragmentProcessor { 55 class GLProcessor : public GrGLSLFragmentProcessor {
56 public: 56 public:
57 static const float kJPEGConversionMatrix[16]; 57 static const float kJPEGConversionMatrix[16];
58 static const float kRec601ConversionMatrix[16]; 58 static const float kRec601ConversionMatrix[16];
59 static const float kRec709ConversionMatrix[16]; 59 static const float kRec709ConversionMatrix[16];
60 60
61 // this class always generates the same code. 61 // this class always generates the same code.
62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} 62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {}
63 63
64 GLProcessor(const GrProcessor&) {} 64 GLProcessor(const GrProcessor&) {}
65 65
(...skipping 29 matching lines...) Expand all
95 break; 95 break;
96 case kRec709_SkYUVColorSpace: 96 case kRec709_SkYUVColorSpace:
97 pdman.setMatrix4f(fMatrixUni, kRec709ConversionMatrix); 97 pdman.setMatrix4f(fMatrixUni, kRec709ConversionMatrix);
98 break; 98 break;
99 } 99 }
100 } 100 }
101 101
102 private: 102 private:
103 GrGLSLProgramDataManager::UniformHandle fMatrixUni; 103 GrGLSLProgramDataManager::UniformHandle fMatrixUni;
104 104
105 typedef GrGLFragmentProcessor INHERITED; 105 typedef GrGLSLFragmentProcessor INHERITED;
106 }; 106 };
107 107
108 private: 108 private:
109 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture , 109 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ,
110 const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFi lterMode, 110 const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFi lterMode,
111 SkYUVColorSpace colorSpace) 111 SkYUVColorSpace colorSpace)
112 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode) 112 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode)
113 , fYAccess(yTexture) 113 , fYAccess(yTexture)
114 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) 114 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode)
115 , fUAccess(uTexture, uvFilterMode) 115 , fUAccess(uTexture, uvFilterMode)
116 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) 116 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode)
117 , fVAccess(vTexture, uvFilterMode) 117 , fVAccess(vTexture, uvFilterMode)
118 , fColorSpace(colorSpace) { 118 , fColorSpace(colorSpace) {
119 this->initClassID<YUVtoRGBEffect>(); 119 this->initClassID<YUVtoRGBEffect>();
120 this->addCoordTransform(&fYTransform); 120 this->addCoordTransform(&fYTransform);
121 this->addTextureAccess(&fYAccess); 121 this->addTextureAccess(&fYAccess);
122 this->addCoordTransform(&fUTransform); 122 this->addCoordTransform(&fUTransform);
123 this->addTextureAccess(&fUAccess); 123 this->addTextureAccess(&fUAccess);
124 this->addCoordTransform(&fVTransform); 124 this->addCoordTransform(&fVTransform);
125 this->addTextureAccess(&fVAccess); 125 this->addTextureAccess(&fVAccess);
126 } 126 }
127 127
128 GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLPr ocessor(*this); } 128 GrGLSLFragmentProcessor* onCreateGLInstance() const override { return new GL Processor(*this); }
129 129
130 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 130 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
131 GrProcessorKeyBuilder* b) const override { 131 GrProcessorKeyBuilder* b) const override {
132 GLProcessor::GenKey(*this, caps, b); 132 GLProcessor::GenKey(*this, caps, b);
133 } 133 }
134 134
135 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 135 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
136 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); 136 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>();
137 return fColorSpace == s.getColorSpace(); 137 return fColorSpace == s.getColorSpace();
138 } 138 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 ////////////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////////////
175 175
176 GrFragmentProcessor* 176 GrFragmentProcessor*
177 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture, 177 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
178 const SkISize sizes[3], SkYUVColorSpace colorSpace) { 178 const SkISize sizes[3], SkYUVColorSpace colorSpace) {
179 SkASSERT(yTexture && uTexture && vTexture && sizes); 179 SkASSERT(yTexture && uTexture && vTexture && sizes);
180 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e); 180 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e);
181 } 181 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrXfermodeFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLFragmentProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698