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 |
| 10 #include "Resources.h" |
| 11 #include "SkBitmapProcState.h" |
| 12 #include "SkBitmapScaler.h" |
9 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
10 | 14 #include "SkImageDecoder.h" |
| 15 #include "SkImageEncoder.h" |
| 16 #include "SkStream.h" |
11 #include "SkTypeface.h" | 17 #include "SkTypeface.h" |
12 #include "SkImageDecoder.h" | |
13 #include "SkStream.h" | |
14 | |
15 #include "SkImageEncoder.h" | |
16 #include "SkBitmapScaler.h" | |
17 #include "SkBitmapProcState.h" | |
18 | 18 |
19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { | 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { |
20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), | 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), |
21 SkIntToScalar(bm.height())); | 21 SkIntToScalar(bm.height())); |
22 mat.mapRect(&bounds); | 22 mat.mapRect(&bounds); |
23 return SkSize::Make(bounds.width(), bounds.height()); | 23 return SkSize::Make(bounds.width(), bounds.height()); |
24 } | 24 } |
25 | 25 |
26 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { | 26 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { |
27 SkPaint paint; | 27 SkPaint paint; |
(...skipping 69 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 path(skiagm::GM::gResourcePath); | 107 SkString resourcePath = GetResourcePath(); |
108 path.append("/"); | 108 resourcePath.append("/"); |
109 path.append(fFilename); | 109 resourcePath.append(fFilename); |
110 | 110 |
111 SkImageDecoder *codec = NULL; | 111 SkImageDecoder* codec = NULL; |
112 SkFILEStream stream(path.c_str()); | 112 SkFILEStream stream(resourcePath.c_str()); |
113 if (stream.isValid()) { | 113 if (stream.isValid()) { |
114 codec = SkImageDecoder::Factory(&stream); | 114 codec = SkImageDecoder::Factory(&stream); |
115 } | 115 } |
116 if (codec) { | 116 if (codec) { |
117 stream.rewind(); | 117 stream.rewind(); |
118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); | 118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); |
119 SkDELETE(codec); | 119 SkDELETE(codec); |
120 } else { | 120 } else { |
121 fBM.allocN32Pixels(1, 1); | 121 fBM.allocN32Pixels(1, 1); |
122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad | 122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad |
123 } | 123 } |
124 fSize = fBM.height(); | 124 fSize = fBM.height(); |
125 } | 125 } |
126 private: | 126 private: |
127 typedef skiagm::GM INHERITED; | 127 typedef skiagm::GM INHERITED; |
128 }; | 128 }; |
129 | 129 |
130 ////////////////////////////////////////////////////////////////////////////// | 130 ////////////////////////////////////////////////////////////////////////////// |
131 | 131 |
132 | 132 |
133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) | 133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) |
OLD | NEW |