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

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

Issue 1215643006: more threading of GrShaderDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@GrShaderDataManager3
Patch Set: tweaks 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/SkArithmeticMode_gpu.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 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 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector, 336 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
336 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVec tor scale, 337 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVec tor scale,
337 GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* co lor, 338 GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* co lor,
338 const SkISize& colorDimensions) { 339 const SkISize& colorDimensions) {
339 return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector, 340 return SkNEW_ARGS(GrDisplacementMapEffect, (shaderDataManager,
341 xChannelSelector,
340 yChannelSelector, 342 yChannelSelector,
341 scale, 343 scale,
342 displacement, 344 displacement,
343 offsetMatrix, 345 offsetMatrix,
344 color, 346 color,
345 colorDimensions)); 347 colorDimensions));
346 } 348 }
347 349
348 virtual ~GrDisplacementMapEffect(); 350 virtual ~GrDisplacementMapEffect();
349 351
(...skipping 13 matching lines...) Expand all
363 const SkVector& scale() const { return fScale; } 365 const SkVector& scale() const { return fScale; }
364 366
365 const char* name() const override { return "DisplacementMap"; } 367 const char* name() const override { return "DisplacementMap"; }
366 const GrTextureDomain& domain() const { return fDomain; } 368 const GrTextureDomain& domain() const { return fDomain; }
367 369
368 private: 370 private:
369 bool onIsEqual(const GrFragmentProcessor&) const override; 371 bool onIsEqual(const GrFragmentProcessor&) const override;
370 372
371 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 373 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
372 374
373 GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChanne lSelector, 375 GrDisplacementMapEffect(GrShaderDataManager*,
376 SkDisplacementMapEffect::ChannelSelectorType xChanne lSelector,
374 SkDisplacementMapEffect::ChannelSelectorType yChanne lSelector, 377 SkDisplacementMapEffect::ChannelSelectorType yChanne lSelector,
375 const SkVector& scale, 378 const SkVector& scale,
376 GrTexture* displacement, const SkMatrix& offsetMatri x, 379 GrTexture* displacement, const SkMatrix& offsetMatri x,
377 GrTexture* color, 380 GrTexture* color,
378 const SkISize& colorDimensions); 381 const SkISize& colorDimensions);
379 382
380 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 383 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
381 384
382 GrCoordTransform fDisplacementTransform; 385 GrCoordTransform fDisplacementTransform;
383 GrTextureAccess fDisplacementAccess; 386 GrTextureAccess fDisplacementAccess;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 442
440 SkVector scale = SkVector::Make(fScale, fScale); 443 SkVector scale = SkVector::Make(fScale, fScale);
441 ctx.ctm().mapVectors(&scale, 1); 444 ctx.ctm().mapVectors(&scale, 1);
442 445
443 GrPaint paint; 446 GrPaint paint;
444 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent); 447 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent);
445 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), 448 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX),
446 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); 449 SkIntToScalar(colorOffset.fY - displacementOffset. fY));
447 450
448 paint.addColorProcessor( 451 paint.addColorProcessor(
449 GrDisplacementMapEffect::Create(fXChannelSelector, 452 GrDisplacementMapEffect::Create(paint.getShaderDataManager(),
453 fXChannelSelector,
450 fYChannelSelector, 454 fYChannelSelector,
451 scale, 455 scale,
452 displacement, 456 displacement,
453 offsetMatrix, 457 offsetMatrix,
454 color, 458 color,
455 colorBM.dimensions()))->unref(); 459 colorBM.dimensions()))->unref();
456 SkIRect colorBounds = bounds; 460 SkIRect colorBounds = bounds;
457 colorBounds.offset(-colorOffset); 461 colorBounds.offset(-colorOffset);
458 SkMatrix matrix; 462 SkMatrix matrix;
459 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), 463 matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
460 -SkIntToScalar(colorBounds.y())); 464 -SkIntToScalar(colorBounds.y()));
461 465
462 GrDrawContext* drawContext = context->drawContext(); 466 GrDrawContext* drawContext = context->drawContext();
463 if (!drawContext) { 467 if (!drawContext) {
464 return false; 468 return false;
465 } 469 }
466 470
467 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matr ix, 471 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matr ix,
468 SkRect::Make(colorBounds)); 472 SkRect::Make(colorBounds));
469 offset->fX = bounds.left(); 473 offset->fX = bounds.left();
470 offset->fY = bounds.top(); 474 offset->fY = bounds.top();
471 WrapTexture(dst, bounds.width(), bounds.height(), result); 475 WrapTexture(dst, bounds.width(), bounds.height(), result);
472 return true; 476 return true;
473 } 477 }
474 478
475 /////////////////////////////////////////////////////////////////////////////// 479 ///////////////////////////////////////////////////////////////////////////////
476 480
477 GrDisplacementMapEffect::GrDisplacementMapEffect( 481 GrDisplacementMapEffect::GrDisplacementMapEffect(
482 GrShaderDataManager*,
478 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector, 483 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector,
479 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector, 484 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector,
480 const SkVector& scale, 485 const SkVector& scale,
481 GrTexture* displacement, 486 GrTexture* displacement,
482 const SkMatrix& offsetMatrix, 487 const SkMatrix& offsetMatrix,
483 GrTexture* color, 488 GrTexture* color,
484 const SkISize& colorDimensions) 489 const SkISize& colorDimensions)
485 : fDisplacementTransform(kLocal_GrCoordSet, offsetMatrix, displacement, 490 : fDisplacementTransform(kLocal_GrCoordSet, offsetMatrix, displacement,
486 GrTextureParams::kNone_FilterMode) 491 GrTextureParams::kNone_FilterMode)
487 , fDisplacementAccess(displacement) 492 , fDisplacementAccess(displacement)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 540 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
536 random->nextRangeU(1, kMaxComponent)); 541 random->nextRangeU(1, kMaxComponent));
537 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = 542 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector =
538 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 543 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
539 random->nextRangeU(1, kMaxComponent)); 544 random->nextRangeU(1, kMaxComponent));
540 SkVector scale = SkVector::Make(random->nextRangeScalar(0, 100.0f), 545 SkVector scale = SkVector::Make(random->nextRangeScalar(0, 100.0f),
541 random->nextRangeScalar(0, 100.0f)); 546 random->nextRangeScalar(0, 100.0f));
542 SkISize colorDimensions; 547 SkISize colorDimensions;
543 colorDimensions.fWidth = random->nextRangeU(0, textures[texIdxColor]->width( )); 548 colorDimensions.fWidth = random->nextRangeU(0, textures[texIdxColor]->width( ));
544 colorDimensions.fHeight = random->nextRangeU(0, textures[texIdxColor]->heigh t()); 549 colorDimensions.fHeight = random->nextRangeU(0, textures[texIdxColor]->heigh t());
545 return GrDisplacementMapEffect::Create(xChannelSelector, yChannelSelector, s cale, 550 GrShaderDataManager shaderDataManager;
551 return GrDisplacementMapEffect::Create(&shaderDataManager,
552 xChannelSelector, yChannelSelector, s cale,
546 textures[texIdxDispl], SkMatrix::I(), 553 textures[texIdxDispl], SkMatrix::I(),
547 textures[texIdxColor], colorDimension s); 554 textures[texIdxColor], colorDimension s);
548 } 555 }
549 556
550 /////////////////////////////////////////////////////////////////////////////// 557 ///////////////////////////////////////////////////////////////////////////////
551 558
552 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc) 559 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc)
553 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector()) 560 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
554 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) { 561 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
555 } 562 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 651 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
645 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 652 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
646 653
647 uint32_t xKey = displacementMap.xChannelSelector(); 654 uint32_t xKey = displacementMap.xChannelSelector();
648 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 655 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
649 656
650 b->add32(xKey | yKey); 657 b->add32(xKey | yKey);
651 } 658 }
652 #endif 659 #endif
653 660
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698