| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 SkString fFilename; | 99 SkString fFilename; |
| 100 int fSize; | 100 int fSize; |
| 101 | 101 |
| 102 SkScalar getScale() { | 102 SkScalar getScale() { |
| 103 return 192.f/fSize; | 103 return 192.f/fSize; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void makeBitmap() { | 106 void makeBitmap() { |
| 107 SkString resourcePath = GetResourcePath(); | |
| 108 resourcePath.append("/"); | |
| 109 resourcePath.append(fFilename); | |
| 110 | |
| 111 SkImageDecoder* codec = NULL; | 107 SkImageDecoder* codec = NULL; |
| 108 SkString resourcePath = GetResourcePath(fFilename.c_str()); |
| 112 SkFILEStream stream(resourcePath.c_str()); | 109 SkFILEStream stream(resourcePath.c_str()); |
| 113 if (stream.isValid()) { | 110 if (stream.isValid()) { |
| 114 codec = SkImageDecoder::Factory(&stream); | 111 codec = SkImageDecoder::Factory(&stream); |
| 115 } | 112 } |
| 116 if (codec) { | 113 if (codec) { |
| 117 stream.rewind(); | 114 stream.rewind(); |
| 118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); | 115 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); |
| 119 SkDELETE(codec); | 116 SkDELETE(codec); |
| 120 } else { | 117 } else { |
| 121 fBM.allocN32Pixels(1, 1); | 118 fBM.allocN32Pixels(1, 1); |
| 122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad | 119 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad |
| 123 } | 120 } |
| 124 fSize = fBM.height(); | 121 fSize = fBM.height(); |
| 125 } | 122 } |
| 126 private: | 123 private: |
| 127 typedef skiagm::GM INHERITED; | 124 typedef skiagm::GM INHERITED; |
| 128 }; | 125 }; |
| 129 | 126 |
| 130 ////////////////////////////////////////////////////////////////////////////// | 127 ////////////////////////////////////////////////////////////////////////////// |
| 131 | 128 |
| 132 | 129 |
| 133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) | 130 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) |
| OLD | NEW |