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

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

Issue 939623005: Pass Rendertarget into context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: sampleapp Created 5 years, 10 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/SkBlurMaskFilter.cpp ('k') | src/effects/SkGpuBlurUtils.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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 desc.fHeight = bounds.height(); 422 desc.fHeight = bounds.height();
423 desc.fConfig = kSkia8888_GrPixelConfig; 423 desc.fConfig = kSkia8888_GrPixelConfig;
424 424
425 SkAutoTUnref<GrTexture> dst( 425 SkAutoTUnref<GrTexture> dst(
426 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); 426 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
427 427
428 if (!dst) { 428 if (!dst) {
429 return false; 429 return false;
430 } 430 }
431 431
432 GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
433
434 SkVector scale = SkVector::Make(fScale, fScale); 432 SkVector scale = SkVector::Make(fScale, fScale);
435 ctx.ctm().mapVectors(&scale, 1); 433 ctx.ctm().mapVectors(&scale, 1);
436 434
437 GrPaint paint; 435 GrPaint paint;
438 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent); 436 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent);
439 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), 437 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX),
440 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); 438 SkIntToScalar(colorOffset.fY - displacementOffset. fY));
441 439
442 paint.addColorProcessor( 440 paint.addColorProcessor(
443 GrDisplacementMapEffect::Create(fXChannelSelector, 441 GrDisplacementMapEffect::Create(fXChannelSelector,
444 fYChannelSelector, 442 fYChannelSelector,
445 scale, 443 scale,
446 displacement, 444 displacement,
447 offsetMatrix, 445 offsetMatrix,
448 color))->unref(); 446 color))->unref();
449 SkIRect colorBounds = bounds; 447 SkIRect colorBounds = bounds;
450 colorBounds.offset(-colorOffset); 448 colorBounds.offset(-colorOffset);
451 SkMatrix matrix; 449 SkMatrix matrix;
452 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), 450 matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
453 -SkIntToScalar(colorBounds.y())); 451 -SkIntToScalar(colorBounds.y()));
454 context->drawRect(paint, matrix, SkRect::Make(colorBounds)); 452 context->drawRect(dst->asRenderTarget(), paint, matrix, SkRect::Make(colorBo unds));
455 offset->fX = bounds.left(); 453 offset->fX = bounds.left();
456 offset->fY = bounds.top(); 454 offset->fY = bounds.top();
457 WrapTexture(dst, bounds.width(), bounds.height(), result); 455 WrapTexture(dst, bounds.width(), bounds.height(), result);
458 return true; 456 return true;
459 } 457 }
460 458
461 /////////////////////////////////////////////////////////////////////////////// 459 ///////////////////////////////////////////////////////////////////////////////
462 460
463 GrDisplacementMapEffect::GrDisplacementMapEffect( 461 GrDisplacementMapEffect::GrDisplacementMapEffect(
464 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector, 462 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 const GrGLCaps&, GrProcessorKeyBuilder* b ) { 630 const GrGLCaps&, GrProcessorKeyBuilder* b ) {
633 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 631 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
634 632
635 uint32_t xKey = displacementMap.xChannelSelector(); 633 uint32_t xKey = displacementMap.xChannelSelector();
636 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 634 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
637 635
638 b->add32(xKey | yKey); 636 b->add32(xKey | yKey);
639 } 637 }
640 #endif 638 #endif
641 639
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkGpuBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698