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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 bounds.offset(srcOffset); | 945 bounds.offset(srcOffset); |
946 if (!this->applyCropRect(&bounds, ctm)) { | 946 if (!this->applyCropRect(&bounds, ctm)) { |
947 return false; | 947 return false; |
948 } | 948 } |
949 | 949 |
950 if (bounds.width() < 2 || bounds.height() < 2) { | 950 if (bounds.width() < 2 || bounds.height() < 2) { |
951 return false; | 951 return false; |
952 } | 952 } |
953 | 953 |
954 dst->setConfig(src.config(), bounds.width(), bounds.height()); | 954 dst->setConfig(src.config(), bounds.width(), bounds.height()); |
955 dst->allocPixels(); | 955 if (!dst->allocPixels()) { |
956 if (!dst->getPixels()) { | |
957 return false; | 956 return false; |
958 } | 957 } |
959 | 958 |
960 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctm)); | 959 SkAutoTUnref<SkLight> transformedLight(light()->transform(ctm)); |
961 | 960 |
962 DiffuseLightingType lightingType(fKD); | 961 DiffuseLightingType lightingType(fKD); |
963 offset->fX = bounds.left(); | 962 offset->fX = bounds.left(); |
964 offset->fY = bounds.top(); | 963 offset->fY = bounds.top(); |
965 bounds.offset(-srcOffset); | 964 bounds.offset(-srcOffset); |
966 switch (transformedLight->type()) { | 965 switch (transformedLight->type()) { |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 | 1607 |
1609 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1608 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
1610 } | 1609 } |
1611 | 1610 |
1612 #endif | 1611 #endif |
1613 | 1612 |
1614 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1613 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1615 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1614 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1616 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1615 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1617 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1616 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |