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

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

Issue 1241723005: Add Rec709 YUV color space support to GrYUVtoRGBEffect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tricksy floatses. 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 | « include/core/SkImageInfo.h ('k') | no next file » | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
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 static const GrGLfloat kRec709ConversionMatrix[16];
57 58
58 // this class always generates the same code. 59 // this class always generates the same code.
59 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} 60 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {}
60 61
61 GLProcessor(const GrProcessor&) {} 62 GLProcessor(const GrProcessor&) {}
62 63
63 virtual void emitCode(GrGLFPBuilder* builder, 64 virtual void emitCode(GrGLFPBuilder* builder,
64 const GrFragmentProcessor&, 65 const GrFragmentProcessor&,
65 const char* outputColor, 66 const char* outputColor,
66 const char* inputColor, 67 const char* inputColor,
(...skipping 17 matching lines...) Expand all
84 virtual void setData(const GrGLProgramDataManager& pdman, 85 virtual void setData(const GrGLProgramDataManager& pdman,
85 const GrProcessor& processor) override { 86 const GrProcessor& processor) override {
86 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); 87 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
87 switch (yuvEffect.getColorSpace()) { 88 switch (yuvEffect.getColorSpace()) {
88 case kJPEG_SkYUVColorSpace: 89 case kJPEG_SkYUVColorSpace:
89 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); 90 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix);
90 break; 91 break;
91 case kRec601_SkYUVColorSpace: 92 case kRec601_SkYUVColorSpace:
92 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix); 93 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix);
93 break; 94 break;
95 case kRec709_SkYUVColorSpace:
96 pdman.setMatrix4f(fMatrixUni, kRec709ConversionMatrix);
97 break;
94 } 98 }
95 } 99 }
96 100
97 private: 101 private:
98 GrGLProgramDataManager::UniformHandle fMatrixUni; 102 GrGLProgramDataManager::UniformHandle fMatrixUni;
99 103
100 typedef GrGLFragmentProcessor INHERITED; 104 typedef GrGLFragmentProcessor INHERITED;
101 }; 105 };
102 106
103 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 107 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = { 158 const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = {
155 1.0f, 0.0f, 1.402f, -0.701f, 159 1.0f, 0.0f, 1.402f, -0.701f,
156 1.0f, -0.34414f, -0.71414f, 0.529f, 160 1.0f, -0.34414f, -0.71414f, 0.529f,
157 1.0f, 1.772f, 0.0f, -0.886f, 161 1.0f, 1.772f, 0.0f, -0.886f,
158 0.0f, 0.0f, 0.0f, 1.0}; 162 0.0f, 0.0f, 0.0f, 1.0};
159 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = { 163 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
160 1.164f, 0.0f, 1.596f, -0.87075f, 164 1.164f, 0.0f, 1.596f, -0.87075f,
161 1.164f, -0.391f, -0.813f, 0.52925f, 165 1.164f, -0.391f, -0.813f, 0.52925f,
162 1.164f, 2.018f, 0.0f, -1.08175f, 166 1.164f, 2.018f, 0.0f, -1.08175f,
163 0.0f, 0.0f, 0.0f, 1.0}; 167 0.0f, 0.0f, 0.0f, 1.0};
168 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = {
169 1.164f, 0.0f, 1.793f, -0.96925f,
170 1.164f, -0.213f, -0.533f, 0.30025f,
171 1.164f, 2.112f, 0.0f, -1.12875f,
172 0.0f, 0.0f, 0.0f, 1.0f};
164 } 173 }
165 174
166 ////////////////////////////////////////////////////////////////////////////// 175 //////////////////////////////////////////////////////////////////////////////
167 176
168 GrFragmentProcessor* 177 GrFragmentProcessor*
169 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe xture, 178 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe xture,
170 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3], 179 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3],
171 SkYUVColorSpace colorSpace) { 180 SkYUVColorSpace colorSpace) {
172 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); 181 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes);
173 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace); 182 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace);
174 } 183 }
OLDNEW
« no previous file with comments | « include/core/SkImageInfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698