| 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 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
rce, | 272 sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
rce, |
| 273 const Context& ctx, | 273 const Context& ctx, |
| 274 SkIPoint* offset) c
onst { | 274 SkIPoint* offset) c
onst { |
| 275 SkIPoint colorOffset = SkIPoint::Make(0, 0); | 275 SkIPoint colorOffset = SkIPoint::Make(0, 0); |
| 276 sk_sp<SkSpecialImage> color(this->filterInput(1, source, ctx, &colorOffset))
; | 276 sk_sp<SkSpecialImage> color(this->filterInput(1, source, ctx, &colorOffset))
; |
| 277 if (!color) { | 277 if (!color) { |
| 278 return nullptr; | 278 return nullptr; |
| 279 } | 279 } |
| 280 | 280 |
| 281 SkIPoint displOffset = SkIPoint::Make(0, 0); | 281 SkIPoint displOffset = SkIPoint::Make(0, 0); |
| 282 // Creation of the displacement map should happen in a non-colorspace aware
context. This | 282 sk_sp<SkSpecialImage> displ(this->filterInput(0, source, ctx, &displOffset))
; |
| 283 // texture is a purely mathematical construct, so we want to just operate on
the stored | |
| 284 // values. Consider: | |
| 285 // User supplies an sRGB displacement map. If we're rendering to a wider gam
ut, then we could | |
| 286 // end up filtering the displacement map into that gamut, which has the effe
ct of reducing | |
| 287 // the amount of displacement that it represents (as encoded values move awa
y from the | |
| 288 // primaries). | |
| 289 // With a more complex DAG attached to this input, it's not clear that worki
ng in ANY specific | |
| 290 // color space makes sense, so we ignore color spaces (and gamma) entirely.
This may not be | |
| 291 // ideal, but it's at least consistent and predictable. | |
| 292 Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(), OutputPropert
ies(nullptr)); | |
| 293 sk_sp<SkSpecialImage> displ(this->filterInput(0, source, displContext, &disp
lOffset)); | |
| 294 if (!displ) { | 283 if (!displ) { |
| 295 return nullptr; | 284 return nullptr; |
| 296 } | 285 } |
| 297 | 286 |
| 298 const SkIRect srcBounds = SkIRect::MakeXYWH(colorOffset.x(), colorOffset.y()
, | 287 const SkIRect srcBounds = SkIRect::MakeXYWH(colorOffset.x(), colorOffset.y()
, |
| 299 color->width(), color->height())
; | 288 color->width(), color->height())
; |
| 300 | 289 |
| 301 // Both paths do bounds checking on color pixel access, we don't need to | 290 // Both paths do bounds checking on color pixel access, we don't need to |
| 302 // pad the color bitmap to bounds here. | 291 // pad the color bitmap to bounds here. |
| 303 SkIRect bounds; | 292 SkIRect bounds; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 622 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
| 634 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 623 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
| 635 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 624 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 636 | 625 |
| 637 uint32_t xKey = displacementMap.xChannelSelector(); | 626 uint32_t xKey = displacementMap.xChannelSelector(); |
| 638 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 627 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 639 | 628 |
| 640 b->add32(xKey | yKey); | 629 b->add32(xKey | yKey); |
| 641 } | 630 } |
| 642 #endif | 631 #endif |
| OLD | NEW |