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

Side by Side Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 1666773002: Clean up GrGLSLFragmentProcessor-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkMagnifierImageFilter.h" 9 #include "SkMagnifierImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 float fYInvInset; 93 float fYInvInset;
94 94
95 typedef GrSingleTextureEffect INHERITED; 95 typedef GrSingleTextureEffect INHERITED;
96 }; 96 };
97 97
98 // For brevity 98 // For brevity
99 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 99 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
100 100
101 class GrGLMagnifierEffect : public GrGLSLFragmentProcessor { 101 class GrGLMagnifierEffect : public GrGLSLFragmentProcessor {
102 public: 102 public:
103 GrGLMagnifierEffect(const GrProcessor&); 103 void emitCode(EmitArgs&) override;
104
105 virtual void emitCode(EmitArgs&) override;
106 104
107 protected: 105 protected:
108 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 106 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
109 107
110 private: 108 private:
111 UniformHandle fOffsetVar; 109 UniformHandle fOffsetVar;
112 UniformHandle fInvZoomVar; 110 UniformHandle fInvZoomVar;
113 UniformHandle fInvInsetVar; 111 UniformHandle fInvInsetVar;
114 UniformHandle fBoundsVar; 112 UniformHandle fBoundsVar;
115 113
116 typedef GrGLSLFragmentProcessor INHERITED; 114 typedef GrGLSLFragmentProcessor INHERITED;
117 }; 115 };
118 116
119 GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) {
120 }
121
122 void GrGLMagnifierEffect::emitCode(EmitArgs& args) { 117 void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
123 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 118 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
124 fOffsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visi bility, 119 fOffsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visi bility,
125 kVec2f_GrSLType, kDefault_GrSLPrecis ion, 120 kVec2f_GrSLType, kDefault_GrSLPrecis ion,
126 "Offset"); 121 "Offset");
127 fInvZoomVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Vis ibility, 122 fInvZoomVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Vis ibility,
128 kVec2f_GrSLType, kDefault_GrSLPreci sion, 123 kVec2f_GrSLType, kDefault_GrSLPreci sion,
129 "InvZoom"); 124 "InvZoom");
130 fInvInsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Vi sibility, 125 fInvInsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Vi sibility,
131 kVec2f_GrSLType, kDefault_GrSLPrec ision, 126 kVec2f_GrSLType, kDefault_GrSLPrec ision,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 175 }
181 176
182 ///////////////////////////////////////////////////////////////////// 177 /////////////////////////////////////////////////////////////////////
183 178
184 void GrMagnifierEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 179 void GrMagnifierEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
185 GrProcessorKeyBuilder* b) const { 180 GrProcessorKeyBuilder* b) const {
186 GrGLMagnifierEffect::GenKey(*this, caps, b); 181 GrGLMagnifierEffect::GenKey(*this, caps, b);
187 } 182 }
188 183
189 GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const { 184 GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const {
190 return new GrGLMagnifierEffect(*this); 185 return new GrGLMagnifierEffect;
191 } 186 }
192 187
193 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect); 188 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
194 189
195 const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) { 190 const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
196 GrTexture* texture = d->fTextures[0]; 191 GrTexture* texture = d->fTextures[0];
197 const int kMaxWidth = 200; 192 const int kMaxWidth = 200;
198 const int kMaxHeight = 200; 193 const int kMaxHeight = 200;
199 const int kMaxInset = 20; 194 const int kMaxInset = 20;
200 uint32_t width = d->fRandom->nextULessThan(kMaxWidth); 195 uint32_t width = d->fRandom->nextULessThan(kMaxWidth);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 365
371 #ifndef SK_IGNORE_TO_STRING 366 #ifndef SK_IGNORE_TO_STRING
372 void SkMagnifierImageFilter::toString(SkString* str) const { 367 void SkMagnifierImageFilter::toString(SkString* str) const {
373 str->appendf("SkMagnifierImageFilter: ("); 368 str->appendf("SkMagnifierImageFilter: (");
374 str->appendf("src: (%f,%f,%f,%f) ", 369 str->appendf("src: (%f,%f,%f,%f) ",
375 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m); 370 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m);
376 str->appendf("inset: %f", fInset); 371 str->appendf("inset: %f", fInset);
377 str->append(")"); 372 str->append(")");
378 } 373 }
379 #endif 374 #endif
OLDNEW
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698