| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
| 9 | 9 |
| 10 #include "Resources.h" | 10 #include "Resources.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (fResPath.size() == 0) { | 99 if (fResPath.size() == 0) { |
| 100 failure.printf("resource path is required!"); | 100 failure.printf("resource path is required!"); |
| 101 } else { | 101 } else { |
| 102 failure.printf("Failed to decode %s", fCurrFile.c_str()); | 102 failure.printf("Failed to decode %s", fCurrFile.c_str()); |
| 103 } | 103 } |
| 104 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint); | 104 canvas->drawText(failure.c_str(), failure.size(), 0, height, paint); |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Name, size of the file, and whether or not it is premultiplied. | 108 // Name, size of the file, and whether or not it is premultiplied. |
| 109 SkString header(SkOSPath::SkBasename(fCurrFile.c_str())); | 109 SkString header(SkOSPath::Basename(fCurrFile.c_str())); |
| 110 header.appendf(" [%dx%d] %s", fBitmap.width(), fBitmap.height(), | 110 header.appendf(" [%dx%d] %s", fBitmap.width(), fBitmap.height(), |
| 111 (fPremul ? "premultiplied" : "unpremultiplied")); | 111 (fPremul ? "premultiplied" : "unpremultiplied")); |
| 112 canvas->drawText(header.c_str(), header.size(), 0, height, paint); | 112 canvas->drawText(header.c_str(), header.size(), 0, height, paint); |
| 113 canvas->translate(0, height); | 113 canvas->translate(0, height); |
| 114 | 114 |
| 115 // Help messages | 115 // Help messages |
| 116 header.printf("Press '%c' to move to the next image.'", fNextImageChar); | 116 header.printf("Press '%c' to move to the next image.'", fNextImageChar); |
| 117 canvas->drawText(header.c_str(), header.size(), 0, height, paint); | 117 canvas->drawText(header.c_str(), header.size(), 0, height, paint); |
| 118 canvas->translate(0, height); | 118 canvas->translate(0, height); |
| 119 | 119 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 SkString basename; | 162 SkString basename; |
| 163 if (!fFileIter.next(&basename)) { | 163 if (!fFileIter.next(&basename)) { |
| 164 fFileIter.reset(fResPath.c_str()); | 164 fFileIter.reset(fResPath.c_str()); |
| 165 if (!fFileIter.next(&basename)) { | 165 if (!fFileIter.next(&basename)) { |
| 166 // Perhaps this should draw some error message? | 166 // Perhaps this should draw some error message? |
| 167 return; | 167 return; |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 fCurrFile = SkOSPath::SkPathJoin(fResPath.c_str(), basename.c_str()); | 170 fCurrFile = SkOSPath::Join(fResPath.c_str(), basename.c_str()); |
| 171 this->decodeCurrFile(); | 171 this->decodeCurrFile(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void decodeCurrFile() { | 174 void decodeCurrFile() { |
| 175 if (fCurrFile.size() == 0) { | 175 if (fCurrFile.size() == 0) { |
| 176 fDecodeSucceeded = false; | 176 fDecodeSucceeded = false; |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 SkFILEStream stream(fCurrFile.c_str()); | 179 SkFILEStream stream(fCurrFile.c_str()); |
| 180 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); | 180 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 197 | 197 |
| 198 typedef SampleView INHERITED; | 198 typedef SampleView INHERITED; |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 ////////////////////////////////////////////////////////////////////////////// | 201 ////////////////////////////////////////////////////////////////////////////// |
| 202 | 202 |
| 203 static SkView* MyFactory() { | 203 static SkView* MyFactory() { |
| 204 return new UnpremulView(GetResourcePath()); | 204 return new UnpremulView(GetResourcePath()); |
| 205 } | 205 } |
| 206 static SkViewRegister reg(MyFactory); | 206 static SkViewRegister reg(MyFactory); |
| OLD | NEW |