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

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

Issue 1149553002: SkImage::NewFromYUVTexturesCopy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warnings 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/GrYUVtoRGBEffect.h ('k') | src/gpu/gl/GrGLGpu.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/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(GrTexture* yTexture, GrTexture* uTexture,
21 GrTexture* vTexture, SkISize sizes[3], 21 GrTexture* vTexture, const SkISize sizes[ 3],
22 SkYUVColorSpace colorSpace) { 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);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ,
114 SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMo de, 114 const SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFi lterMode,
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);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
170 SkISize sizes[3], SkYUVColorSpace colorSpace) { 170 const 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/GrYUVtoRGBEffect.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698