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

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

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 11 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 | « src/effects/SkComposeImageFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.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 "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
10 #include "SkUnPreMultiply.h" 10 #include "SkUnPreMultiply.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 215
216 dst->setConfig(color.config(), bounds.width(), bounds.height()); 216 dst->setConfig(color.config(), bounds.width(), bounds.height());
217 dst->allocPixels(); 217 dst->allocPixels();
218 if (!dst->getPixels()) { 218 if (!dst->getPixels()) {
219 return false; 219 return false;
220 } 220 }
221 221
222 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds); 222 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds);
223 223
224 offset->fX += bounds.left(); 224 offset->fX = bounds.left();
225 offset->fY += bounds.top(); 225 offset->fY = bounds.top();
226 return true; 226 return true;
227 } 227 }
228 228
229 /////////////////////////////////////////////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////////////////
230 230
231 #if SK_SUPPORT_GPU 231 #if SK_SUPPORT_GPU
232 class GrGLDisplacementMapEffect : public GrGLEffect { 232 class GrGLDisplacementMapEffect : public GrGLEffect {
233 public: 233 public:
234 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, 234 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
235 const GrDrawEffect& drawEffect); 235 const GrDrawEffect& drawEffect);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 displacementBM.getBounds(&displBounds); 349 displacementBM.getBounds(&displBounds);
350 if (!this->applyCropRect(&displBounds, ctm)) { 350 if (!this->applyCropRect(&displBounds, ctm)) {
351 return false; 351 return false;
352 } 352 }
353 if (!bounds.intersect(displBounds)) { 353 if (!bounds.intersect(displBounds)) {
354 return false; 354 return false;
355 } 355 }
356 SkRect srcRect = SkRect::Make(bounds); 356 SkRect srcRect = SkRect::Make(bounds);
357 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); 357 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
358 context->drawRectToRect(paint, dstRect, srcRect); 358 context->drawRectToRect(paint, dstRect, srcRect);
359 offset->fX += bounds.left(); 359 offset->fX = bounds.left();
360 offset->fY += bounds.top(); 360 offset->fY = bounds.top();
361 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result); 361 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result);
362 } 362 }
363 363
364 /////////////////////////////////////////////////////////////////////////////// 364 ///////////////////////////////////////////////////////////////////////////////
365 365
366 GrDisplacementMapEffect::GrDisplacementMapEffect( 366 GrDisplacementMapEffect::GrDisplacementMapEffect(
367 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector, 367 SkDisplacementMapEffect::ChannelSelectorType xChann elSelector,
368 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector, 368 SkDisplacementMapEffect::ChannelSelectorType yChann elSelector,
369 SkScalar scale, 369 SkScalar scale,
370 GrTexture* displacement, 370 GrTexture* displacement,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 const GrGLCaps&) { 539 const GrGLCaps&) {
540 const GrDisplacementMapEffect& displacementMap = 540 const GrDisplacementMapEffect& displacementMap =
541 drawEffect.castEffect<GrDisplacementMapEffect>(); 541 drawEffect.castEffect<GrDisplacementMapEffect>();
542 542
543 EffectKey xKey = displacementMap.xChannelSelector(); 543 EffectKey xKey = displacementMap.xChannelSelector();
544 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits; 544 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits;
545 545
546 return xKey | yKey; 546 return xKey | yKey;
547 } 547 }
548 #endif 548 #endif
OLDNEW
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698