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

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

Issue 1287023009: Added tree structure to GrGLFragmentProcessor, i.e. GL instances (Closed) Base URL: https://skia.googlesource.com/skia@cs3_isequal_nonrecursive
Patch Set: moved onSetData from public to protected, onCreateGLInstance from public to private in subclasses Created 5 years, 4 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/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 #if SK_SUPPORT_GPU 303 #if SK_SUPPORT_GPU
304 class GrGLDisplacementMapEffect : public GrGLFragmentProcessor { 304 class GrGLDisplacementMapEffect : public GrGLFragmentProcessor {
305 public: 305 public:
306 GrGLDisplacementMapEffect(const GrProcessor&); 306 GrGLDisplacementMapEffect(const GrProcessor&);
307 virtual ~GrGLDisplacementMapEffect(); 307 virtual ~GrGLDisplacementMapEffect();
308 308
309 virtual void emitCode(EmitArgs&) override; 309 virtual void emitCode(EmitArgs&) override;
310 310
311 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*); 311 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*);
312 312
313 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
314 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; } 313 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; }
315 314
315 protected:
316 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
317
316 private: 318 private:
317 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; 319 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
318 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; 320 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
319 GrGLProgramDataManager::UniformHandle fScaleUni; 321 GrGLProgramDataManager::UniformHandle fScaleUni;
320 GrTextureDomain::GLDomain fGLDomain; 322 GrTextureDomain::GLDomain fGLDomain;
321 323
322 typedef GrGLFragmentProcessor INHERITED; 324 typedef GrGLFragmentProcessor INHERITED;
323 }; 325 };
324 326
325 /////////////////////////////////////////////////////////////////////////////// 327 ///////////////////////////////////////////////////////////////////////////////
(...skipping 11 matching lines...) Expand all
337 yChannelSelector, 339 yChannelSelector,
338 scale, 340 scale,
339 displacement, 341 displacement,
340 offsetMatrix, 342 offsetMatrix,
341 color, 343 color,
342 colorDimensions)); 344 colorDimensions));
343 } 345 }
344 346
345 virtual ~GrDisplacementMapEffect(); 347 virtual ~GrDisplacementMapEffect();
346 348
347 GrGLFragmentProcessor* createGLInstance() const override {
348 return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
349 }
350
351 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const 349 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const
352 { return fXChannelSelector; } 350 { return fXChannelSelector; }
353 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const 351 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const
354 { return fYChannelSelector; } 352 { return fYChannelSelector; }
355 const SkVector& scale() const { return fScale; } 353 const SkVector& scale() const { return fScale; }
356 354
357 const char* name() const override { return "DisplacementMap"; } 355 const char* name() const override { return "DisplacementMap"; }
358 const GrTextureDomain& domain() const { return fDomain; } 356 const GrTextureDomain& domain() const { return fDomain; }
359 357
360 private: 358 private:
359 GrGLFragmentProcessor* onCreateGLInstance() const override {
360 return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
361 }
362
361 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 363 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
362 GrProcessorKeyBuilder* b) const override { 364 GrProcessorKeyBuilder* b) const override {
363 GrGLDisplacementMapEffect::GenKey(*this, caps, b); 365 GrGLDisplacementMapEffect::GenKey(*this, caps, b);
364 } 366 }
365 367
366 bool onIsEqual(const GrFragmentProcessor&) const override; 368 bool onIsEqual(const GrFragmentProcessor&) const override;
367 369
368 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 370 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
369 371
370 GrDisplacementMapEffect(GrProcessorDataManager*, 372 GrDisplacementMapEffect(GrProcessorDataManager*,
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 default: 616 default:
615 SkDEBUGFAIL("Unknown Y channel selector"); 617 SkDEBUGFAIL("Unknown Y channel selector");
616 } 618 }
617 fsBuilder->codeAppend("-vec2(0.5));\t\t"); 619 fsBuilder->codeAppend("-vec2(0.5));\t\t");
618 620
619 fGLDomain.sampleTexture(fsBuilder, domain, args.fOutputColor, SkString(cCoor ds), 621 fGLDomain.sampleTexture(fsBuilder, domain, args.fOutputColor, SkString(cCoor ds),
620 args.fSamplers[1]); 622 args.fSamplers[1]);
621 fsBuilder->codeAppend(";\n"); 623 fsBuilder->codeAppend(";\n");
622 } 624 }
623 625
624 void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman, 626 void GrGLDisplacementMapEffect::onSetData(const GrGLProgramDataManager& pdman,
625 const GrProcessor& proc) { 627 const GrProcessor& proc) {
626 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 628 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
627 GrTexture* colorTex = displacementMap.texture(1); 629 GrTexture* colorTex = displacementMap.texture(1);
628 SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); 630 SkScalar scaleX = displacementMap.scale().fX / colorTex->width();
629 SkScalar scaleY = displacementMap.scale().fY / colorTex->height(); 631 SkScalar scaleY = displacementMap.scale().fY / colorTex->height();
630 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), 632 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
631 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? 633 colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
632 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); 634 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
633 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin()); 635 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin());
634 } 636 }
635 637
636 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, 638 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
637 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 639 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 640 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
639 641
640 uint32_t xKey = displacementMap.xChannelSelector(); 642 uint32_t xKey = displacementMap.xChannelSelector();
641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 643 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
642 644
643 b->add32(xKey | yKey); 645 b->add32(xKey | yKey);
644 } 646 }
645 #endif 647 #endif
646 648
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698