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 "GrRenderTargetContext.h" | 19 #include "GrRenderTargetContext.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 "GrTextureProxy.h" |
24 #include "SkGr.h" | 25 #include "SkGr.h" |
25 #include "SkGrPriv.h" | 26 #include "SkGrPriv.h" |
26 #include "effects/GrSingleTextureEffect.h" | 27 #include "effects/GrSingleTextureEffect.h" |
27 #include "effects/GrTextureDomain.h" | 28 #include "effects/GrTextureDomain.h" |
28 #include "glsl/GrGLSLFragmentProcessor.h" | 29 #include "glsl/GrGLSLFragmentProcessor.h" |
29 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 30 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
30 #include "glsl/GrGLSLProgramDataManager.h" | 31 #include "glsl/GrGLSLProgramDataManager.h" |
31 #include "glsl/GrGLSLUniformHandler.h" | 32 #include "glsl/GrGLSLUniformHandler.h" |
32 | 33 |
33 class GrGLDiffuseLightingEffect; | 34 class GrGLDiffuseLightingEffect; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 const SkIRect& offsetBounds, | 407 const SkIRect& offsetBounds, |
407 const SkMatrix& matrix, | 408 const SkMatrix& matrix, |
408 const OutputProperties& outpu
tProperties) const { | 409 const OutputProperties& outpu
tProperties) const { |
409 SkASSERT(source->isTextureBacked()); | 410 SkASSERT(source->isTextureBacked()); |
410 | 411 |
411 GrContext* context = source->getContext(); | 412 GrContext* context = source->getContext(); |
412 | 413 |
413 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); | 414 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); |
414 SkASSERT(inputTexture); | 415 SkASSERT(inputTexture); |
415 | 416 |
416 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetCo
ntext( | 417 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRender
TargetContext( |
417 SkBackingFit::kApprox,offsetBounds.width(), offsetBounds.height(), | 418 SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(), |
418 GrRenderableConfigForColorSpace(outputProperties.colorSpace()), | 419 GrRenderableConfigForColorSpace(outputProperties.colorSpace()), |
419 sk_ref_sp(outputProperties.colorSpace()))); | 420 sk_ref_sp(outputProperties.colorSpace()))); |
420 if (!renderTargetContext) { | 421 if (!renderTargetContext) { |
421 return nullptr; | 422 return nullptr; |
422 } | 423 } |
423 | 424 |
424 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); | 425 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); |
425 SkRect dstRect = SkRect::Make(dstIRect); | 426 SkRect dstRect = SkRect::Make(dstIRect); |
426 | 427 |
427 // setup new clip | 428 // setup new clip |
(...skipping 23 matching lines...) Expand all Loading... |
451 kInterior_BoundaryMode, pSrcBounds, offsetBounds); | 452 kInterior_BoundaryMode, pSrcBounds, offsetBounds); |
452 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
right, | 453 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
right, |
453 kRight_BoundaryMode, pSrcBounds, offsetBounds); | 454 kRight_BoundaryMode, pSrcBounds, offsetBounds); |
454 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottomLeft, | 455 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottomLeft, |
455 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); | 456 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); |
456 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottom, | 457 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottom, |
457 kBottom_BoundaryMode, pSrcBounds, offsetBounds); | 458 kBottom_BoundaryMode, pSrcBounds, offsetBounds); |
458 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottomRight, | 459 this->drawRect(renderTargetContext.get(), inputTexture.get(), matrix, clip,
bottomRight, |
459 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); | 460 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); |
460 | 461 |
461 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off
setBounds.height()), | 462 return SkSpecialImage::MakeDeferredFromGpu(SkIRect::MakeWH(offsetBounds.widt
h(), |
462 kNeedNewImageUniqueID_SpecialImage, | 463 offsetBounds.heig
ht()), |
463 renderTargetContext->asTexture(), | 464 kNeedNewImageUniqueID_SpecialImag
e, |
464 sk_ref_sp(renderTargetContext->getColorSp
ace())); | 465 renderTargetContext->asDeferredTe
xture(), |
| 466 sk_ref_sp(renderTargetContext->ge
tColorSpace())); |
465 } | 467 } |
466 #endif | 468 #endif |
467 | 469 |
468 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { | 470 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { |
469 public: | 471 public: |
470 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, | 472 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, |
471 SkScalar surfaceScale, | 473 SkScalar surfaceScale, |
472 SkScalar kd, | 474 SkScalar kd, |
473 sk_sp<SkImageFilter>, | 475 sk_sp<SkImageFilter>, |
474 const CropRect*); | 476 const CropRect*); |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 | 2177 |
2176 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2178 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
2177 } | 2179 } |
2178 | 2180 |
2179 #endif | 2181 #endif |
2180 | 2182 |
2181 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2183 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
2182 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2184 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
2183 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2185 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
2184 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2186 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |