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

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

Issue 1109863004: Use GLSLCaps for creating processor keys and GLSL-specific programs (Closed) Base URL: https://chromium.googlesource.com/skia@master
Patch Set: Created 5 years, 8 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/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"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 virtual ~GrMorphologyEffect(); 310 virtual ~GrMorphologyEffect();
311 311
312 MorphologyType type() const { return fType; } 312 MorphologyType type() const { return fType; }
313 bool useRange() const { return fUseRange; } 313 bool useRange() const { return fUseRange; }
314 const float* range() const { return fRange; } 314 const float* range() const { return fRange; }
315 315
316 const char* name() const override { return "Morphology"; } 316 const char* name() const override { return "Morphology"; }
317 317
318 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const overri de; 318 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
319 319
320 GrGLFragmentProcessor* createGLInstance() const override; 320 GrGLFragmentProcessor* createGLInstance() const override;
321 321
322 protected: 322 protected:
323 323
324 MorphologyType fType; 324 MorphologyType fType;
325 bool fUseRange; 325 bool fUseRange;
326 float fRange[2]; 326 float fRange[2];
327 327
328 private: 328 private:
(...skipping 15 matching lines...) Expand all
344 public: 344 public:
345 GrGLMorphologyEffect(const GrProcessor&); 345 GrGLMorphologyEffect(const GrProcessor&);
346 346
347 virtual void emitCode(GrGLFPBuilder*, 347 virtual void emitCode(GrGLFPBuilder*,
348 const GrFragmentProcessor&, 348 const GrFragmentProcessor&,
349 const char* outputColor, 349 const char* outputColor,
350 const char* inputColor, 350 const char* inputColor,
351 const TransformedCoordsArray&, 351 const TransformedCoordsArray&,
352 const TextureSamplerArray&) override; 352 const TextureSamplerArray&) override;
353 353
354 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder* b); 354 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b);
355 355
356 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; 356 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
357 357
358 private: 358 private:
359 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); } 359 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
360 360
361 int fRadius; 361 int fRadius;
362 Gr1DKernelEffect::Direction fDirection; 362 Gr1DKernelEffect::Direction fDirection;
363 bool fUseRange; 363 bool fUseRange;
364 GrMorphologyEffect::MorphologyType fType; 364 GrMorphologyEffect::MorphologyType fType;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // coord.x = min(highBound, coord.x); 443 // coord.x = min(highBound, coord.x);
444 fsBuilder->codeAppendf("\t\t\tcoord.%s = min(highBound, coord.%s);", dir , dir); 444 fsBuilder->codeAppendf("\t\t\tcoord.%s = min(highBound, coord.%s);", dir , dir);
445 } 445 }
446 fsBuilder->codeAppend("\t\t}\n"); 446 fsBuilder->codeAppend("\t\t}\n");
447 SkString modulate; 447 SkString modulate;
448 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); 448 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor);
449 fsBuilder->codeAppend(modulate.c_str()); 449 fsBuilder->codeAppend(modulate.c_str());
450 } 450 }
451 451
452 void GrGLMorphologyEffect::GenKey(const GrProcessor& proc, 452 void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
453 const GrGLCaps&, GrProcessorKeyBuilder* b) { 453 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
454 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); 454 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
455 uint32_t key = static_cast<uint32_t>(m.radius()); 455 uint32_t key = static_cast<uint32_t>(m.radius());
456 key |= (m.type() << 8); 456 key |= (m.type() << 8);
457 key |= (m.direction() << 9); 457 key |= (m.direction() << 9);
458 if (m.useRange()) key |= 1 << 10; 458 if (m.useRange()) key |= 1 << 10;
459 b->add32(key); 459 b->add32(key);
460 } 460 }
461 461
462 void GrGLMorphologyEffect::setData(const GrGLProgramDataManager& pdman, 462 void GrGLMorphologyEffect::setData(const GrGLProgramDataManager& pdman,
463 const GrProcessor& proc) { 463 const GrProcessor& proc) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 : Gr1DKernelEffect(texture, direction, radius) 510 : Gr1DKernelEffect(texture, direction, radius)
511 , fType(type), fUseRange(true) { 511 , fType(type), fUseRange(true) {
512 this->initClassID<GrMorphologyEffect>(); 512 this->initClassID<GrMorphologyEffect>();
513 fRange[0] = range[0]; 513 fRange[0] = range[0];
514 fRange[1] = range[1]; 514 fRange[1] = range[1];
515 } 515 }
516 516
517 GrMorphologyEffect::~GrMorphologyEffect() { 517 GrMorphologyEffect::~GrMorphologyEffect() {
518 } 518 }
519 519
520 void GrMorphologyEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyB uilder* b) const { 520 void GrMorphologyEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKe yBuilder* b) const {
521 GrGLMorphologyEffect::GenKey(*this, caps, b); 521 GrGLMorphologyEffect::GenKey(*this, caps, b);
522 } 522 }
523 523
524 GrGLFragmentProcessor* GrMorphologyEffect::createGLInstance() const { 524 GrGLFragmentProcessor* GrMorphologyEffect::createGLInstance() const {
525 return SkNEW_ARGS(GrGLMorphologyEffect, (*this)); 525 return SkNEW_ARGS(GrGLMorphologyEffect, (*this));
526 } 526 }
527 bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 527 bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
528 const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>(); 528 const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
529 return (this->radius() == s.radius() && 529 return (this->radius() == s.radius() &&
530 this->direction() == s.direction() && 530 this->direction() == s.direction() &&
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 SkBitmap* result, SkIPoint* offset) con st { 747 SkBitmap* result, SkIPoint* offset) con st {
748 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); 748 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset);
749 } 749 }
750 750
751 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 751 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
752 SkBitmap* result, SkIPoint* offset) cons t { 752 SkBitmap* result, SkIPoint* offset) cons t {
753 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); 753 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset);
754 } 754 }
755 755
756 #endif 756 #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