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

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

Issue 208843002: Revert of Fix GPU displacement with expanding crop rects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 377 }
378 if (!bounds.intersect(displBounds)) { 378 if (!bounds.intersect(displBounds)) {
379 return false; 379 return false;
380 } 380 }
381 GrTexture* color = colorBM.getTexture(); 381 GrTexture* color = colorBM.getTexture();
382 GrTexture* displacement = displacementBM.getTexture(); 382 GrTexture* displacement = displacementBM.getTexture();
383 GrContext* context = color->getContext(); 383 GrContext* context = color->getContext();
384 384
385 GrTextureDesc desc; 385 GrTextureDesc desc;
386 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 386 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
387 desc.fWidth = bounds.width(); 387 desc.fWidth = colorBM.width();
388 desc.fHeight = bounds.height(); 388 desc.fHeight = colorBM.height();
389 desc.fConfig = kSkia8888_GrPixelConfig; 389 desc.fConfig = kSkia8888_GrPixelConfig;
390 390
391 GrAutoScratchTexture ast(context, desc); 391 GrAutoScratchTexture ast(context, desc);
392 SkAutoTUnref<GrTexture> dst(ast.detach()); 392 SkAutoTUnref<GrTexture> dst(ast.detach());
393 393
394 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); 394 GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
395 395
396 SkVector scale = SkVector::Make(fScale, fScale); 396 SkVector scale = SkVector::Make(fScale, fScale);
397 ctx.ctm().mapVectors(&scale, 1); 397 ctx.ctm().mapVectors(&scale, 1);
398 398
399 GrPaint paint; 399 GrPaint paint;
400 SkMatrix offsetMatrix = GrEffect::MakeDivByTextureWHMatrix(displacement); 400 SkMatrix offsetMatrix = GrEffect::MakeDivByTextureWHMatrix(displacement);
401 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), 401 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX),
402 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); 402 SkIntToScalar(colorOffset.fY - displacementOffset. fY));
403 403
404 paint.addColorEffect( 404 paint.addColorEffect(
405 GrDisplacementMapEffect::Create(fXChannelSelector, 405 GrDisplacementMapEffect::Create(fXChannelSelector,
406 fYChannelSelector, 406 fYChannelSelector,
407 scale, 407 scale,
408 displacement, 408 displacement,
409 offsetMatrix, 409 offsetMatrix,
410 color))->unref(); 410 color))->unref();
411 SkIRect colorBounds = bounds; 411 SkIRect colorBounds = bounds;
412 colorBounds.offset(-colorOffset); 412 colorBounds.offset(-colorOffset);
413 GrContext::AutoMatrix am;
414 am.setIdentity(context);
415 SkMatrix matrix; 413 SkMatrix matrix;
416 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), 414 matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
417 -SkIntToScalar(colorBounds.y())); 415 -SkIntToScalar(colorBounds.y()));
418 context->concatMatrix(matrix); 416 context->concatMatrix(matrix);
419 context->drawRect(paint, SkRect::Make(colorBounds)); 417 context->drawRect(paint, SkRect::Make(colorBounds));
420 offset->fX = bounds.left(); 418 offset->fX = bounds.left();
421 offset->fY = bounds.top(); 419 offset->fY = bounds.top();
422 WrapTexture(dst, bounds.width(), bounds.height(), result); 420 WrapTexture(dst, bounds.width(), bounds.height(), result);
423 return true; 421 return true;
424 } 422 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 const GrGLCaps&) { 602 const GrGLCaps&) {
605 const GrDisplacementMapEffect& displacementMap = 603 const GrDisplacementMapEffect& displacementMap =
606 drawEffect.castEffect<GrDisplacementMapEffect>(); 604 drawEffect.castEffect<GrDisplacementMapEffect>();
607 605
608 EffectKey xKey = displacementMap.xChannelSelector(); 606 EffectKey xKey = displacementMap.xChannelSelector();
609 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi ts; 607 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi ts;
610 608
611 return xKey | yKey; 609 return xKey | yKey;
612 } 610 }
613 #endif 611 #endif
OLDNEW
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698