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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 953 |
954 if (bounds.width() < 2 || bounds.height() < 2) { | 954 if (bounds.width() < 2 || bounds.height() < 2) { |
955 return false; | 955 return false; |
956 } | 956 } |
957 | 957 |
958 SkAutoLockPixels alp(src); | 958 SkAutoLockPixels alp(src); |
959 if (!src.getPixels()) { | 959 if (!src.getPixels()) { |
960 return false; | 960 return false; |
961 } | 961 } |
962 | 962 |
963 dst->setConfig(src.config(), bounds.width(), bounds.height()); | 963 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { |
964 if (!dst->allocPixels()) { | |
965 return false; | 964 return false; |
966 } | 965 } |
967 | 966 |
968 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); | 967 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); |
969 | 968 |
970 DiffuseLightingType lightingType(fKD); | 969 DiffuseLightingType lightingType(fKD); |
971 offset->fX = bounds.left(); | 970 offset->fX = bounds.left(); |
972 offset->fY = bounds.top(); | 971 offset->fY = bounds.top(); |
973 bounds.offset(-srcOffset); | 972 bounds.offset(-srcOffset); |
974 switch (transformedLight->type()) { | 973 switch (transformedLight->type()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 | 1044 |
1046 if (bounds.width() < 2 || bounds.height() < 2) { | 1045 if (bounds.width() < 2 || bounds.height() < 2) { |
1047 return false; | 1046 return false; |
1048 } | 1047 } |
1049 | 1048 |
1050 SkAutoLockPixels alp(src); | 1049 SkAutoLockPixels alp(src); |
1051 if (!src.getPixels()) { | 1050 if (!src.getPixels()) { |
1052 return false; | 1051 return false; |
1053 } | 1052 } |
1054 | 1053 |
1055 dst->setConfig(src.config(), bounds.width(), bounds.height()); | 1054 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { |
1056 dst->allocPixels(); | |
1057 if (!dst->getPixels()) { | |
1058 return false; | 1055 return false; |
1059 } | 1056 } |
1060 | 1057 |
1061 SpecularLightingType lightingType(fKS, fShininess); | 1058 SpecularLightingType lightingType(fKS, fShininess); |
1062 offset->fX = bounds.left(); | 1059 offset->fX = bounds.left(); |
1063 offset->fY = bounds.top(); | 1060 offset->fY = bounds.top(); |
1064 bounds.offset(-srcOffset); | 1061 bounds.offset(-srcOffset); |
1065 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); | 1062 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm())); |
1066 switch (transformedLight->type()) { | 1063 switch (transformedLight->type()) { |
1067 case SkLight::kDistant_LightType: | 1064 case SkLight::kDistant_LightType: |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 | 1612 |
1616 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1613 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
1617 } | 1614 } |
1618 | 1615 |
1619 #endif | 1616 #endif |
1620 | 1617 |
1621 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1618 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1622 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1619 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1623 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1620 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1624 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1621 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |