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

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

Issue 1228683002: rename GrShaderDataManager -> GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@grfixuptests
Patch Set: rebase onto origin/master Created 5 years, 5 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/SkLumaColorFilter.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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 GrTextureDomain::GLDomain fGLDomain; 325 GrTextureDomain::GLDomain fGLDomain;
326 326
327 typedef GrGLFragmentProcessor INHERITED; 327 typedef GrGLFragmentProcessor INHERITED;
328 }; 328 };
329 329
330 /////////////////////////////////////////////////////////////////////////////// 330 ///////////////////////////////////////////////////////////////////////////////
331 331
332 class GrDisplacementMapEffect : public GrFragmentProcessor { 332 class GrDisplacementMapEffect : public GrFragmentProcessor {
333 public: 333 public:
334 static GrFragmentProcessor* Create( 334 static GrFragmentProcessor* Create(
335 GrShaderDataManager* shaderDataManager, 335 GrProcessorDataManager* procDataManager,
336 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector, 336 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
337 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVec tor scale, 337 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVec tor scale,
338 GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* co lor, 338 GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* co lor,
339 const SkISize& colorDimensions) { 339 const SkISize& colorDimensions) {
340 return SkNEW_ARGS(GrDisplacementMapEffect, (shaderDataManager, 340 return SkNEW_ARGS(GrDisplacementMapEffect, (procDataManager,
341 xChannelSelector, 341 xChannelSelector,
342 yChannelSelector, 342 yChannelSelector,
343 scale, 343 scale,
344 displacement, 344 displacement,
345 offsetMatrix, 345 offsetMatrix,
346 color, 346 color,
347 colorDimensions)); 347 colorDimensions));
348 } 348 }
349 349
350 virtual ~GrDisplacementMapEffect(); 350 virtual ~GrDisplacementMapEffect();
(...skipping 14 matching lines...) Expand all
365 const SkVector& scale() const { return fScale; } 365 const SkVector& scale() const { return fScale; }
366 366
367 const char* name() const override { return "DisplacementMap"; } 367 const char* name() const override { return "DisplacementMap"; }
368 const GrTextureDomain& domain() const { return fDomain; } 368 const GrTextureDomain& domain() const { return fDomain; }
369 369
370 private: 370 private:
371 bool onIsEqual(const GrFragmentProcessor&) const override; 371 bool onIsEqual(const GrFragmentProcessor&) const override;
372 372
373 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 373 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
374 374
375 GrDisplacementMapEffect(GrShaderDataManager*, 375 GrDisplacementMapEffect(GrProcessorDataManager*,
376 SkDisplacementMapEffect::ChannelSelectorType xChanne lSelector, 376 SkDisplacementMapEffect::ChannelSelectorType xChanne lSelector,
377 SkDisplacementMapEffect::ChannelSelectorType yChanne lSelector, 377 SkDisplacementMapEffect::ChannelSelectorType yChanne lSelector,
378 const SkVector& scale, 378 const SkVector& scale,
379 GrTexture* displacement, const SkMatrix& offsetMatri x, 379 GrTexture* displacement, const SkMatrix& offsetMatri x,
380 GrTexture* color, 380 GrTexture* color,
381 const SkISize& colorDimensions); 381 const SkISize& colorDimensions);
382 382
383 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 383 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
384 384
385 GrCoordTransform fDisplacementTransform; 385 GrCoordTransform fDisplacementTransform;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 SkVector scale = SkVector::Make(fScale, fScale); 443 SkVector scale = SkVector::Make(fScale, fScale);
444 ctx.ctm().mapVectors(&scale, 1); 444 ctx.ctm().mapVectors(&scale, 1);
445 445
446 GrPaint paint; 446 GrPaint paint;
447 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent); 447 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent);
448 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), 448 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX),
449 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); 449 SkIntToScalar(colorOffset.fY - displacementOffset. fY));
450 450
451 paint.addColorProcessor( 451 paint.addColorProcessor(
452 GrDisplacementMapEffect::Create(paint.getShaderDataManager(), 452 GrDisplacementMapEffect::Create(paint.getProcessorDataManager(),
453 fXChannelSelector, 453 fXChannelSelector,
454 fYChannelSelector, 454 fYChannelSelector,
455 scale, 455 scale,
456 displacement, 456 displacement,
457 offsetMatrix, 457 offsetMatrix,
458 color, 458 color,
459 colorBM.dimensions()))->unref(); 459 colorBM.dimensions()))->unref();
460 SkIRect colorBounds = bounds; 460 SkIRect colorBounds = bounds;
461 colorBounds.offset(-colorOffset); 461 colorBounds.offset(-colorOffset);
462 SkMatrix matrix; 462 SkMatrix matrix;
463 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), 463 matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
464 -SkIntToScalar(colorBounds.y())); 464 -SkIntToScalar(colorBounds.y()));
465 465
466 GrDrawContext* drawContext = context->drawContext(); 466 GrDrawContext* drawContext = context->drawContext();
467 if (!drawContext) { 467 if (!drawContext) {
468 return false; 468 return false;
469 } 469 }
470 470
471 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matr ix, 471 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matr ix,
472 SkRect::Make(colorBounds)); 472 SkRect::Make(colorBounds));
473 offset->fX = bounds.left(); 473 offset->fX = bounds.left();
474 offset->fY = bounds.top(); 474 offset->fY = bounds.top();
475 WrapTexture(dst, bounds.width(), bounds.height(), result); 475 WrapTexture(dst, bounds.width(), bounds.height(), result);
476 return true; 476 return true;
477 } 477 }
478 478
479 /////////////////////////////////////////////////////////////////////////////// 479 ///////////////////////////////////////////////////////////////////////////////
480 480
481 GrDisplacementMapEffect::GrDisplacementMapEffect( 481 GrDisplacementMapEffect::GrDisplacementMapEffect(
482 GrShaderDataManager*, 482 GrProcessorDataManager*,
483 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector, 483 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector,
484 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector, 484 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector,
485 const SkVector& scale, 485 const SkVector& scale,
486 GrTexture* displacement, 486 GrTexture* displacement,
487 const SkMatrix& offsetMatrix, 487 const SkMatrix& offsetMatrix,
488 GrTexture* color, 488 GrTexture* color,
489 const SkISize& colorDimensions) 489 const SkISize& colorDimensions)
490 : fDisplacementTransform(kLocal_GrCoordSet, offsetMatrix, displacement, 490 : fDisplacementTransform(kLocal_GrCoordSet, offsetMatrix, displacement,
491 GrTextureParams::kNone_FilterMode) 491 GrTextureParams::kNone_FilterMode)
492 , fDisplacementAccess(displacement) 492 , fDisplacementAccess(displacement)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 537 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
538 d->fRandom->nextRangeU(1, kMaxComponent)); 538 d->fRandom->nextRangeU(1, kMaxComponent));
539 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = 539 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector =
540 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 540 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
541 d->fRandom->nextRangeU(1, kMaxComponent)); 541 d->fRandom->nextRangeU(1, kMaxComponent));
542 SkVector scale = SkVector::Make(d->fRandom->nextRangeScalar(0, 100.0f), 542 SkVector scale = SkVector::Make(d->fRandom->nextRangeScalar(0, 100.0f),
543 d->fRandom->nextRangeScalar(0, 100.0f)); 543 d->fRandom->nextRangeScalar(0, 100.0f));
544 SkISize colorDimensions; 544 SkISize colorDimensions;
545 colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor] ->width()); 545 colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor] ->width());
546 colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor ]->height()); 546 colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor ]->height());
547 return GrDisplacementMapEffect::Create(d->fShaderDataManager, 547 return GrDisplacementMapEffect::Create(d->fProcDataManager,
548 xChannelSelector, yChannelSelector, s cale, 548 xChannelSelector, yChannelSelector, s cale,
549 d->fTextures[texIdxDispl], SkMatrix:: I(), 549 d->fTextures[texIdxDispl], SkMatrix:: I(),
550 d->fTextures[texIdxColor], colorDimen sions); 550 d->fTextures[texIdxColor], colorDimen sions);
551 } 551 }
552 552
553 /////////////////////////////////////////////////////////////////////////////// 553 ///////////////////////////////////////////////////////////////////////////////
554 554
555 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc) 555 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc)
556 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector()) 556 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
557 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) { 557 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 647 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
648 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 648 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
649 649
650 uint32_t xKey = displacementMap.xChannelSelector(); 650 uint32_t xKey = displacementMap.xChannelSelector();
651 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 651 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
652 652
653 b->add32(xKey | yKey); 653 b->add32(xKey | yKey);
654 } 654 }
655 #endif 655 #endif
656 656
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLumaColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698