| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 subset.set(tileX, tileY, tileX + this->getTileWidth(), | 65 subset.set(tileX, tileY, tileX + this->getTileWidth(), |
| 66 tileY + this->getTileHeight()); | 66 tileY + this->getTileHeight()); |
| 67 SkDEBUGCODE(bool extracted =) | 67 SkDEBUGCODE(bool extracted =) |
| 68 baseBitmap.extractSubset(&dst, subset); | 68 baseBitmap.extractSubset(&dst, subset); |
| 69 SkASSERT(extracted); | 69 SkASSERT(extracted); |
| 70 if (!fWritePath.isEmpty()) { | 70 if (!fWritePath.isEmpty()) { |
| 71 // Similar to write() in PictureRenderer.cpp, but ju
st encodes | 71 // Similar to write() in PictureRenderer.cpp, but ju
st encodes |
| 72 // a bitmap directly. | 72 // a bitmap directly. |
| 73 // TODO: Share more common code with write() to do t
his, to properly | 73 // TODO: Share more common code with write() to do t
his, to properly |
| 74 // write out the JSON summary, etc. | 74 // write out the JSON summary, etc. |
| 75 SkString pathWithNumber = SkOSPath::SkPathJoin(fWrit
ePath.c_str(), | 75 SkString pathWithNumber = SkOSPath::Join(fWritePath.
c_str(), |
| 76 fInpu
tFilename.c_str()); | 76 fInputFilen
ame.c_str()); |
| 77 pathWithNumber.remove(pathWithNumber.size() - 4, 4); | 77 pathWithNumber.remove(pathWithNumber.size() - 4, 4); |
| 78 pathWithNumber.appendf("%i.png", i++); | 78 pathWithNumber.appendf("%i.png", i++); |
| 79 SkBitmap copy; | 79 SkBitmap copy; |
| 80 #if SK_SUPPORT_GPU | 80 #if SK_SUPPORT_GPU |
| 81 if (isUsingGpuDevice()) { | 81 if (isUsingGpuDevice()) { |
| 82 dst.pixelRef()->readPixels(©, &subset); | 82 dst.pixelRef()->readPixels(©, &subset); |
| 83 } else { | 83 } else { |
| 84 #endif | 84 #endif |
| 85 dst.copyTo(©); | 85 dst.copyTo(©); |
| 86 #if SK_SUPPORT_GPU | 86 #if SK_SUPPORT_GPU |
| 87 } | 87 } |
| 88 #endif | 88 #endif |
| 89 success &= SkImageEncoder::EncodeFile(pathWithNumber
.c_str(), copy, | 89 success &= SkImageEncoder::EncodeFile(pathWithNumber
.c_str(), copy, |
| 90 SkImageEncoder
::kPNG_Type, 100); | 90 SkImageEncoder
::kPNG_Type, 100); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 return success; | 96 return success; |
| 97 } | 97 } |
| 98 | 98 |
| 99 SkString CopyTilesRenderer::getConfigNameInternal() { | 99 SkString CopyTilesRenderer::getConfigNameInternal() { |
| 100 return SkString("copy_tiles"); | 100 return SkString("copy_tiles"); |
| 101 } | 101 } |
| 102 } | 102 } |
| OLD | NEW |