| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 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 "SkLightingImageFilter.h" | 8 #include "SkLightingImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkPoint3.h" | 11 #include "SkPoint3.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkSpecialImage.h" | 13 #include "SkSpecialImage.h" |
| 14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
| 16 | 16 |
| 17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 18 #include "GrContext.h" | 18 #include "GrContext.h" |
| 19 #include "GrDrawContext.h" | 19 #include "GrDrawContext.h" |
| 20 #include "GrFixedClip.h" | 20 #include "GrFixedClip.h" |
| 21 #include "GrFragmentProcessor.h" | 21 #include "GrFragmentProcessor.h" |
| 22 #include "GrInvariantOutput.h" | 22 #include "GrInvariantOutput.h" |
| 23 #include "GrPaint.h" | 23 #include "GrPaint.h" |
| 24 #include "SkGr.h" | 24 #include "SkGr.h" |
| 25 #include "SkGrPriv.h" |
| 25 #include "effects/GrSingleTextureEffect.h" | 26 #include "effects/GrSingleTextureEffect.h" |
| 26 #include "effects/GrTextureDomain.h" | 27 #include "effects/GrTextureDomain.h" |
| 27 #include "glsl/GrGLSLFragmentProcessor.h" | 28 #include "glsl/GrGLSLFragmentProcessor.h" |
| 28 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 29 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 29 #include "glsl/GrGLSLProgramDataManager.h" | 30 #include "glsl/GrGLSLProgramDataManager.h" |
| 30 #include "glsl/GrGLSLUniformHandler.h" | 31 #include "glsl/GrGLSLUniformHandler.h" |
| 31 | 32 |
| 32 class GrGLDiffuseLightingEffect; | 33 class GrGLDiffuseLightingEffect; |
| 33 class GrGLSpecularLightingEffect; | 34 class GrGLSpecularLightingEffect; |
| 34 | 35 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 SkSpecialIma
ge* input, | 403 SkSpecialIma
ge* input, |
| 403 const SkIRec
t& offsetBounds, | 404 const SkIRec
t& offsetBounds, |
| 404 const SkMatr
ix& matrix) const { | 405 const SkMatr
ix& matrix) const { |
| 405 SkASSERT(source->isTextureBacked()); | 406 SkASSERT(source->isTextureBacked()); |
| 406 | 407 |
| 407 GrContext* context = source->getContext(); | 408 GrContext* context = source->getContext(); |
| 408 | 409 |
| 409 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); | 410 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); |
| 410 SkASSERT(inputTexture); | 411 SkASSERT(inputTexture); |
| 411 | 412 |
| 412 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp
rox, | 413 sk_sp<GrDrawContext> drawContext( |
| 413 offsetBounds.width
(), | 414 context->makeDrawContext(SkBackingFit::kApprox,offsetBounds.width(), off
setBounds.height(), |
| 414 offsetBounds.heigh
t(), | 415 GrRenderableConfigForColorSpace(source->getColo
rSpace()), |
| 415 kRGBA_8888_GrPixel
Config, | 416 sk_ref_sp(source->getColorSpace()))); |
| 416 sk_ref_sp(source->
getColorSpace()))); | |
| 417 if (!drawContext) { | 417 if (!drawContext) { |
| 418 return nullptr; | 418 return nullptr; |
| 419 } | 419 } |
| 420 | 420 |
| 421 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); | 421 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); |
| 422 SkRect dstRect = SkRect::Make(dstIRect); | 422 SkRect dstRect = SkRect::Make(dstIRect); |
| 423 | 423 |
| 424 // setup new clip | 424 // setup new clip |
| 425 GrFixedClip clip(dstIRect); | 425 GrFixedClip clip(dstIRect); |
| 426 | 426 |
| (...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 | 2171 |
| 2172 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2172 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
| 2173 } | 2173 } |
| 2174 | 2174 |
| 2175 #endif | 2175 #endif |
| 2176 | 2176 |
| 2177 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2177 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
| 2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
| 2179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
| 2180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |