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" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 SkASSERT(source->isTextureBacked()); | 404 SkASSERT(source->isTextureBacked()); |
405 | 405 |
406 GrContext* context = source->getContext(); | 406 GrContext* context = source->getContext(); |
407 | 407 |
408 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); | 408 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); |
409 SkASSERT(inputTexture); | 409 SkASSERT(inputTexture); |
410 | 410 |
411 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, | 411 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, |
412 offsetBounds.width(
), | 412 offsetBounds.width(
), |
413 offsetBounds.height
(), | 413 offsetBounds.height
(), |
414 kRGBA_8888_GrPixelC
onfig)); | 414 kRGBA_8888_GrPixelC
onfig, |
| 415 sk_ref_sp(source->g
etColorSpace()))); |
415 if (!drawContext) { | 416 if (!drawContext) { |
416 return nullptr; | 417 return nullptr; |
417 } | 418 } |
418 | 419 |
419 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); | 420 SkIRect dstIRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height
()); |
420 SkRect dstRect = SkRect::Make(dstIRect); | 421 SkRect dstRect = SkRect::Make(dstIRect); |
421 | 422 |
422 // setup new clip | 423 // setup new clip |
423 GrFixedClip clip(dstIRect); | 424 GrFixedClip clip(dstIRect); |
424 | 425 |
(...skipping 21 matching lines...) Expand all Loading... |
446 kInterior_BoundaryMode, pSrcBounds, offsetBounds); | 447 kInterior_BoundaryMode, pSrcBounds, offsetBounds); |
447 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, right, k
Right_BoundaryMode, | 448 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, right, k
Right_BoundaryMode, |
448 pSrcBounds, offsetBounds); | 449 pSrcBounds, offsetBounds); |
449 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe
ft, | 450 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe
ft, |
450 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); | 451 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); |
451 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom, | 452 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom, |
452 kBottom_BoundaryMode, pSrcBounds, offsetBounds); | 453 kBottom_BoundaryMode, pSrcBounds, offsetBounds); |
453 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi
ght, | 454 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi
ght, |
454 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); | 455 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); |
455 | 456 |
456 // TODO: Get the colorSpace from the drawContext (once it has one) | |
457 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off
setBounds.height()), | 457 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off
setBounds.height()), |
458 kNeedNewImageUniqueID_SpecialImage, | 458 kNeedNewImageUniqueID_SpecialImage, |
459 drawContext->asTexture(), | 459 drawContext->asTexture(), |
460 sk_ref_sp(source->getColorSpace())); | 460 sk_ref_sp(drawContext->getColorSpace())); |
461 } | 461 } |
462 #endif | 462 #endif |
463 | 463 |
464 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { | 464 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { |
465 public: | 465 public: |
466 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, | 466 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, |
467 SkScalar surfaceScale, | 467 SkScalar surfaceScale, |
468 SkScalar kd, | 468 SkScalar kd, |
469 sk_sp<SkImageFilter>, | 469 sk_sp<SkImageFilter>, |
470 const CropRect*); | 470 const CropRect*); |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 | 2170 |
2171 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2171 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
2172 } | 2172 } |
2173 | 2173 |
2174 #endif | 2174 #endif |
2175 | 2175 |
2176 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2176 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
2177 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2177 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
2179 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2179 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |