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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
69 if (!fWritePath.isEmpty()) { | 69 if (!fWritePath.isEmpty()) { |
70 // Similar to write() in PictureRenderer.cpp, but ju
st encodes | 70 // Similar to write() in PictureRenderer.cpp, but ju
st encodes |
71 // a bitmap directly. | 71 // a bitmap directly. |
72 // TODO: Share more common code with write() to do t
his, to properly | 72 // TODO: Share more common code with write() to do t
his, to properly |
73 // write out the JSON summary, etc. | 73 // write out the JSON summary, etc. |
74 SkString pathWithNumber; | 74 SkString pathWithNumber = SkOSPath::SkPathJoin(fWrit
ePath.c_str(), |
75 make_filepath(&pathWithNumber, fWritePath, fInputFil
ename); | 75 fInpu
tFilename.c_str()); |
76 pathWithNumber.remove(pathWithNumber.size() - 4, 4); | 76 pathWithNumber.remove(pathWithNumber.size() - 4, 4); |
77 pathWithNumber.appendf("%i.png", i++); | 77 pathWithNumber.appendf("%i.png", i++); |
78 SkBitmap copy; | 78 SkBitmap copy; |
79 #if SK_SUPPORT_GPU | 79 #if SK_SUPPORT_GPU |
80 if (isUsingGpuDevice()) { | 80 if (isUsingGpuDevice()) { |
81 dst.pixelRef()->readPixels(©, &subset); | 81 dst.pixelRef()->readPixels(©, &subset); |
82 } else { | 82 } else { |
83 #endif | 83 #endif |
84 dst.copyTo(©); | 84 dst.copyTo(©); |
85 #if SK_SUPPORT_GPU | 85 #if SK_SUPPORT_GPU |
86 } | 86 } |
87 #endif | 87 #endif |
88 success &= SkImageEncoder::EncodeFile(pathWithNumber
.c_str(), copy, | 88 success &= SkImageEncoder::EncodeFile(pathWithNumber
.c_str(), copy, |
89 SkImageEncoder
::kPNG_Type, 100); | 89 SkImageEncoder
::kPNG_Type, 100); |
90 } | 90 } |
91 } | 91 } |
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 |