1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*
* $RCSfile$
*
* Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved.
*
* Use is subject to license terms.
*
* $Revision$
* $Date$
* $State$
*/
#include "StdAfx.h"
D3dImageComponent::D3dImageComponent()
{
init();
}
D3dImageComponent::D3dImageComponent(D3dCtx *_ctx,
int _hashCode,
LPDIRECT3DTEXTURE8 _surf)
{
ctx = _ctx;
hashCode = _hashCode;
surf = _surf;
next = NULL;
}
D3dImageComponent::~D3dImageComponent()
{
if ((ctx != NULL) && (surf != NULL)) {
ctx->freeResource(surf);
}
}
VOID D3dImageComponent::init()
{
next = NULL;
surf = NULL;
hashCode = 0;
ctx = NULL;
}
D3dImageComponent* D3dImageComponent::add(D3dImageComponent *list,
D3dCtx *ctx,
int hashCode,
LPDIRECT3DTEXTURE8 surf)
{
D3dImageComponent *p = list->next;
D3dImageComponent *ic = new D3dImageComponent(ctx, hashCode, surf);
if (ic == NULL) {
return NULL;
}
list->next = ic;
ic->next = p;
return ic;
}
D3dImageComponent* D3dImageComponent::find(D3dImageComponent *list,
D3dCtx *ctx,
int hashCode)
{
// skip the first dummy node
D3dImageComponent *p = list->next;
while (p != NULL) {
if ((p->ctx == ctx) &&
(p->hashCode == hashCode)) {
return p;
}
p = p->next;
}
return NULL;
}
VOID D3dImageComponent::remove(D3dImageComponent *list,
D3dCtx *ctx, int hashCode)
{
// skip the first dummy node
D3dImageComponent *p = list->next;
D3dImageComponent *q = list;
while (p != NULL) {
if ((p->ctx == ctx) &&
(p->hashCode == hashCode)) {
q->next = p->next;
delete p;
break;
}
q = p;
p = p->next;
}
}
VOID D3dImageComponent::remove(D3dImageComponent *list,
int hashCode)
{
// skip the first dummy node
D3dImageComponent *p = list->next;
D3dImageComponent *q = list;
while (p != NULL) {
if (p->hashCode == hashCode) {
q->next = p->next;
delete p;
// continue for image in another ctx
p = q->next;
} else {
q = p;
p = p->next;
}
}
}
VOID D3dImageComponent::remove(D3dImageComponent *list,
D3dCtx *ctx)
{
// skip the first dummy node
D3dImageComponent *p = list->next;
D3dImageComponent *q = list;
while (p != NULL) {
if (p->ctx == ctx) {
q->next = p->next;
delete p;
p = q->next;
// continue for other images
} else {
q = p;
p = p->next;
}
}
}
VOID D3dImageComponent::remove(D3dImageComponent *list,
D3dImageComponent *ic)
{
// skip the first dummy node
D3dImageComponent *p = list->next;
D3dImageComponent *q = list;
while (p != NULL) {
if (p == ic) {
q->next = p->next;
delete p;
break;
}
q = p;
p = p->next;
}
}
VOID D3dImageComponent::removeAll(D3dImageComponent *list)
{
// skip the first dummy node
D3dImageComponent *q, *p = list->next;
list->next = NULL;
while (p != NULL) {
q = p->next;
delete p;
p = q;
}
}
|