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

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

Issue 101623007: Fixed more issues (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed conflict with senorblanco's cl Created 7 years 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 | « gm/displacement.cpp ('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 "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
10 #include "SkUnPreMultiply.h" 10 #include "SkUnPreMultiply.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 SkAutoLockPixels alp_displacement(displ), alp_color(color); 199 SkAutoLockPixels alp_displacement(displ), alp_color(color);
200 if (!displ.getPixels() || !color.getPixels()) { 200 if (!displ.getPixels() || !color.getPixels()) {
201 return false; 201 return false;
202 } 202 }
203 SkIRect bounds; 203 SkIRect bounds;
204 color.getBounds(&bounds); 204 color.getBounds(&bounds);
205 if (!this->applyCropRect(&bounds, ctm)) { 205 if (!this->applyCropRect(&bounds, ctm)) {
206 return false; 206 return false;
207 } 207 }
208 SkIRect displBounds;
209 displ.getBounds(&displBounds);
210 if (!this->applyCropRect(&displBounds, ctm)) {
211 return false;
212 }
213 if (!bounds.intersect(displBounds)) {
214 return false;
215 }
208 216
209 dst->setConfig(color.config(), bounds.width(), bounds.height()); 217 dst->setConfig(color.config(), bounds.width(), bounds.height());
210 dst->allocPixels(); 218 dst->allocPixels();
211 if (!dst->getPixels()) { 219 if (!dst->getPixels()) {
212 return false; 220 return false;
213 } 221 }
214 222
215 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds); 223 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds);
216 224
217 offset->fX += bounds.left(); 225 offset->fX += bounds.left();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 GrDisplacementMapEffect::Create(fXChannelSelector, 339 GrDisplacementMapEffect::Create(fXChannelSelector,
332 fYChannelSelector, 340 fYChannelSelector,
333 fScale, 341 fScale,
334 displacement, 342 displacement,
335 color))->unref(); 343 color))->unref();
336 SkIRect bounds; 344 SkIRect bounds;
337 src.getBounds(&bounds); 345 src.getBounds(&bounds);
338 if (!this->applyCropRect(&bounds, ctm)) { 346 if (!this->applyCropRect(&bounds, ctm)) {
339 return false; 347 return false;
340 } 348 }
349 SkIRect displBounds;
350 displacementBM.getBounds(&displBounds);
351 if (!this->applyCropRect(&displBounds, ctm)) {
352 return false;
353 }
354 if (!bounds.intersect(displBounds)) {
355 return false;
356 }
341 SkRect srcRect = SkRect::Make(bounds); 357 SkRect srcRect = SkRect::Make(bounds);
342 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); 358 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
343 context->drawRectToRect(paint, dstRect, srcRect); 359 context->drawRectToRect(paint, dstRect, srcRect);
344 offset->fX += bounds.left(); 360 offset->fX += bounds.left();
345 offset->fY += bounds.top(); 361 offset->fY += bounds.top();
346 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result); 362 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result);
347 } 363 }
348 364
349 /////////////////////////////////////////////////////////////////////////////// 365 ///////////////////////////////////////////////////////////////////////////////
350 366
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 const GrGLCaps&) { 540 const GrGLCaps&) {
525 const GrDisplacementMapEffect& displacementMap = 541 const GrDisplacementMapEffect& displacementMap =
526 drawEffect.castEffect<GrDisplacementMapEffect>(); 542 drawEffect.castEffect<GrDisplacementMapEffect>();
527 543
528 EffectKey xKey = displacementMap.xChannelSelector(); 544 EffectKey xKey = displacementMap.xChannelSelector();
529 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits; 545 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits;
530 546
531 return xKey | yKey; 547 return xKey | yKey;
532 } 548 }
533 #endif 549 #endif
OLDNEW
« no previous file with comments | « gm/displacement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698