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

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

Issue 1388113002: Bye bye processor data manager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove files Created 5 years, 2 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/GrYUVtoRGBEffect.h ('k') | src/image/SkImageShader.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 "gl/GrGLFragmentProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
15 15
16 namespace { 16 namespace {
17 17
18 class YUVtoRGBEffect : public GrFragmentProcessor { 18 class YUVtoRGBEffect : public GrFragmentProcessor {
19 public: 19 public:
20 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* yTexture, 20 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
21 GrTexture* uTexture, GrTexture* vTexture, 21 GrTexture* vTexture, const SkISize sizes[ 3],
22 const SkISize sizes[3], SkYUVColorSpace c olorSpace) { 22 SkYUVColorSpace colorSpace) {
23 SkScalar w[3], h[3]; 23 SkScalar w[3], h[3];
24 w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width() ); 24 w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width() );
25 h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height( )); 25 h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height( ));
26 w[1] = SkIntToScalar(sizes[1].fWidth) / SkIntToScalar(uTexture->width() ); 26 w[1] = SkIntToScalar(sizes[1].fWidth) / SkIntToScalar(uTexture->width() );
27 h[1] = SkIntToScalar(sizes[1].fHeight) / SkIntToScalar(uTexture->height( )); 27 h[1] = SkIntToScalar(sizes[1].fHeight) / SkIntToScalar(uTexture->height( ));
28 w[2] = SkIntToScalar(sizes[2].fWidth) / SkIntToScalar(vTexture->width() ); 28 w[2] = SkIntToScalar(sizes[2].fWidth) / SkIntToScalar(vTexture->width() );
29 h[2] = SkIntToScalar(sizes[2].fHeight) / SkIntToScalar(vTexture->height( )); 29 h[2] = SkIntToScalar(sizes[2].fHeight) / SkIntToScalar(vTexture->height( ));
30 SkMatrix yuvMatrix[3]; 30 SkMatrix yuvMatrix[3];
31 yuvMatrix[0] = GrCoordTransform::MakeDivByTextureWHMatrix(yTexture); 31 yuvMatrix[0] = GrCoordTransform::MakeDivByTextureWHMatrix(yTexture);
32 yuvMatrix[1] = yuvMatrix[0]; 32 yuvMatrix[1] = yuvMatrix[0];
33 yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]); 33 yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]);
34 yuvMatrix[2] = yuvMatrix[0]; 34 yuvMatrix[2] = yuvMatrix[0];
35 yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]); 35 yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]);
36 GrTextureParams::FilterMode uvFilterMode = 36 GrTextureParams::FilterMode uvFilterMode =
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 new YUVtoRGBEffect(procDataManager, yTexture, uTexture, vTexture, yuvMatrix, 43 return new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFil terMode,
44 uvFilterMode, colorSpace); 44 colorSpace);
45 } 45 }
46 46
47 const char* name() const 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:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 } 98 }
99 99
100 private: 100 private:
101 GrGLProgramDataManager::UniformHandle fMatrixUni; 101 GrGLProgramDataManager::UniformHandle fMatrixUni;
102 102
103 typedef GrGLFragmentProcessor INHERITED; 103 typedef GrGLFragmentProcessor INHERITED;
104 }; 104 };
105 105
106 private: 106 private:
107 YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex ture, 107 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ,
108 GrTexture* vTexture, const SkMatrix yuvMatrix[3], 108 const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFi lterMode,
109 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col orSpace) 109 SkYUVColorSpace colorSpace)
110 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode) 110 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN one_FilterMode)
111 , fYAccess(yTexture) 111 , fYAccess(yTexture)
112 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) 112 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode)
113 , fUAccess(uTexture, uvFilterMode) 113 , fUAccess(uTexture, uvFilterMode)
114 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) 114 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode)
115 , fVAccess(vTexture, uvFilterMode) 115 , fVAccess(vTexture, uvFilterMode)
116 , fColorSpace(colorSpace) { 116 , fColorSpace(colorSpace) {
117 this->initClassID<YUVtoRGBEffect>(); 117 this->initClassID<YUVtoRGBEffect>();
118 this->addCoordTransform(&fYTransform); 118 this->addCoordTransform(&fYTransform);
119 this->addTextureAccess(&fYAccess); 119 this->addTextureAccess(&fYAccess);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = { 165 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = {
166 1.164f, 0.0f, 1.793f, -0.96925f, 166 1.164f, 0.0f, 1.793f, -0.96925f,
167 1.164f, -0.213f, -0.533f, 0.30025f, 167 1.164f, -0.213f, -0.533f, 0.30025f,
168 1.164f, 2.112f, 0.0f, -1.12875f, 168 1.164f, 2.112f, 0.0f, -1.12875f,
169 0.0f, 0.0f, 0.0f, 1.0f}; 169 0.0f, 0.0f, 0.0f, 1.0f};
170 } 170 }
171 171
172 ////////////////////////////////////////////////////////////////////////////// 172 //////////////////////////////////////////////////////////////////////////////
173 173
174 GrFragmentProcessor* 174 GrFragmentProcessor*
175 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe xture, 175 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
176 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3], 176 const SkISize sizes[3], SkYUVColorSpace colorSpace) {
177 SkYUVColorSpace colorSpace) { 177 SkASSERT(yTexture && uTexture && vTexture && sizes);
178 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); 178 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e);
179 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace);
180 } 179 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrYUVtoRGBEffect.h ('k') | src/image/SkImageShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698