gfx/skia/trunk/src/animator/SkHitTest.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial