| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 colorBounds.offset(-colorOffset); | 258 colorBounds.offset(-colorOffset); |
| 259 | 259 |
| 260 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, | 260 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, |
| 261 &displ, colorOffset - displOffset, &color, colorBounds); | 261 &displ, colorOffset - displOffset, &color, colorBounds); |
| 262 | 262 |
| 263 offset->fX = bounds.left(); | 263 offset->fX = bounds.left(); |
| 264 offset->fY = bounds.top(); | 264 offset->fY = bounds.top(); |
| 265 return true; | 265 return true; |
| 266 } | 266 } |
| 267 | 267 |
| 268 void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst)
const { | 268 SkRect SkDisplacementMapEffect::computeFastBounds(const SkRect& src) const { |
| 269 if (this->getColorInput()) { | 269 SkRect bounds = this->getColorInput() ? this->getColorInput()->computeFastBo
unds(src) : src; |
| 270 this->getColorInput()->computeFastBounds(src, dst); | 270 bounds.outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_
ScalarHalf); |
| 271 } else { | 271 return bounds; |
| 272 *dst = src; | |
| 273 } | |
| 274 dst->outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_Sc
alarHalf); | |
| 275 } | 272 } |
| 276 | 273 |
| 277 void SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMat
rix& ctm, | 274 SkIRect SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const Sk
Matrix& ctm, |
| 278 SkIRect* dst, MapDirection) const { | 275 MapDirection) const { |
| 279 *dst = src; | |
| 280 SkVector scale = SkVector::Make(fScale, fScale); | 276 SkVector scale = SkVector::Make(fScale, fScale); |
| 281 ctm.mapVectors(&scale, 1); | 277 ctm.mapVectors(&scale, 1); |
| 282 dst->outset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf), | 278 return src.makeOutset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHal
f), |
| 283 SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf)); | 279 SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHal
f)); |
| 284 } | 280 } |
| 285 | 281 |
| 286 bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, | 282 SkIRect SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatr
ix& ctm, |
| 287 SkIRect* dst, MapDirection directio
n) const { | 283 MapDirection direction) const { |
| 288 // Recurse only into color input. | 284 // Recurse only into color input. |
| 289 if (this->getColorInput()) { | 285 if (this->getColorInput()) { |
| 290 return this->getColorInput()->filterBounds(src, ctm, dst, direction); | 286 return this->getColorInput()->filterBounds(src, ctm, direction); |
| 291 } | 287 } |
| 292 *dst = src; | 288 return src; |
| 293 return true; | |
| 294 } | 289 } |
| 295 | 290 |
| 296 #ifndef SK_IGNORE_TO_STRING | 291 #ifndef SK_IGNORE_TO_STRING |
| 297 void SkDisplacementMapEffect::toString(SkString* str) const { | 292 void SkDisplacementMapEffect::toString(SkString* str) const { |
| 298 str->appendf("SkDisplacementMapEffect: ("); | 293 str->appendf("SkDisplacementMapEffect: ("); |
| 299 str->appendf("scale: %f ", fScale); | 294 str->appendf("scale: %f ", fScale); |
| 300 str->appendf("displacement: ("); | 295 str->appendf("displacement: ("); |
| 301 if (this->getDisplacementInput()) { | 296 if (this->getDisplacementInput()) { |
| 302 this->getDisplacementInput()->toString(str); | 297 this->getDisplacementInput()->toString(str); |
| 303 } | 298 } |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 625 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
| 631 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 626 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 632 | 627 |
| 633 uint32_t xKey = displacementMap.xChannelSelector(); | 628 uint32_t xKey = displacementMap.xChannelSelector(); |
| 634 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 629 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 635 | 630 |
| 636 b->add32(xKey | yKey); | 631 b->add32(xKey | yKey); |
| 637 } | 632 } |
| 638 #endif | 633 #endif |
| 639 | 634 |
| OLD | NEW |