| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1009 |
| 1010 if (bounds.width() < 2 || bounds.height() < 2) { | 1010 if (bounds.width() < 2 || bounds.height() < 2) { |
| 1011 return false; | 1011 return false; |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 SkAutoLockPixels alp(src); | 1014 SkAutoLockPixels alp(src); |
| 1015 if (!src.getPixels()) { | 1015 if (!src.getPixels()) { |
| 1016 return false; | 1016 return false; |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { | 1019 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))
) { |
| 1020 return false; | 1020 return false; |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); | 1023 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); |
| 1024 | 1024 |
| 1025 DiffuseLightingType lightingType(fKD); | 1025 DiffuseLightingType lightingType(fKD); |
| 1026 offset->fX = bounds.left(); | 1026 offset->fX = bounds.left(); |
| 1027 offset->fY = bounds.top(); | 1027 offset->fY = bounds.top(); |
| 1028 bounds.offset(-srcOffset); | 1028 bounds.offset(-srcOffset); |
| 1029 switch (transformedLight->type()) { | 1029 switch (transformedLight->type()) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1127 |
| 1128 if (bounds.width() < 2 || bounds.height() < 2) { | 1128 if (bounds.width() < 2 || bounds.height() < 2) { |
| 1129 return false; | 1129 return false; |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 SkAutoLockPixels alp(src); | 1132 SkAutoLockPixels alp(src); |
| 1133 if (!src.getPixels()) { | 1133 if (!src.getPixels()) { |
| 1134 return false; | 1134 return false; |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { | 1137 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))
) { |
| 1138 return false; | 1138 return false; |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 SpecularLightingType lightingType(fKS, fShininess); | 1141 SpecularLightingType lightingType(fKS, fShininess); |
| 1142 offset->fX = bounds.left(); | 1142 offset->fX = bounds.left(); |
| 1143 offset->fY = bounds.top(); | 1143 offset->fY = bounds.top(); |
| 1144 bounds.offset(-srcOffset); | 1144 bounds.offset(-srcOffset); |
| 1145 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); | 1145 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); |
| 1146 switch (transformedLight->type()) { | 1146 switch (transformedLight->type()) { |
| 1147 case SkLight::kDistant_LightType: | 1147 case SkLight::kDistant_LightType: |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 | 1703 |
| 1704 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1704 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
| 1705 } | 1705 } |
| 1706 | 1706 |
| 1707 #endif | 1707 #endif |
| 1708 | 1708 |
| 1709 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1709 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
| 1710 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1710 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
| 1711 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1711 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
| 1712 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1712 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |