Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/animator/SkDisplayList.cpp

Issue 764463002: rename SkDrawable to SkADrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkDisplayList.h" 10 #include "SkDisplayList.h"
11 #include "SkAnimateActive.h" 11 #include "SkAnimateActive.h"
12 #include "SkAnimateBase.h" 12 #include "SkAnimateBase.h"
13 #include "SkAnimateMaker.h" 13 #include "SkAnimateMaker.h"
14 #include "SkDisplayApply.h" 14 #include "SkDisplayApply.h"
15 #include "SkDrawable.h" 15 #include "SkADrawable.h"
16 #include "SkDrawGroup.h" 16 #include "SkDrawGroup.h"
17 #include "SkDrawMatrix.h" 17 #include "SkDrawMatrix.h"
18 #include "SkInterpolator.h" 18 #include "SkInterpolator.h"
19 #include "SkTime.h" 19 #include "SkTime.h"
20 20
21 SkDisplayList::SkDisplayList() : fDrawBounds(true), fUnionBounds(false), fInTime (0) { 21 SkDisplayList::SkDisplayList() : fDrawBounds(true), fUnionBounds(false), fInTime (0) {
22 } 22 }
23 23
24 SkDisplayList::~SkDisplayList() { 24 SkDisplayList::~SkDisplayList() {
25 } 25 }
26 26
27 void SkDisplayList::append(SkActive* active) { 27 void SkDisplayList::append(SkActive* active) {
28 *fActiveList.append() = active; 28 *fActiveList.append() = active;
29 } 29 }
30 30
31 bool SkDisplayList::draw(SkAnimateMaker& maker, SkMSec inTime) { 31 bool SkDisplayList::draw(SkAnimateMaker& maker, SkMSec inTime) {
32 validate(); 32 validate();
33 fInTime = inTime; 33 fInTime = inTime;
34 bool result = false; 34 bool result = false;
35 fInvalBounds.setEmpty(); 35 fInvalBounds.setEmpty();
36 if (fDrawList.count()) { 36 if (fDrawList.count()) {
37 for (SkActive** activePtr = fActiveList.begin(); activePtr < fActiveList .end(); activePtr++) { 37 for (SkActive** activePtr = fActiveList.begin(); activePtr < fActiveList .end(); activePtr++) {
38 SkActive* active = *activePtr; 38 SkActive* active = *activePtr;
39 active->reset(); 39 active->reset();
40 } 40 }
41 for (int index = 0; index < fDrawList.count(); index++) { 41 for (int index = 0; index < fDrawList.count(); index++) {
42 SkDrawable* draw = fDrawList[index]; 42 SkADrawable* draw = fDrawList[index];
43 draw->initialize(); // allow matrices to reset themselves 43 draw->initialize(); // allow matrices to reset themselves
44 SkASSERT(draw->isDrawable()); 44 SkASSERT(draw->isDrawable());
45 validate(); 45 validate();
46 result |= draw->draw(maker); 46 result |= draw->draw(maker);
47 } 47 }
48 } 48 }
49 validate(); 49 validate();
50 return result; 50 return result;
51 } 51 }
52 52
53 int SkDisplayList::findGroup(SkDrawable* match, SkTDDrawableArray** list, 53 int SkDisplayList::findGroup(SkADrawable* match, SkTDDrawableArray** list,
54 SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 54 SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) {
55 *parent = NULL; 55 *parent = NULL;
56 *list = &fDrawList; 56 *list = &fDrawList;
57 *grandList = &fDrawList; 57 *grandList = &fDrawList;
58 return SearchForMatch(match, list, parent, found, grandList); 58 return SearchForMatch(match, list, parent, found, grandList);
59 } 59 }
60 60
61 void SkDisplayList::hardReset() { 61 void SkDisplayList::hardReset() {
62 fDrawList.reset(); 62 fDrawList.reset();
63 fActiveList.reset(); 63 fActiveList.reset();
64 } 64 }
65 65
66 bool SkDisplayList::onIRect(const SkIRect& r) { 66 bool SkDisplayList::onIRect(const SkIRect& r) {
67 fBounds = r; 67 fBounds = r;
68 return fDrawBounds; 68 return fDrawBounds;
69 } 69 }
70 70
71 int SkDisplayList::SearchForMatch(SkDrawable* match, SkTDDrawableArray** list, 71 int SkDisplayList::SearchForMatch(SkADrawable* match, SkTDDrawableArray** list,
72 SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 72 SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) {
73 *found = NULL; 73 *found = NULL;
74 for (int index = 0; index < (*list)->count(); index++) { 74 for (int index = 0; index < (*list)->count(); index++) {
75 SkDrawable* draw = (**list)[index]; 75 SkADrawable* draw = (**list)[index];
76 if (draw == match) 76 if (draw == match)
77 return index; 77 return index;
78 if (draw->isApply()) { 78 if (draw->isApply()) {
79 SkApply* apply = (SkApply*) draw; 79 SkApply* apply = (SkApply*) draw;
80 if (apply->scope == match) 80 if (apply->scope == match)
81 return index; 81 return index;
82 if (apply->scope->isGroup() && SearchGroupForMatch(apply->scope, mat ch, list, parent, found, grandList, index)) 82 if (apply->scope->isGroup() && SearchGroupForMatch(apply->scope, mat ch, list, parent, found, grandList, index))
83 return index; 83 return index;
84 if (apply->mode == SkApply::kMode_create) { 84 if (apply->mode == SkApply::kMode_create) {
85 for (SkDrawable** ptr = apply->fScopes.begin(); ptr < apply->fSc opes.end(); ptr++) { 85 for (SkADrawable** ptr = apply->fScopes.begin(); ptr < apply->fS copes.end(); ptr++) {
86 SkDrawable* scope = *ptr; 86 SkADrawable* scope = *ptr;
87 if (scope == match) 87 if (scope == match)
88 return index; 88 return index;
89 //perhaps should call SearchGroupForMatch here as well (on s cope) 89 //perhaps should call SearchGroupForMatch here as well (on s cope)
90 } 90 }
91 } 91 }
92 } 92 }
93 if (draw->isGroup() && SearchGroupForMatch(draw, match, list, parent, fo und, grandList, index)) 93 if (draw->isGroup() && SearchGroupForMatch(draw, match, list, parent, fo und, grandList, index))
94 return index; 94 return index;
95 95
96 } 96 }
97 return -1; 97 return -1;
98 } 98 }
99 99
100 bool SkDisplayList::SearchGroupForMatch(SkDrawable* draw, SkDrawable* match, SkT DDrawableArray** list, 100 bool SkDisplayList::SearchGroupForMatch(SkADrawable* draw, SkADrawable* match, S kTDDrawableArray** list,
101 SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList, int &i ndex) { 101 SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList, int &i ndex) {
102 SkGroup* group = (SkGroup*) draw; 102 SkGroup* group = (SkGroup*) draw;
103 if (group->getOriginal() == match) 103 if (group->getOriginal() == match)
104 return true; 104 return true;
105 SkTDDrawableArray* saveList = *list; 105 SkTDDrawableArray* saveList = *list;
106 int groupIndex = group->findGroup(match, list, parent, found, grandL ist); 106 int groupIndex = group->findGroup(match, list, parent, found, grandL ist);
107 if (groupIndex >= 0) { 107 if (groupIndex >= 0) {
108 *found = group; 108 *found = group;
109 index = groupIndex; 109 index = groupIndex;
110 return true; 110 return true;
111 } 111 }
112 *list = saveList; 112 *list = saveList;
113 return false; 113 return false;
114 } 114 }
115 115
116 void SkDisplayList::reset() { 116 void SkDisplayList::reset() {
117 for (int index = 0; index < fDrawList.count(); index++) { 117 for (int index = 0; index < fDrawList.count(); index++) {
118 SkDrawable* draw = fDrawList[index]; 118 SkADrawable* draw = fDrawList[index];
119 if (draw->isApply() == false) 119 if (draw->isApply() == false)
120 continue; 120 continue;
121 SkApply* apply = (SkApply*) draw; 121 SkApply* apply = (SkApply*) draw;
122 apply->reset(); 122 apply->reset();
123 } 123 }
124 } 124 }
125 125
126 void SkDisplayList::remove(SkActive* active) { 126 void SkDisplayList::remove(SkActive* active) {
127 int index = fActiveList.find(active); 127 int index = fActiveList.find(active);
128 SkASSERT(index >= 0); 128 SkASSERT(index >= 0);
(...skipping 15 matching lines...) Expand all
144 fDumpIndex = index; 144 fDumpIndex = index;
145 fDrawList[fDumpIndex]->dump(maker); 145 fDrawList[fDumpIndex]->dump(maker);
146 } 146 }
147 } 147 }
148 148
149 #endif 149 #endif
150 150
151 #ifdef SK_DEBUG 151 #ifdef SK_DEBUG
152 void SkDisplayList::validate() { 152 void SkDisplayList::validate() {
153 for (int index = 0; index < fDrawList.count(); index++) { 153 for (int index = 0; index < fDrawList.count(); index++) {
154 SkDrawable* draw = fDrawList[index]; 154 SkADrawable* draw = fDrawList[index];
155 draw->validate(); 155 draw->validate();
156 } 156 }
157 } 157 }
158 #endif 158 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698