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

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

Issue 1616663003: Fix bounds computations for SkDisplacementMapEffect with negative scale. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix onComputeFastBounds() as well Created 4 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
« 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 "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 offset->fY = bounds.top(); 262 offset->fY = bounds.top();
263 return true; 263 return true;
264 } 264 }
265 265
266 void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const { 266 void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
267 if (this->getColorInput()) { 267 if (this->getColorInput()) {
268 this->getColorInput()->computeFastBounds(src, dst); 268 this->getColorInput()->computeFastBounds(src, dst);
269 } else { 269 } else {
270 *dst = src; 270 *dst = src;
271 } 271 }
272 dst->outset(fScale * SK_ScalarHalf, fScale * SK_ScalarHalf); 272 dst->outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_Sc alarHalf);
273 } 273 }
274 274
275 void SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMat rix& ctm, 275 void SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMat rix& ctm,
276 SkIRect* dst, MapDirection) const { 276 SkIRect* dst, MapDirection) const {
277 *dst = src; 277 *dst = src;
278 SkVector scale = SkVector::Make(fScale, fScale); 278 SkVector scale = SkVector::Make(fScale, fScale);
279 ctm.mapVectors(&scale, 1); 279 ctm.mapVectors(&scale, 1);
280 dst->outset(SkScalarCeilToInt(scale.fX * SK_ScalarHalf), 280 dst->outset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
281 SkScalarCeilToInt(scale.fY * SK_ScalarHalf)); 281 SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
282 } 282 }
283 283
284 bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, 284 bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
285 SkIRect* dst) const { 285 SkIRect* dst) const {
286 SkIRect bounds; 286 SkIRect bounds;
287 this->onFilterNodeBounds(src, ctm, &bounds, kReverse_MapDirection); 287 this->onFilterNodeBounds(src, ctm, &bounds, kReverse_MapDirection);
288 if (this->getColorInput()) { 288 if (this->getColorInput()) {
289 return this->getColorInput()->filterBounds(bounds, ctm, dst); 289 return this->getColorInput()->filterBounds(bounds, ctm, dst);
290 } 290 }
291 *dst = bounds; 291 *dst = bounds;
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 641 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
642 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 642 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
643 643
644 uint32_t xKey = displacementMap.xChannelSelector(); 644 uint32_t xKey = displacementMap.xChannelSelector();
645 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 645 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
646 646
647 b->add32(xKey | yKey); 647 b->add32(xKey | yKey);
648 } 648 }
649 #endif 649 #endif
650 650
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