blob: 0bc832a8fb37e701ba981c7aa2a63ab162377c3c [file] [log] [blame]
Jeff Brown5541de92011-04-11 11:54:25 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "Sprites"
18
19//#define LOG_NDEBUG 0
20
21#include "SpriteController.h"
22
23#include <cutils/log.h>
24#include <utils/String8.h>
Mathias Agopian52800612013-02-14 17:11:20 -080025#include <gui/Surface.h>
Jeff Brown5541de92011-04-11 11:54:25 -070026
Andreas Gampe6b83b762014-11-10 15:55:11 -080027#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wunused-parameter"
Jeff Brown5541de92011-04-11 11:54:25 -070029#include <SkBitmap.h>
30#include <SkCanvas.h>
31#include <SkColor.h>
32#include <SkPaint.h>
33#include <SkXfermode.h>
Andreas Gampe6b83b762014-11-10 15:55:11 -080034#pragma GCC diagnostic pop
35
Mathias Agopian52800612013-02-14 17:11:20 -080036#include <android/native_window.h>
Jeff Brown5541de92011-04-11 11:54:25 -070037
38namespace android {
39
40// --- SpriteController ---
41
42SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer) :
43 mLooper(looper), mOverlayLayer(overlayLayer) {
44 mHandler = new WeakMessageHandler(this);
Jeff Brown2352b972011-04-12 22:39:53 -070045
46 mLocked.transactionNestingCount = 0;
47 mLocked.deferredSpriteUpdate = false;
Jeff Brown5541de92011-04-11 11:54:25 -070048}
49
50SpriteController::~SpriteController() {
51 mLooper->removeMessages(mHandler);
52
53 if (mSurfaceComposerClient != NULL) {
54 mSurfaceComposerClient->dispose();
55 mSurfaceComposerClient.clear();
56 }
57}
58
59sp<Sprite> SpriteController::createSprite() {
60 return new SpriteImpl(this);
61}
62
Jeff Brown2352b972011-04-12 22:39:53 -070063void SpriteController::openTransaction() {
64 AutoMutex _l(mLock);
65
66 mLocked.transactionNestingCount += 1;
67}
68
69void SpriteController::closeTransaction() {
70 AutoMutex _l(mLock);
71
72 LOG_ALWAYS_FATAL_IF(mLocked.transactionNestingCount == 0,
73 "Sprite closeTransaction() called but there is no open sprite transaction");
74
75 mLocked.transactionNestingCount -= 1;
76 if (mLocked.transactionNestingCount == 0 && mLocked.deferredSpriteUpdate) {
77 mLocked.deferredSpriteUpdate = false;
Jeff Brown5541de92011-04-11 11:54:25 -070078 mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES));
79 }
80}
81
Jeff Brown2352b972011-04-12 22:39:53 -070082void SpriteController::invalidateSpriteLocked(const sp<SpriteImpl>& sprite) {
83 bool wasEmpty = mLocked.invalidatedSprites.isEmpty();
84 mLocked.invalidatedSprites.push(sprite);
85 if (wasEmpty) {
86 if (mLocked.transactionNestingCount != 0) {
87 mLocked.deferredSpriteUpdate = true;
88 } else {
89 mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES));
90 }
91 }
92}
93
Jeff Brown5541de92011-04-11 11:54:25 -070094void SpriteController::disposeSurfaceLocked(const sp<SurfaceControl>& surfaceControl) {
Jeff Brown2352b972011-04-12 22:39:53 -070095 bool wasEmpty = mLocked.disposedSurfaces.isEmpty();
96 mLocked.disposedSurfaces.push(surfaceControl);
Jeff Brown5541de92011-04-11 11:54:25 -070097 if (wasEmpty) {
98 mLooper->sendMessage(mHandler, Message(MSG_DISPOSE_SURFACES));
99 }
100}
101
102void SpriteController::handleMessage(const Message& message) {
103 switch (message.what) {
104 case MSG_UPDATE_SPRITES:
105 doUpdateSprites();
106 break;
107 case MSG_DISPOSE_SURFACES:
108 doDisposeSurfaces();
109 break;
110 }
111}
112
113void SpriteController::doUpdateSprites() {
114 // Collect information about sprite updates.
115 // Each sprite update record includes a reference to its associated sprite so we can
116 // be certain the sprites will not be deleted while this function runs. Sprites
117 // may invalidate themselves again during this time but we will handle those changes
118 // in the next iteration.
119 Vector<SpriteUpdate> updates;
120 size_t numSprites;
121 { // acquire lock
122 AutoMutex _l(mLock);
123
Jeff Brown2352b972011-04-12 22:39:53 -0700124 numSprites = mLocked.invalidatedSprites.size();
Jeff Brown5541de92011-04-11 11:54:25 -0700125 for (size_t i = 0; i < numSprites; i++) {
Jeff Brown2352b972011-04-12 22:39:53 -0700126 const sp<SpriteImpl>& sprite = mLocked.invalidatedSprites.itemAt(i);
Jeff Brown5541de92011-04-11 11:54:25 -0700127
128 updates.push(SpriteUpdate(sprite, sprite->getStateLocked()));
129 sprite->resetDirtyLocked();
130 }
Jeff Brown2352b972011-04-12 22:39:53 -0700131 mLocked.invalidatedSprites.clear();
Jeff Brown5541de92011-04-11 11:54:25 -0700132 } // release lock
133
134 // Create missing surfaces.
135 bool surfaceChanged = false;
136 for (size_t i = 0; i < numSprites; i++) {
137 SpriteUpdate& update = updates.editItemAt(i);
138
139 if (update.state.surfaceControl == NULL && update.state.wantSurfaceVisible()) {
Jeff Brown2352b972011-04-12 22:39:53 -0700140 update.state.surfaceWidth = update.state.icon.bitmap.width();
141 update.state.surfaceHeight = update.state.icon.bitmap.height();
Jeff Brown5541de92011-04-11 11:54:25 -0700142 update.state.surfaceDrawn = false;
143 update.state.surfaceVisible = false;
144 update.state.surfaceControl = obtainSurface(
145 update.state.surfaceWidth, update.state.surfaceHeight);
146 if (update.state.surfaceControl != NULL) {
147 update.surfaceChanged = surfaceChanged = true;
148 }
149 }
150 }
151
152 // Resize sprites if needed, inside a global transaction.
153 bool haveGlobalTransaction = false;
154 for (size_t i = 0; i < numSprites; i++) {
155 SpriteUpdate& update = updates.editItemAt(i);
156
157 if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) {
Jeff Brown2352b972011-04-12 22:39:53 -0700158 int32_t desiredWidth = update.state.icon.bitmap.width();
159 int32_t desiredHeight = update.state.icon.bitmap.height();
Jeff Brown5541de92011-04-11 11:54:25 -0700160 if (update.state.surfaceWidth < desiredWidth
161 || update.state.surfaceHeight < desiredHeight) {
162 if (!haveGlobalTransaction) {
163 SurfaceComposerClient::openGlobalTransaction();
164 haveGlobalTransaction = true;
165 }
166
167 status_t status = update.state.surfaceControl->setSize(desiredWidth, desiredHeight);
168 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000169 ALOGE("Error %d resizing sprite surface from %dx%d to %dx%d",
Jeff Brown5541de92011-04-11 11:54:25 -0700170 status, update.state.surfaceWidth, update.state.surfaceHeight,
171 desiredWidth, desiredHeight);
172 } else {
173 update.state.surfaceWidth = desiredWidth;
174 update.state.surfaceHeight = desiredHeight;
175 update.state.surfaceDrawn = false;
176 update.surfaceChanged = surfaceChanged = true;
177
178 if (update.state.surfaceVisible) {
179 status = update.state.surfaceControl->hide();
180 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000181 ALOGE("Error %d hiding sprite surface after resize.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700182 } else {
183 update.state.surfaceVisible = false;
184 }
185 }
186 }
187 }
188 }
189 }
190 if (haveGlobalTransaction) {
191 SurfaceComposerClient::closeGlobalTransaction();
192 }
193
194 // Redraw sprites if needed.
195 for (size_t i = 0; i < numSprites; i++) {
196 SpriteUpdate& update = updates.editItemAt(i);
197
198 if ((update.state.dirty & DIRTY_BITMAP) && update.state.surfaceDrawn) {
199 update.state.surfaceDrawn = false;
200 update.surfaceChanged = surfaceChanged = true;
201 }
202
203 if (update.state.surfaceControl != NULL && !update.state.surfaceDrawn
204 && update.state.wantSurfaceVisible()) {
205 sp<Surface> surface = update.state.surfaceControl->getSurface();
Mathias Agopian52800612013-02-14 17:11:20 -0800206 ANativeWindow_Buffer outBuffer;
207 status_t status = surface->lock(&outBuffer, NULL);
Jeff Brown5541de92011-04-11 11:54:25 -0700208 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000209 ALOGE("Error %d locking sprite surface before drawing.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700210 } else {
211 SkBitmap surfaceBitmap;
Mathias Agopian52800612013-02-14 17:11:20 -0800212 ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
Mike Reedb9330552014-06-16 17:31:48 -0400213 surfaceBitmap.installPixels(SkImageInfo::MakeN32Premul(outBuffer.width, outBuffer.height),
214 outBuffer.bits, bpr);
Jeff Brown5541de92011-04-11 11:54:25 -0700215
Derek Sollenbergerfc615a02012-12-20 14:39:57 -0500216 SkCanvas surfaceCanvas(surfaceBitmap);
Jeff Brown5541de92011-04-11 11:54:25 -0700217
218 SkPaint paint;
219 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
Jeff Brown2352b972011-04-12 22:39:53 -0700220 surfaceCanvas.drawBitmap(update.state.icon.bitmap, 0, 0, &paint);
Jeff Brown5541de92011-04-11 11:54:25 -0700221
Michael Wright4d8779f2013-10-16 14:01:50 -0700222 if (outBuffer.width > update.state.icon.bitmap.width()) {
Jeff Brown5541de92011-04-11 11:54:25 -0700223 paint.setColor(0); // transparent fill color
Jeff Brown2352b972011-04-12 22:39:53 -0700224 surfaceCanvas.drawRectCoords(update.state.icon.bitmap.width(), 0,
Mathias Agopian52800612013-02-14 17:11:20 -0800225 outBuffer.width, update.state.icon.bitmap.height(), paint);
Jeff Brown5541de92011-04-11 11:54:25 -0700226 }
Michael Wright4d8779f2013-10-16 14:01:50 -0700227 if (outBuffer.height > update.state.icon.bitmap.height()) {
Jeff Brown5541de92011-04-11 11:54:25 -0700228 paint.setColor(0); // transparent fill color
Jeff Brown2352b972011-04-12 22:39:53 -0700229 surfaceCanvas.drawRectCoords(0, update.state.icon.bitmap.height(),
Mathias Agopian52800612013-02-14 17:11:20 -0800230 outBuffer.width, outBuffer.height, paint);
Jeff Brown5541de92011-04-11 11:54:25 -0700231 }
232
233 status = surface->unlockAndPost();
234 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000235 ALOGE("Error %d unlocking and posting sprite surface after drawing.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700236 } else {
237 update.state.surfaceDrawn = true;
238 update.surfaceChanged = surfaceChanged = true;
239 }
240 }
241 }
242 }
243
244 // Set sprite surface properties and make them visible.
245 bool haveTransaction = false;
246 for (size_t i = 0; i < numSprites; i++) {
247 SpriteUpdate& update = updates.editItemAt(i);
248
249 bool wantSurfaceVisibleAndDrawn = update.state.wantSurfaceVisible()
250 && update.state.surfaceDrawn;
251 bool becomingVisible = wantSurfaceVisibleAndDrawn && !update.state.surfaceVisible;
252 bool becomingHidden = !wantSurfaceVisibleAndDrawn && update.state.surfaceVisible;
253 if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden
254 || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA
255 | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER
256 | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) {
257 status_t status;
258 if (!haveTransaction) {
Mathias Agopian439863f2011-06-28 19:09:31 -0700259 SurfaceComposerClient::openGlobalTransaction();
Jeff Brown5541de92011-04-11 11:54:25 -0700260 haveTransaction = true;
261 }
262
263 if (wantSurfaceVisibleAndDrawn
264 && (becomingVisible || (update.state.dirty & DIRTY_ALPHA))) {
265 status = update.state.surfaceControl->setAlpha(update.state.alpha);
266 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000267 ALOGE("Error %d setting sprite surface alpha.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700268 }
269 }
270
271 if (wantSurfaceVisibleAndDrawn
272 && (becomingVisible || (update.state.dirty & (DIRTY_POSITION
273 | DIRTY_HOTSPOT)))) {
274 status = update.state.surfaceControl->setPosition(
Jeff Brown2352b972011-04-12 22:39:53 -0700275 update.state.positionX - update.state.icon.hotSpotX,
276 update.state.positionY - update.state.icon.hotSpotY);
Jeff Brown5541de92011-04-11 11:54:25 -0700277 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000278 ALOGE("Error %d setting sprite surface position.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700279 }
280 }
281
282 if (wantSurfaceVisibleAndDrawn
283 && (becomingVisible
284 || (update.state.dirty & DIRTY_TRANSFORMATION_MATRIX))) {
285 status = update.state.surfaceControl->setMatrix(
286 update.state.transformationMatrix.dsdx,
287 update.state.transformationMatrix.dtdx,
288 update.state.transformationMatrix.dsdy,
289 update.state.transformationMatrix.dtdy);
290 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000291 ALOGE("Error %d setting sprite surface transformation matrix.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700292 }
293 }
294
295 int32_t surfaceLayer = mOverlayLayer + update.state.layer;
296 if (wantSurfaceVisibleAndDrawn
297 && (becomingVisible || (update.state.dirty & DIRTY_LAYER))) {
298 status = update.state.surfaceControl->setLayer(surfaceLayer);
299 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000300 ALOGE("Error %d setting sprite surface layer.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700301 }
302 }
303
304 if (becomingVisible) {
Jeff Brown4fd42e52012-08-26 22:49:01 -0700305 status = update.state.surfaceControl->show();
Jeff Brown5541de92011-04-11 11:54:25 -0700306 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000307 ALOGE("Error %d showing sprite surface.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700308 } else {
309 update.state.surfaceVisible = true;
310 update.surfaceChanged = surfaceChanged = true;
311 }
312 } else if (becomingHidden) {
313 status = update.state.surfaceControl->hide();
314 if (status) {
Steve Block3762c312012-01-06 19:20:56 +0000315 ALOGE("Error %d hiding sprite surface.", status);
Jeff Brown5541de92011-04-11 11:54:25 -0700316 } else {
317 update.state.surfaceVisible = false;
318 update.surfaceChanged = surfaceChanged = true;
319 }
320 }
321 }
322 }
323
324 if (haveTransaction) {
Mathias Agopian439863f2011-06-28 19:09:31 -0700325 SurfaceComposerClient::closeGlobalTransaction();
Jeff Brown5541de92011-04-11 11:54:25 -0700326 }
327
328 // If any surfaces were changed, write back the new surface properties to the sprites.
329 if (surfaceChanged) { // acquire lock
330 AutoMutex _l(mLock);
331
332 for (size_t i = 0; i < numSprites; i++) {
333 const SpriteUpdate& update = updates.itemAt(i);
334
335 if (update.surfaceChanged) {
336 update.sprite->setSurfaceLocked(update.state.surfaceControl,
337 update.state.surfaceWidth, update.state.surfaceHeight,
338 update.state.surfaceDrawn, update.state.surfaceVisible);
339 }
340 }
341 } // release lock
342
343 // Clear the sprite update vector outside the lock. It is very important that
344 // we do not clear sprite references inside the lock since we could be releasing
345 // the last remaining reference to the sprite here which would result in the
346 // sprite being deleted and the lock being reacquired by the sprite destructor
347 // while already held.
348 updates.clear();
349}
350
351void SpriteController::doDisposeSurfaces() {
352 // Collect disposed surfaces.
353 Vector<sp<SurfaceControl> > disposedSurfaces;
354 { // acquire lock
Jeff Brown2352b972011-04-12 22:39:53 -0700355 AutoMutex _l(mLock);
356
357 disposedSurfaces = mLocked.disposedSurfaces;
358 mLocked.disposedSurfaces.clear();
Jeff Brown5541de92011-04-11 11:54:25 -0700359 } // release lock
360
361 // Release the last reference to each surface outside of the lock.
362 // We don't want the surfaces to be deleted while we are holding our lock.
363 disposedSurfaces.clear();
364}
365
366void SpriteController::ensureSurfaceComposerClient() {
367 if (mSurfaceComposerClient == NULL) {
368 mSurfaceComposerClient = new SurfaceComposerClient();
369 }
370}
371
372sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height) {
373 ensureSurfaceComposerClient();
374
375 sp<SurfaceControl> surfaceControl = mSurfaceComposerClient->createSurface(
Jeff Brown64a55af2012-08-26 02:47:39 -0700376 String8("Sprite"), width, height, PIXEL_FORMAT_RGBA_8888,
Riley Andrews68eccda2014-07-07 11:47:35 -0700377 ISurfaceComposerClient::eHidden |
378 ISurfaceComposerClient::eCursorWindow);
Mathias Agopian52800612013-02-14 17:11:20 -0800379 if (surfaceControl == NULL || !surfaceControl->isValid()) {
Steve Block3762c312012-01-06 19:20:56 +0000380 ALOGE("Error creating sprite surface.");
Jeff Brown5541de92011-04-11 11:54:25 -0700381 return NULL;
382 }
383 return surfaceControl;
384}
385
386
387// --- SpriteController::SpriteImpl ---
388
389SpriteController::SpriteImpl::SpriteImpl(const sp<SpriteController> controller) :
Jeff Brown2352b972011-04-12 22:39:53 -0700390 mController(controller) {
Jeff Brown5541de92011-04-11 11:54:25 -0700391}
392
393SpriteController::SpriteImpl::~SpriteImpl() {
394 AutoMutex _m(mController->mLock);
395
396 // Let the controller take care of deleting the last reference to sprite
397 // surfaces so that we do not block the caller on an IPC here.
Jeff Brown2352b972011-04-12 22:39:53 -0700398 if (mLocked.state.surfaceControl != NULL) {
399 mController->disposeSurfaceLocked(mLocked.state.surfaceControl);
400 mLocked.state.surfaceControl.clear();
Jeff Brown5541de92011-04-11 11:54:25 -0700401 }
402}
403
Jeff Brown2352b972011-04-12 22:39:53 -0700404void SpriteController::SpriteImpl::setIcon(const SpriteIcon& icon) {
Jeff Brown5541de92011-04-11 11:54:25 -0700405 AutoMutex _l(mController->mLock);
406
Jeff Brown2352b972011-04-12 22:39:53 -0700407 uint32_t dirty;
408 if (icon.isValid()) {
Mike Reed4a9c3892014-07-07 15:44:40 -0400409 icon.bitmap.copyTo(&mLocked.state.icon.bitmap, kN32_SkColorType);
Jeff Brown5541de92011-04-11 11:54:25 -0700410
Jeff Brown2352b972011-04-12 22:39:53 -0700411 if (!mLocked.state.icon.isValid()
412 || mLocked.state.icon.hotSpotX != icon.hotSpotX
413 || mLocked.state.icon.hotSpotY != icon.hotSpotY) {
414 mLocked.state.icon.hotSpotX = icon.hotSpotX;
415 mLocked.state.icon.hotSpotY = icon.hotSpotY;
416 dirty = DIRTY_BITMAP | DIRTY_HOTSPOT;
417 } else {
418 dirty = DIRTY_BITMAP;
419 }
420 } else if (mLocked.state.icon.isValid()) {
421 mLocked.state.icon.bitmap.reset();
422 dirty = DIRTY_BITMAP | DIRTY_HOTSPOT;
423 } else {
424 return; // setting to invalid icon and already invalid so nothing to do
Jeff Brown5541de92011-04-11 11:54:25 -0700425 }
426
427 invalidateLocked(dirty);
428}
429
430void SpriteController::SpriteImpl::setVisible(bool visible) {
431 AutoMutex _l(mController->mLock);
432
Jeff Brown2352b972011-04-12 22:39:53 -0700433 if (mLocked.state.visible != visible) {
434 mLocked.state.visible = visible;
Jeff Brown5541de92011-04-11 11:54:25 -0700435 invalidateLocked(DIRTY_VISIBILITY);
436 }
437}
438
439void SpriteController::SpriteImpl::setPosition(float x, float y) {
440 AutoMutex _l(mController->mLock);
441
Jeff Brown2352b972011-04-12 22:39:53 -0700442 if (mLocked.state.positionX != x || mLocked.state.positionY != y) {
443 mLocked.state.positionX = x;
444 mLocked.state.positionY = y;
Jeff Brown5541de92011-04-11 11:54:25 -0700445 invalidateLocked(DIRTY_POSITION);
446 }
447}
448
449void SpriteController::SpriteImpl::setLayer(int32_t layer) {
450 AutoMutex _l(mController->mLock);
451
Jeff Brown2352b972011-04-12 22:39:53 -0700452 if (mLocked.state.layer != layer) {
453 mLocked.state.layer = layer;
Jeff Brown5541de92011-04-11 11:54:25 -0700454 invalidateLocked(DIRTY_LAYER);
455 }
456}
457
458void SpriteController::SpriteImpl::setAlpha(float alpha) {
459 AutoMutex _l(mController->mLock);
460
Jeff Brown2352b972011-04-12 22:39:53 -0700461 if (mLocked.state.alpha != alpha) {
462 mLocked.state.alpha = alpha;
Jeff Brown5541de92011-04-11 11:54:25 -0700463 invalidateLocked(DIRTY_ALPHA);
464 }
465}
466
467void SpriteController::SpriteImpl::setTransformationMatrix(
468 const SpriteTransformationMatrix& matrix) {
469 AutoMutex _l(mController->mLock);
470
Jeff Brown2352b972011-04-12 22:39:53 -0700471 if (mLocked.state.transformationMatrix != matrix) {
472 mLocked.state.transformationMatrix = matrix;
Jeff Brown5541de92011-04-11 11:54:25 -0700473 invalidateLocked(DIRTY_TRANSFORMATION_MATRIX);
474 }
475}
476
Jeff Brown5541de92011-04-11 11:54:25 -0700477void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) {
Jeff Brown2352b972011-04-12 22:39:53 -0700478 bool wasDirty = mLocked.state.dirty;
479 mLocked.state.dirty |= dirty;
480
481 if (!wasDirty) {
482 mController->invalidateSpriteLocked(this);
Jeff Brown5541de92011-04-11 11:54:25 -0700483 }
484}
485
486} // namespace android