Home | History | Annotate | Download | only in ui

Lines Matching refs:Tile

49      *  This is the tile state in the CPU side.
50 * Life of a Tile:
85 // The offsets of the (left, top) of the upper-left tile to the (left, top)
96 private final HashMap<Long, Tile> mActiveTiles = new HashMap<Long, Tile>();
185 // 1. Decide the tile level we want to use for display.
186 // 2. Decide the tile levels we want to keep as texture (in addition to
195 // The tile levels we want to keep as texture is in the range
203 // We want to keep one more tile level as texture in addition to what
227 // If rotation is transient, don't update the tile.
236 // Recycle unused tiles: if the level of the active tile is outside the
238 Iterator<Map.Entry<Long, Tile>>
241 Tile tile = iter.next().getValue();
242 int level = tile.mTileLevel;
244 || !range[level - fromLevel].contains(tile.mX, tile.mY)) {
246 recycleTile(tile);
266 for (Tile tile : mActiveTiles.values()) {
267 recycleTile(tile);
278 // aligned to the tile boundary.
301 // align the rectangle to tile boundary
332 for (Tile texture : mActiveTiles.values()) {
341 Tile tile = mRecycledQueue.pop();
342 while (tile != null) {
343 tile.recycle();
344 tile = mRecycledQueue.pop();
407 for (Tile tile : mActiveTiles.values()) {
408 if (!tile.isContentValid(canvas)) queueForDecode(tile);
412 void queueForUpload(Tile tile) {
414 mUploadQueue.push(tile);
421 synchronized void queueForDecode(Tile tile) {
422 if (tile.mTileState == STATE_ACTIVATED) {
423 tile.mTileState = STATE_IN_QUEUE;
424 if (mDecodeQueue.push(tile)) notifyAll();
428 boolean decodeTile(Tile tile) {
430 if (tile.mTileState != STATE_IN_QUEUE) return false;
431 tile.mTileState = STATE_DECODING;
433 boolean decodeComplete = tile.decode();
435 if (tile.mTileState == STATE_RECYCLING) {
436 tile.mTileState = STATE_RECYCLED;
437 tile.mDecodedTile = null;
438 mRecycledQueue.push(tile);
441 tile.mTileState = decodeComplete ? STATE_DECODED : STATE_DECODE_FAIL;
446 private synchronized Tile obtainTile(int x, int y, int level) {
447 Tile tile = mRecycledQueue.pop();
448 if (tile != null) {
449 tile.mTileState = STATE_ACTIVATED;
450 tile.update(x, y, level);
451 return tile;
453 return new Tile(x, y, level);
456 synchronized void recycleTile(Tile tile) {
457 if (tile.mTileState == STATE_DECODING) {
458 tile.mTileState = STATE_RECYCLING;
461 tile.mTileState = STATE_RECYCLED;
462 tile.mDecodedTile = null;
463 mRecycledQueue.push(tile);
468 Tile tile = mActiveTiles.get(key);
469 if (tile != null) {
470 if (tile.mTileState == STATE_IN_QUEUE) {
471 tile.mTileState = STATE_ACTIVATED;
475 tile = obtainTile(x, y, level);
476 mActiveTiles.put(key, tile);
479 private Tile getTile(int x, int y, int level) {
496 Tile tile;
499 tile = mUploadQueue.pop();
501 if (tile == null || quota <= 0) break;
502 if (!tile.isContentValid(canvas)) {
503 Utils.assertTrue(tile.mTileState == STATE_DECODED);
504 tile.updateContent(canvas);
508 mActive.set(tile != null);
509 return tile != null;
513 // Draw the tile to a square at canvas that locates at (x, y) and
522 Tile tile = getTile(tx, ty, level);
523 if (tile != null) {
524 if (!tile.isContentValid(canvas)) {
525 if (tile.mTileState == STATE_DECODED) {
528 tile.updateContent(canvas);
532 } else if (tile.mTileState != STATE_DECODE_FAIL){
534 queueForDecode(tile);
537 if (drawTile(tile, canvas, source, target)) return;
552 Tile tile, GLCanvas canvas, RectF source, RectF target) {
554 if (tile.isContentValid(canvas)) {
557 canvas.drawTexture(tile, source, target);
561 // Parent can be divided to four quads and tile is one of the four.
562 Tile parent = tile.getParentTile();
564 if (tile.mX == parent.mX) {
571 if (tile.mY == parent.mY) {
578 tile = parent;
582 private class Tile extends UploadedTexture {
586 Tile mNext;
590 public Tile(int x, int y, int level) {
602 // Get a tile from the original image. The tile is down-scaled
610 Log.w(TAG, "fail to decode tile", t);
631 public Tile getParentTile() {
641 return String.format("tile(%s, %s, %s / %s)",
647 private Tile mHead;
649 public Tile pop() {
650 Tile tile = mHead;
651 if (tile != null) mHead = tile.mNext;
652 return tile;
655 public boolean push(Tile tile) {
657 tile.mNext = mHead;
658 mHead = tile;
683 Tile tile = null;
685 tile = mDecodeQueue.pop();
686 if (tile == null && !jc.isCancelled()) {
690 if (tile == null) continue;
691 if (decodeTile(tile)) queueForUpload(tile);