OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkHitTest.h" | 10 #include "SkHitTest.h" |
11 | 11 |
12 #if SK_USE_CONDENSED_INFO == 0 | 12 #if SK_USE_CONDENSED_INFO == 0 |
13 | 13 |
14 const SkMemberInfo SkHitTest::fInfo[] = { | 14 const SkMemberInfo SkHitTest::fInfo[] = { |
15 SK_MEMBER_ARRAY(bullets, Displayable), | 15 SK_MEMBER_ARRAY(bullets, Displayable), |
16 SK_MEMBER_ARRAY(hits, Int), | 16 SK_MEMBER_ARRAY(hits, Int), |
17 SK_MEMBER_ARRAY(targets, Displayable), | 17 SK_MEMBER_ARRAY(targets, Displayable), |
18 SK_MEMBER(value, Boolean) | 18 SK_MEMBER(value, Boolean) |
19 }; | 19 }; |
20 | 20 |
21 #endif | 21 #endif |
22 | 22 |
23 DEFINE_GET_MEMBER(SkHitTest); | 23 DEFINE_GET_MEMBER(SkHitTest); |
24 | 24 |
25 SkHitTest::SkHitTest() : value(false) { | 25 SkHitTest::SkHitTest() : value(false) { |
26 } | 26 } |
27 | 27 |
28 bool SkHitTest::draw(SkAnimateMaker& maker) { | 28 bool SkHitTest::draw(SkAnimateMaker&) { |
29 hits.setCount(bullets.count()); | 29 hits.setCount(bullets.count()); |
30 value = false; | 30 value = false; |
31 int bulletCount = bullets.count(); | 31 int bulletCount = bullets.count(); |
32 int targetCount = targets.count(); | 32 int targetCount = targets.count(); |
33 for (int bIndex = 0; bIndex < bulletCount; bIndex++) { | 33 for (int bIndex = 0; bIndex < bulletCount; bIndex++) { |
34 SkDisplayable* bullet = bullets[bIndex]; | 34 SkDisplayable* bullet = bullets[bIndex]; |
35 SkRect bBounds; | 35 SkRect bBounds; |
36 bullet->getBounds(&bBounds); | 36 bullet->getBounds(&bBounds); |
37 hits[bIndex] = -1; | 37 hits[bIndex] = -1; |
38 if (bBounds.fLeft == (int16_t)0x8000U) | 38 if (bBounds.fLeft == (int16_t)0x8000U) |
39 continue; | 39 continue; |
40 for (int tIndex = 0; tIndex < targetCount; tIndex++) { | 40 for (int tIndex = 0; tIndex < targetCount; tIndex++) { |
41 SkDisplayable* target = targets[tIndex]; | 41 SkDisplayable* target = targets[tIndex]; |
42 SkRect tBounds; | 42 SkRect tBounds; |
43 target->getBounds(&tBounds); | 43 target->getBounds(&tBounds); |
44 if (bBounds.intersect(tBounds)) { | 44 if (bBounds.intersect(tBounds)) { |
45 hits[bIndex] = tIndex; | 45 hits[bIndex] = tIndex; |
46 value = true; | 46 value = true; |
47 break; | 47 break; |
48 } | 48 } |
49 } | 49 } |
50 } | 50 } |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 bool SkHitTest::enable(SkAnimateMaker& maker) { | 54 bool SkHitTest::enable(SkAnimateMaker&) { |
55 for (int bIndex = 0; bIndex < bullets.count(); bIndex++) { | 55 for (int bIndex = 0; bIndex < bullets.count(); bIndex++) { |
56 SkDisplayable* bullet = bullets[bIndex]; | 56 SkDisplayable* bullet = bullets[bIndex]; |
57 bullet->enableBounder(); | 57 bullet->enableBounder(); |
58 } | 58 } |
59 for (int tIndex = 0; tIndex < targets.count(); tIndex++) { | 59 for (int tIndex = 0; tIndex < targets.count(); tIndex++) { |
60 SkDisplayable* target = targets[tIndex]; | 60 SkDisplayable* target = targets[tIndex]; |
61 target->enableBounder(); | 61 target->enableBounder(); |
62 } | 62 } |
63 return false; | 63 return false; |
64 } | 64 } |
65 | 65 |
66 bool SkHitTest::hasEnable() const { | 66 bool SkHitTest::hasEnable() const { |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 const SkMemberInfo* SkHitTest::preferredChild(SkDisplayTypes type) { | 70 const SkMemberInfo* SkHitTest::preferredChild(SkDisplayTypes) { |
71 if (bullets.count() == 0) | 71 if (bullets.count() == 0) |
72 return getMember("bullets"); | 72 return getMember("bullets"); |
73 return getMember("targets"); // !!! cwap! need to refer to member through en
um like kScope instead | 73 return getMember("targets"); // !!! cwap! need to refer to member through en
um like kScope instead |
74 } | 74 } |
OLD | NEW |