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

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

Issue 1230803002: YUV to RGB Texture threading GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 5 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/SkImage_Gpu.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 "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/GrGLProcessor.h" 13 #include "gl/GrGLProcessor.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(GrTexture* yTexture, GrTexture* uTexture, 20 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* yTexture,
21 GrTexture* vTexture, const SkISize sizes[ 3], 21 GrTexture* uTexture, GrTexture* vTexture,
22 SkYUVColorSpace colorSpace) { 22 const SkISize sizes[3], SkYUVColorSpace c olorSpace) {
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 SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatr ix, 43 return SkNEW_ARGS(YUVtoRGBEffect, (procDataManager, yTexture, uTexture, vTexture, yuvMatrix,
44 uvFilterMode, colorSpace)); 44 uvFilterMode, 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 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 103 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
104 GrProcessorKeyBuilder* b) const 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 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(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex ture,
114 const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFi lterMode, 114 GrTexture* vTexture, const SkMatrix yuvMatrix[3],
115 SkYUVColorSpace colorSpace) 115 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col orSpace)
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);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = { 159 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
160 1.164f, 0.0f, 1.596f, -0.87075f, 160 1.164f, 0.0f, 1.596f, -0.87075f,
161 1.164f, -0.391f, -0.813f, 0.52925f, 161 1.164f, -0.391f, -0.813f, 0.52925f,
162 1.164f, 2.018f, 0.0f, -1.08175f, 162 1.164f, 2.018f, 0.0f, -1.08175f,
163 0.0f, 0.0f, 0.0f, 1.0}; 163 0.0f, 0.0f, 0.0f, 1.0};
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(GrProcessorDataManager* procDataManager, GrTexture* yTe xture,
170 const SkISize sizes[3], SkYUVColorSpace colorSpace) { 170 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3],
171 SkASSERT(yTexture && uTexture && vTexture && sizes); 171 SkYUVColorSpace colorSpace) {
172 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e); 172 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes);
173 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace);
173 } 174 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrYUVtoRGBEffect.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698