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