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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/SkMagnifierImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.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 "SkMorphologyImageFilter.h" 8 #include "SkMorphologyImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkOpts.h" 12 #include "SkOpts.h"
13 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
14 #include "SkRect.h" 14 #include "SkRect.h"
15 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
16 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
17 #include "GrContext.h" 17 #include "GrContext.h"
18 #include "GrDrawContext.h" 18 #include "GrDrawContext.h"
19 #include "GrInvariantOutput.h" 19 #include "GrInvariantOutput.h"
20 #include "GrTexture.h" 20 #include "GrTexture.h"
21 #include "effects/Gr1DKernelEffect.h" 21 #include "effects/Gr1DKernelEffect.h"
22 #include "gl/GrGLFragmentProcessor.h" 22 #include "glsl/GrGLSLFragmentProcessor.h"
23 #include "glsl/GrGLSLFragmentShaderBuilder.h" 23 #include "glsl/GrGLSLFragmentShaderBuilder.h"
24 #include "glsl/GrGLSLProgramBuilder.h" 24 #include "glsl/GrGLSLProgramBuilder.h"
25 #include "glsl/GrGLSLProgramDataManager.h" 25 #include "glsl/GrGLSLProgramDataManager.h"
26 #endif 26 #endif
27 27
28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, 28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
29 int radiusY, 29 int radiusY,
30 SkImageFilter* input, 30 SkImageFilter* input,
31 const CropRect* cropRect) 31 const CropRect* cropRect)
32 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { 32 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 const char* name() const override { return "Morphology"; } 230 const char* name() const override { return "Morphology"; }
231 231
232 protected: 232 protected:
233 233
234 MorphologyType fType; 234 MorphologyType fType;
235 bool fUseRange; 235 bool fUseRange;
236 float fRange[2]; 236 float fRange[2];
237 237
238 private: 238 private:
239 GrGLFragmentProcessor* onCreateGLInstance() const override; 239 GrGLSLFragmentProcessor* onCreateGLInstance() const override;
240 240
241 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 241 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
242 242
243 bool onIsEqual(const GrFragmentProcessor&) const override; 243 bool onIsEqual(const GrFragmentProcessor&) const override;
244 244
245 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 245 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
246 246
247 GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType); 247 GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
248 GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType, 248 GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType,
249 float bounds[2]); 249 float bounds[2]);
250 250
251 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 251 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
252 252
253 typedef Gr1DKernelEffect INHERITED; 253 typedef Gr1DKernelEffect INHERITED;
254 }; 254 };
255 255
256 /////////////////////////////////////////////////////////////////////////////// 256 ///////////////////////////////////////////////////////////////////////////////
257 257
258 class GrGLMorphologyEffect : public GrGLFragmentProcessor { 258 class GrGLMorphologyEffect : public GrGLSLFragmentProcessor {
259 public: 259 public:
260 GrGLMorphologyEffect(const GrProcessor&); 260 GrGLMorphologyEffect(const GrProcessor&);
261 261
262 virtual void emitCode(EmitArgs&) override; 262 virtual void emitCode(EmitArgs&) override;
263 263
264 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b); 264 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b);
265 265
266 protected: 266 protected:
267 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 267 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
268 268
269 private: 269 private:
270 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); } 270 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
271 271
272 int fRadius; 272 int fRadius;
273 Gr1DKernelEffect::Direction fDirection; 273 Gr1DKernelEffect::Direction fDirection;
274 bool fUseRange; 274 bool fUseRange;
275 GrMorphologyEffect::MorphologyType fType; 275 GrMorphologyEffect::MorphologyType fType;
276 GrGLSLProgramDataManager::UniformHandle fPixelSizeUni; 276 GrGLSLProgramDataManager::UniformHandle fPixelSizeUni;
277 GrGLSLProgramDataManager::UniformHandle fRangeUni; 277 GrGLSLProgramDataManager::UniformHandle fRangeUni;
278 278
279 typedef GrGLFragmentProcessor INHERITED; 279 typedef GrGLSLFragmentProcessor INHERITED;
280 }; 280 };
281 281
282 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) { 282 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) {
283 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); 283 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
284 fRadius = m.radius(); 284 fRadius = m.radius();
285 fDirection = m.direction(); 285 fDirection = m.direction();
286 fUseRange = m.useRange(); 286 fUseRange = m.useRange();
287 fType = m.type(); 287 fType = m.type();
288 } 288 }
289 289
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 fRange[1] = range[1]; 420 fRange[1] = range[1];
421 } 421 }
422 422
423 GrMorphologyEffect::~GrMorphologyEffect() { 423 GrMorphologyEffect::~GrMorphologyEffect() {
424 } 424 }
425 425
426 void GrMorphologyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessor KeyBuilder* b) const { 426 void GrMorphologyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessor KeyBuilder* b) const {
427 GrGLMorphologyEffect::GenKey(*this, caps, b); 427 GrGLMorphologyEffect::GenKey(*this, caps, b);
428 } 428 }
429 429
430 GrGLFragmentProcessor* GrMorphologyEffect::onCreateGLInstance() const { 430 GrGLSLFragmentProcessor* GrMorphologyEffect::onCreateGLInstance() const {
431 return new GrGLMorphologyEffect(*this); 431 return new GrGLMorphologyEffect(*this);
432 } 432 }
433 bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 433 bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
434 const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>(); 434 const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
435 return (this->radius() == s.radius() && 435 return (this->radius() == s.radius() &&
436 this->direction() == s.direction() && 436 this->direction() == s.direction() &&
437 this->useRange() == s.useRange() && 437 this->useRange() == s.useRange() &&
438 this->type() == s.type()); 438 this->type() == s.type());
439 } 439 }
440 440
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 SkBitmap* result, SkIPoint* offset) con st { 670 SkBitmap* result, SkIPoint* offset) con st {
671 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); 671 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset);
672 } 672 }
673 673
674 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 674 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
675 SkBitmap* result, SkIPoint* offset) cons t { 675 SkBitmap* result, SkIPoint* offset) cons t {
676 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); 676 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset);
677 } 677 }
678 678
679 #endif 679 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698