| 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" |
| 11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
| 12 #include "SkSpecialImage.h" | 12 #include "SkSpecialImage.h" |
| 13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 14 #include "SkUnPreMultiply.h" | 14 #include "SkUnPreMultiply.h" |
| 15 #include "SkColorPriv.h" | 15 #include "SkColorPriv.h" |
| 16 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
| 17 #include "GrContext.h" | 17 #include "GrContext.h" |
| 18 #include "GrDrawContext.h" | 18 #include "GrDrawContext.h" |
| 19 #include "GrCoordTransform.h" | 19 #include "GrCoordTransform.h" |
| 20 #include "GrInvariantOutput.h" | 20 #include "GrInvariantOutput.h" |
| 21 #include "SkGr.h" | 21 #include "SkGr.h" |
| 22 #include "SkGrPriv.h" |
| 22 #include "effects/GrTextureDomain.h" | 23 #include "effects/GrTextureDomain.h" |
| 23 #include "glsl/GrGLSLFragmentProcessor.h" | 24 #include "glsl/GrGLSLFragmentProcessor.h" |
| 24 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 25 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 25 #include "glsl/GrGLSLProgramDataManager.h" | 26 #include "glsl/GrGLSLProgramDataManager.h" |
| 26 #include "glsl/GrGLSLUniformHandler.h" | 27 #include "glsl/GrGLSLUniformHandler.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at
most | 32 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at
most |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 displTexture.get(), | 331 displTexture.get(), |
| 331 offsetMatrix, | 332 offsetMatrix, |
| 332 colorTexture.get(), | 333 colorTexture.get(), |
| 333 SkISize::Make(color->width(), color->h
eight()))); | 334 SkISize::Make(color->width(), color->h
eight()))); |
| 334 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 335 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 335 SkMatrix matrix; | 336 SkMatrix matrix; |
| 336 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colo
rBounds.y())); | 337 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colo
rBounds.y())); |
| 337 | 338 |
| 338 sk_sp<GrDrawContext> drawContext( | 339 sk_sp<GrDrawContext> drawContext( |
| 339 context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), boun
ds.height(), | 340 context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), boun
ds.height(), |
| 340 kSkia8888_GrPixelConfig, sk_ref_sp(source->
getColorSpace()))); | 341 GrRenderableConfigForColorSpace(source->get
ColorSpace()), |
| 342 sk_ref_sp(source->getColorSpace()))); |
| 341 if (!drawContext) { | 343 if (!drawContext) { |
| 342 return nullptr; | 344 return nullptr; |
| 343 } | 345 } |
| 344 | 346 |
| 345 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(colorBound
s)); | 347 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(colorBound
s)); |
| 346 | 348 |
| 347 offset->fX = bounds.left(); | 349 offset->fX = bounds.left(); |
| 348 offset->fY = bounds.top(); | 350 offset->fY = bounds.top(); |
| 349 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), | 351 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), |
| 350 kNeedNewImageUniqueID_SpecialImage, | 352 kNeedNewImageUniqueID_SpecialImage, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 620 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
| 619 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 621 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
| 620 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 622 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 621 | 623 |
| 622 uint32_t xKey = displacementMap.xChannelSelector(); | 624 uint32_t xKey = displacementMap.xChannelSelector(); |
| 623 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 625 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 624 | 626 |
| 625 b->add32(xKey | yKey); | 627 b->add32(xKey | yKey); |
| 626 } | 628 } |
| 627 #endif | 629 #endif |
| OLD | NEW |