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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkBitmap baseBitmap; |
| 61 fCanvas->readPixels(SkIRect::MakeSize(fCanvas->getBaseLayerSize(
)), &baseBitmap); |
61 SkIRect subset; | 62 SkIRect subset; |
62 for (int tileY = 0; tileY < fLargeTileHeight; tileY += this->get
TileHeight()) { | 63 for (int tileY = 0; tileY < fLargeTileHeight; tileY += this->get
TileHeight()) { |
63 for (int tileX = 0; tileX < fLargeTileWidth; tileX += this->
getTileWidth()) { | 64 for (int tileX = 0; tileX < fLargeTileWidth; tileX += this->
getTileWidth()) { |
64 subset.set(tileX, tileY, tileX + this->getTileWidth(), | 65 subset.set(tileX, tileY, tileX + this->getTileWidth(), |
65 tileY + this->getTileHeight()); | 66 tileY + this->getTileHeight()); |
66 SkDEBUGCODE(bool extracted =) | 67 SkDEBUGCODE(bool extracted =) |
67 baseBitmap.extractSubset(&dst, subset); | 68 baseBitmap.extractSubset(&dst, subset); |
68 SkASSERT(extracted); | 69 SkASSERT(extracted); |
69 if (!fWritePath.isEmpty()) { | 70 if (!fWritePath.isEmpty()) { |
70 // Similar to write() in PictureRenderer.cpp, but ju
st encodes | 71 // Similar to write() in PictureRenderer.cpp, but ju
st encodes |
(...skipping 21 matching lines...) Expand all Loading... |
92 } | 93 } |
93 } | 94 } |
94 } | 95 } |
95 return success; | 96 return success; |
96 } | 97 } |
97 | 98 |
98 SkString CopyTilesRenderer::getConfigNameInternal() { | 99 SkString CopyTilesRenderer::getConfigNameInternal() { |
99 return SkString("copy_tiles"); | 100 return SkString("copy_tiles"); |
100 } | 101 } |
101 } | 102 } |
OLD | NEW |