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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 } | 1019 } |
1020 return true; | 1020 return true; |
1021 } | 1021 } |
1022 #endif | 1022 #endif |
1023 | 1023 |
1024 /////////////////////////////////////////////////////////////////////////////// | 1024 /////////////////////////////////////////////////////////////////////////////// |
1025 | 1025 |
1026 #if SK_SUPPORT_GPU | 1026 #if SK_SUPPORT_GPU |
1027 | 1027 |
1028 namespace { | 1028 namespace { |
1029 SkPoint3 random_point3(SkMWCRandom* random) { | 1029 SkPoint3 random_point3(SkRandom* random) { |
1030 return SkPoint3(SkScalarToFloat(random->nextSScalar1()), | 1030 return SkPoint3(SkScalarToFloat(random->nextSScalar1()), |
1031 SkScalarToFloat(random->nextSScalar1()), | 1031 SkScalarToFloat(random->nextSScalar1()), |
1032 SkScalarToFloat(random->nextSScalar1())); | 1032 SkScalarToFloat(random->nextSScalar1())); |
1033 } | 1033 } |
1034 | 1034 |
1035 SkLight* create_random_light(SkMWCRandom* random) { | 1035 SkLight* create_random_light(SkRandom* random) { |
1036 int type = random->nextULessThan(3); | 1036 int type = random->nextULessThan(3); |
1037 switch (type) { | 1037 switch (type) { |
1038 case 0: { | 1038 case 0: { |
1039 return SkNEW_ARGS(SkDistantLight, (random_point3(random), random->ne
xtU())); | 1039 return SkNEW_ARGS(SkDistantLight, (random_point3(random), random->ne
xtU())); |
1040 } | 1040 } |
1041 case 1: { | 1041 case 1: { |
1042 return SkNEW_ARGS(SkPointLight, (random_point3(random), random->next
U())); | 1042 return SkNEW_ARGS(SkPointLight, (random_point3(random), random->next
U())); |
1043 } | 1043 } |
1044 case 2: { | 1044 case 2: { |
1045 return SkNEW_ARGS(SkSpotLight, (random_point3(random), | 1045 return SkNEW_ARGS(SkSpotLight, (random_point3(random), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 } | 1161 } |
1162 | 1162 |
1163 bool GrDiffuseLightingEffect::onIsEqual(const GrEffect& sBase) const { | 1163 bool GrDiffuseLightingEffect::onIsEqual(const GrEffect& sBase) const { |
1164 const GrDiffuseLightingEffect& s = CastEffect<GrDiffuseLightingEffect>(sBase
); | 1164 const GrDiffuseLightingEffect& s = CastEffect<GrDiffuseLightingEffect>(sBase
); |
1165 return INHERITED::onIsEqual(sBase) && | 1165 return INHERITED::onIsEqual(sBase) && |
1166 this->kd() == s.kd(); | 1166 this->kd() == s.kd(); |
1167 } | 1167 } |
1168 | 1168 |
1169 GR_DEFINE_EFFECT_TEST(GrDiffuseLightingEffect); | 1169 GR_DEFINE_EFFECT_TEST(GrDiffuseLightingEffect); |
1170 | 1170 |
1171 GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkMWCRandom* random, | 1171 GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkRandom* random, |
1172 GrContext* context, | 1172 GrContext* context, |
1173 const GrDrawTargetCaps&, | 1173 const GrDrawTargetCaps&, |
1174 GrTexture* textures[]) { | 1174 GrTexture* textures[]) { |
1175 SkScalar surfaceScale = random->nextSScalar1(); | 1175 SkScalar surfaceScale = random->nextSScalar1(); |
1176 SkScalar kd = random->nextUScalar1(); | 1176 SkScalar kd = random->nextUScalar1(); |
1177 SkAutoTUnref<SkLight> light(create_random_light(random)); | 1177 SkAutoTUnref<SkLight> light(create_random_light(random)); |
1178 SkMatrix matrix; | 1178 SkMatrix matrix; |
1179 for (int i = 0; i < 9; i++) { | 1179 for (int i = 0; i < 9; i++) { |
1180 matrix[i] = random->nextUScalar1(); | 1180 matrix[i] = random->nextUScalar1(); |
1181 } | 1181 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1379 |
1380 bool GrSpecularLightingEffect::onIsEqual(const GrEffect& sBase) const { | 1380 bool GrSpecularLightingEffect::onIsEqual(const GrEffect& sBase) const { |
1381 const GrSpecularLightingEffect& s = CastEffect<GrSpecularLightingEffect>(sBa
se); | 1381 const GrSpecularLightingEffect& s = CastEffect<GrSpecularLightingEffect>(sBa
se); |
1382 return INHERITED::onIsEqual(sBase) && | 1382 return INHERITED::onIsEqual(sBase) && |
1383 this->ks() == s.ks() && | 1383 this->ks() == s.ks() && |
1384 this->shininess() == s.shininess(); | 1384 this->shininess() == s.shininess(); |
1385 } | 1385 } |
1386 | 1386 |
1387 GR_DEFINE_EFFECT_TEST(GrSpecularLightingEffect); | 1387 GR_DEFINE_EFFECT_TEST(GrSpecularLightingEffect); |
1388 | 1388 |
1389 GrEffectRef* GrSpecularLightingEffect::TestCreate(SkMWCRandom* random, | 1389 GrEffectRef* GrSpecularLightingEffect::TestCreate(SkRandom* random, |
1390 GrContext* context, | 1390 GrContext* context, |
1391 const GrDrawTargetCaps&, | 1391 const GrDrawTargetCaps&, |
1392 GrTexture* textures[]) { | 1392 GrTexture* textures[]) { |
1393 SkScalar surfaceScale = random->nextSScalar1(); | 1393 SkScalar surfaceScale = random->nextSScalar1(); |
1394 SkScalar ks = random->nextUScalar1(); | 1394 SkScalar ks = random->nextUScalar1(); |
1395 SkScalar shininess = random->nextUScalar1(); | 1395 SkScalar shininess = random->nextUScalar1(); |
1396 SkAutoTUnref<SkLight> light(create_random_light(random)); | 1396 SkAutoTUnref<SkLight> light(create_random_light(random)); |
1397 SkMatrix matrix; | 1397 SkMatrix matrix; |
1398 for (int i = 0; i < 9; i++) { | 1398 for (int i = 0; i < 9; i++) { |
1399 matrix[i] = random->nextUScalar1(); | 1399 matrix[i] = random->nextUScalar1(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 | 1564 |
1565 #endif | 1565 #endif |
1566 | 1566 |
1567 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1567 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1568 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1568 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1569 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1569 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1570 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight) | 1570 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight) |
1571 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight) | 1571 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight) |
1572 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight) | 1572 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight) |
1573 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1573 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |