| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "picture_utils.h" | 8 #include "picture_utils.h" |
| 9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 for (int x = 0; x < this->getViewWidth(); x += fLargeTileWidth) { | 48 for (int x = 0; x < this->getViewWidth(); x += fLargeTileWidth) { |
| 49 for (int y = 0; y < this->getViewHeight(); y += fLargeTileHeight) { | 49 for (int y = 0; y < this->getViewHeight(); y += fLargeTileHeight) { |
| 50 SkAutoCanvasRestore autoRestore(fCanvas, true); | 50 SkAutoCanvasRestore autoRestore(fCanvas, true); |
| 51 // Translate so that we draw the correct portion of the picture. | 51 // Translate so that we draw the correct portion of the picture. |
| 52 // Perform a postTranslate so that the scaleFactor does not inte
rfere with the | 52 // Perform a postTranslate so that the scaleFactor does not inte
rfere with the |
| 53 // positioning. | 53 // positioning. |
| 54 SkMatrix mat(fCanvas->getTotalMatrix()); | 54 SkMatrix mat(fCanvas->getTotalMatrix()); |
| 55 mat.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 55 mat.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 56 fCanvas->setMatrix(mat); | 56 fCanvas->setMatrix(mat); |
| 57 // Draw the picture | 57 // Draw the picture |
| 58 fCanvas->drawPicture(*fPicture); | 58 fCanvas->drawPicture(fPicture); |
| 59 // Now extract the picture into tiles | 59 // Now extract the picture into tiles |
| 60 const SkBitmap& baseBitmap = fCanvas->getDevice()->accessBitmap(
false); | 60 const SkBitmap& baseBitmap = fCanvas->getDevice()->accessBitmap(
false); |
| 61 SkIRect subset; | 61 SkIRect subset; |
| 62 for (int tileY = 0; tileY < fLargeTileHeight; tileY += this->get
TileHeight()) { | 62 for (int tileY = 0; tileY < fLargeTileHeight; tileY += this->get
TileHeight()) { |
| 63 for (int tileX = 0; tileX < fLargeTileWidth; tileX += this->
getTileWidth()) { | 63 for (int tileX = 0; tileX < fLargeTileWidth; tileX += this->
getTileWidth()) { |
| 64 subset.set(tileX, tileY, tileX + this->getTileWidth(), | 64 subset.set(tileX, tileY, tileX + this->getTileWidth(), |
| 65 tileY + this->getTileHeight()); | 65 tileY + this->getTileHeight()); |
| 66 SkDEBUGCODE(bool extracted =) | 66 SkDEBUGCODE(bool extracted =) |
| 67 baseBitmap.extractSubset(&dst, subset); | 67 baseBitmap.extractSubset(&dst, subset); |
| 68 SkASSERT(extracted); | 68 SkASSERT(extracted); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 return success; | 95 return success; |
| 96 } | 96 } |
| 97 | 97 |
| 98 SkString CopyTilesRenderer::getConfigNameInternal() { | 98 SkString CopyTilesRenderer::getConfigNameInternal() { |
| 99 return SkString("copy_tiles"); | 99 return SkString("copy_tiles"); |
| 100 } | 100 } |
| 101 } | 101 } |
| OLD | NEW |