| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 kInterior_BoundaryMode, pSrcBounds, offsetBounds); | 453 kInterior_BoundaryMode, pSrcBounds, offsetBounds); |
| 454 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, right, k
Right_BoundaryMode, | 454 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, right, k
Right_BoundaryMode, |
| 455 pSrcBounds, offsetBounds); | 455 pSrcBounds, offsetBounds); |
| 456 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe
ft, | 456 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe
ft, |
| 457 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); | 457 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); |
| 458 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom, | 458 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom, |
| 459 kBottom_BoundaryMode, pSrcBounds, offsetBounds); | 459 kBottom_BoundaryMode, pSrcBounds, offsetBounds); |
| 460 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi
ght, | 460 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi
ght, |
| 461 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); | 461 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); |
| 462 | 462 |
| 463 return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), | 463 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off
setBounds.height()), |
| 464 SkIRect::MakeWH(offsetBounds.width(), off
setBounds.height()), | |
| 465 kNeedNewImageUniqueID_SpecialImage, | 464 kNeedNewImageUniqueID_SpecialImage, |
| 466 dst.get()); | 465 dst.get()); |
| 467 } | 466 } |
| 468 #endif | 467 #endif |
| 469 | 468 |
| 470 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { | 469 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { |
| 471 public: | 470 public: |
| 472 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, | 471 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, |
| 473 SkScalar surfaceScale, | 472 SkScalar surfaceScale, |
| 474 SkScalar kd, | 473 SkScalar kd, |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 case SkImageFilterLight::kSpot_LightType: | 1318 case SkImageFilterLight::kSpot_LightType: |
| 1320 lightBitmap<DiffuseLightingType, SkSpotLight>(lightingType, | 1319 lightBitmap<DiffuseLightingType, SkSpotLight>(lightingType, |
| 1321 transformedLight.get()
, | 1320 transformedLight.get()
, |
| 1322 inputBM, | 1321 inputBM, |
| 1323 &dst, | 1322 &dst, |
| 1324 surfaceScale(), | 1323 surfaceScale(), |
| 1325 bounds); | 1324 bounds); |
| 1326 break; | 1325 break; |
| 1327 } | 1326 } |
| 1328 | 1327 |
| 1329 return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), | 1328 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), |
| 1330 SkIRect::MakeWH(bounds.width(), bounds
.height()), | |
| 1331 dst); | 1329 dst); |
| 1332 } | 1330 } |
| 1333 | 1331 |
| 1334 #ifndef SK_IGNORE_TO_STRING | 1332 #ifndef SK_IGNORE_TO_STRING |
| 1335 void SkDiffuseLightingImageFilter::toString(SkString* str) const { | 1333 void SkDiffuseLightingImageFilter::toString(SkString* str) const { |
| 1336 str->appendf("SkDiffuseLightingImageFilter: ("); | 1334 str->appendf("SkDiffuseLightingImageFilter: ("); |
| 1337 str->appendf("kD: %f\n", fKD); | 1335 str->appendf("kD: %f\n", fKD); |
| 1338 str->append(")"); | 1336 str->append(")"); |
| 1339 } | 1337 } |
| 1340 #endif | 1338 #endif |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 case SkImageFilterLight::kSpot_LightType: | 1484 case SkImageFilterLight::kSpot_LightType: |
| 1487 lightBitmap<SpecularLightingType, SkSpotLight>(lightingType, | 1485 lightBitmap<SpecularLightingType, SkSpotLight>(lightingType, |
| 1488 transformedLight.get(
), | 1486 transformedLight.get(
), |
| 1489 inputBM, | 1487 inputBM, |
| 1490 &dst, | 1488 &dst, |
| 1491 surfaceScale(), | 1489 surfaceScale(), |
| 1492 bounds); | 1490 bounds); |
| 1493 break; | 1491 break; |
| 1494 } | 1492 } |
| 1495 | 1493 |
| 1496 return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), | 1494 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), dst); |
| 1497 SkIRect::MakeWH(bounds.width(), bounds
.height()), | |
| 1498 dst); | |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 #ifndef SK_IGNORE_TO_STRING | 1497 #ifndef SK_IGNORE_TO_STRING |
| 1502 void SkSpecularLightingImageFilter::toString(SkString* str) const { | 1498 void SkSpecularLightingImageFilter::toString(SkString* str) const { |
| 1503 str->appendf("SkSpecularLightingImageFilter: ("); | 1499 str->appendf("SkSpecularLightingImageFilter: ("); |
| 1504 str->appendf("kS: %f shininess: %f", fKS, fShininess); | 1500 str->appendf("kS: %f shininess: %f", fKS, fShininess); |
| 1505 str->append(")"); | 1501 str->append(")"); |
| 1506 } | 1502 } |
| 1507 #endif | 1503 #endif |
| 1508 | 1504 |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 | 2171 |
| 2176 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2172 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
| 2177 } | 2173 } |
| 2178 | 2174 |
| 2179 #endif | 2175 #endif |
| 2180 | 2176 |
| 2181 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2177 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
| 2182 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
| 2183 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
| 2184 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |