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

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

Issue 778453002: Remove backend factories (Closed) Base URL: https://skia.googlesource.com/skia.git@unichoice
Patch Set: cleanup Created 6 years 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
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 "gl/builders/GrGLProgramBuilder.h"
9 #include "GrYUVtoRGBEffect.h" 8 #include "GrYUVtoRGBEffect.h"
10 9
11 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
12 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
13 #include "GrProcessor.h" 12 #include "GrProcessor.h"
14 #include "gl/GrGLProcessor.h" 13 #include "gl/GrGLProcessor.h"
15 #include "GrTBackendProcessorFactory.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
16 15
17 namespace { 16 namespace {
18 17
19 class YUVtoRGBEffect : public GrFragmentProcessor { 18 class YUVtoRGBEffect : public GrFragmentProcessor {
20 public: 19 public:
21 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture, 20 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
22 GrTexture* vTexture, SkYUVColorSpace colo rSpace) { 21 GrTexture* vTexture, SkYUVColorSpace colo rSpace) {
23 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSp ace)); 22 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSp ace));
24 } 23 }
25 24
26 static const char* Name() { return "YUV to RGB"; } 25 virtual const char* name() const SK_OVERRIDE { return "YUV to RGB"; }
27 26
28 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE { 27 virtual uint32_t classID() const {
29 return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance() ; 28 static uint32_t id = GenClassID();
29 return id;
30 } 30 }
31 31
32 SkYUVColorSpace getColorSpace() const { 32 SkYUVColorSpace getColorSpace() const {
33 return fColorSpace; 33 return fColorSpace;
34 } 34 }
35 35
36 class GLProcessor : public GrGLFragmentProcessor { 36 class GLProcessor : public GrGLFragmentProcessor {
37 public: 37 public:
38 static const GrGLfloat kJPEGConversionMatrix[16]; 38 static const GrGLfloat kJPEGConversionMatrix[16];
39 static const GrGLfloat kRec601ConversionMatrix[16]; 39 static const GrGLfloat kRec601ConversionMatrix[16];
40 40
41 // this class always generates the same code. 41 // this class always generates the same code.
42 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder*) {} 42 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder*) {}
43 43
44 GLProcessor(const GrBackendProcessorFactory& factory, 44 GLProcessor(const GrProcessor&) {}
45 const GrProcessor&)
46 : INHERITED(factory) {
47 }
48 45
49 virtual void emitCode(GrGLFPBuilder* builder, 46 virtual void emitCode(GrGLFPBuilder* builder,
50 const GrFragmentProcessor&, 47 const GrFragmentProcessor&,
51 const char* outputColor, 48 const char* outputColor,
52 const char* inputColor, 49 const char* inputColor,
53 const TransformedCoordsArray& coords, 50 const TransformedCoordsArray& coords,
54 const TextureSamplerArray& samplers) SK_OVERRIDE { 51 const TextureSamplerArray& samplers) SK_OVERRIDE {
55 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 52 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
56 53
57 const char* yuvMatrix = NULL; 54 const char* yuvMatrix = NULL;
(...skipping 21 matching lines...) Expand all
79 break; 76 break;
80 } 77 }
81 } 78 }
82 79
83 private: 80 private:
84 GrGLProgramDataManager::UniformHandle fMatrixUni; 81 GrGLProgramDataManager::UniformHandle fMatrixUni;
85 82
86 typedef GrGLFragmentProcessor INHERITED; 83 typedef GrGLFragmentProcessor INHERITED;
87 }; 84 };
88 85
86 virtual void getGLProcessorKey(const GrGLCaps& caps,
87 GrProcessorKeyBuilder* b) const SK_OVERRIDE {
88 GLProcessor::GenKey(*this, caps, b);
89 }
90
91 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE {
92 return SkNEW_ARGS(GLProcessor, (*this));
93 }
94
89 private: 95 private:
90 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture , 96 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ,
91 SkYUVColorSpace colorSpace) 97 SkYUVColorSpace colorSpace)
92 : fCoordTransform(kLocal_GrCoordSet, GrCoordTransform::MakeDivByTextureWHMa trix(yTexture), 98 : fCoordTransform(kLocal_GrCoordSet, GrCoordTransform::MakeDivByTextureWHMa trix(yTexture),
93 yTexture) 99 yTexture)
94 , fYAccess(yTexture) 100 , fYAccess(yTexture)
95 , fUAccess(uTexture) 101 , fUAccess(uTexture)
96 , fVAccess(vTexture) 102 , fVAccess(vTexture)
97 , fColorSpace(colorSpace) { 103 , fColorSpace(colorSpace) {
98 this->addCoordTransform(&fCoordTransform); 104 this->addCoordTransform(&fCoordTransform);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 0.0f, 0.0f, 0.0f, 1.0}; 139 0.0f, 0.0f, 0.0f, 1.0};
134 } 140 }
135 141
136 ////////////////////////////////////////////////////////////////////////////// 142 //////////////////////////////////////////////////////////////////////////////
137 143
138 GrFragmentProcessor* 144 GrFragmentProcessor*
139 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture, 145 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
140 SkYUVColorSpace colorSpace) { 146 SkYUVColorSpace colorSpace) {
141 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace); 147 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace);
142 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698