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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 : INHERITED(buffer) | 903 : INHERITED(buffer) |
904 { | 904 { |
905 fKD = buffer.readScalar(); | 905 fKD = buffer.readScalar(); |
906 } | 906 } |
907 | 907 |
908 void SkDiffuseLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) con
st { | 908 void SkDiffuseLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) con
st { |
909 this->INHERITED::flatten(buffer); | 909 this->INHERITED::flatten(buffer); |
910 buffer.writeScalar(fKD); | 910 buffer.writeScalar(fKD); |
911 } | 911 } |
912 | 912 |
913 bool SkDiffuseLightingImageFilter::onFilterImage(Proxy*, | 913 bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy, |
914 const SkBitmap& src, | 914 const SkBitmap& source, |
915 const SkMatrix& ctm, | 915 const SkMatrix& ctm, |
916 SkBitmap* dst, | 916 SkBitmap* dst, |
917 SkIPoint* offset) { | 917 SkIPoint* offset) { |
| 918 SkImageFilter* input = getInput(0); |
| 919 SkBitmap src = source; |
| 920 if (input && !input->filterImage(proxy, source, ctm, &src, offset)) { |
| 921 return false; |
| 922 } |
| 923 |
918 if (src.config() != SkBitmap::kARGB_8888_Config) { | 924 if (src.config() != SkBitmap::kARGB_8888_Config) { |
919 return false; | 925 return false; |
920 } | 926 } |
921 SkAutoLockPixels alp(src); | 927 SkAutoLockPixels alp(src); |
922 if (!src.getPixels()) { | 928 if (!src.getPixels()) { |
923 return false; | 929 return false; |
924 } | 930 } |
925 | 931 |
926 SkIRect bounds; | 932 SkIRect bounds; |
927 src.getBounds(&bounds); | 933 src.getBounds(&bounds); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 fKS = buffer.readScalar(); | 987 fKS = buffer.readScalar(); |
982 fShininess = buffer.readScalar(); | 988 fShininess = buffer.readScalar(); |
983 } | 989 } |
984 | 990 |
985 void SkSpecularLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) co
nst { | 991 void SkSpecularLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) co
nst { |
986 this->INHERITED::flatten(buffer); | 992 this->INHERITED::flatten(buffer); |
987 buffer.writeScalar(fKS); | 993 buffer.writeScalar(fKS); |
988 buffer.writeScalar(fShininess); | 994 buffer.writeScalar(fShininess); |
989 } | 995 } |
990 | 996 |
991 bool SkSpecularLightingImageFilter::onFilterImage(Proxy*, | 997 bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy, |
992 const SkBitmap& src, | 998 const SkBitmap& source, |
993 const SkMatrix& ctm, | 999 const SkMatrix& ctm, |
994 SkBitmap* dst, | 1000 SkBitmap* dst, |
995 SkIPoint* offset) { | 1001 SkIPoint* offset) { |
| 1002 SkImageFilter* input = getInput(0); |
| 1003 SkBitmap src = source; |
| 1004 if (input && !input->filterImage(proxy, source, ctm, &src, offset)) { |
| 1005 return false; |
| 1006 } |
| 1007 |
996 if (src.config() != SkBitmap::kARGB_8888_Config) { | 1008 if (src.config() != SkBitmap::kARGB_8888_Config) { |
997 return false; | 1009 return false; |
998 } | 1010 } |
999 SkAutoLockPixels alp(src); | 1011 SkAutoLockPixels alp(src); |
1000 if (!src.getPixels()) { | 1012 if (!src.getPixels()) { |
1001 return false; | 1013 return false; |
1002 } | 1014 } |
1003 | 1015 |
1004 SkIRect bounds; | 1016 SkIRect bounds; |
1005 src.getBounds(&bounds); | 1017 src.getBounds(&bounds); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 | 1582 |
1571 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1583 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
1572 } | 1584 } |
1573 | 1585 |
1574 #endif | 1586 #endif |
1575 | 1587 |
1576 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1588 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1589 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1590 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1579 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1591 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |