OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 17 matching lines...) Expand all Loading... |
28 fVerticalVelocity(verticalVelocity) { | 28 fVerticalVelocity(verticalVelocity) { |
29 SkString resourcePath = GetResourcePath(imageFilename); | 29 SkString resourcePath = GetResourcePath(imageFilename); |
30 SkImageDecoder* codec = NULL; | 30 SkImageDecoder* codec = NULL; |
31 SkFILEStream stream(resourcePath.c_str()); | 31 SkFILEStream stream(resourcePath.c_str()); |
32 if (stream.isValid()) { | 32 if (stream.isValid()) { |
33 codec = SkImageDecoder::Factory(&stream); | 33 codec = SkImageDecoder::Factory(&stream); |
34 } | 34 } |
35 if (codec) { | 35 if (codec) { |
36 stream.rewind(); | 36 stream.rewind(); |
37 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); | 37 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); |
38 SkDELETE(codec); | 38 delete codec; |
39 } else { | 39 } else { |
40 fBM.allocN32Pixels(1, 1); | 40 fBM.allocN32Pixels(1, 1); |
41 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad | 41 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad |
42 } | 42 } |
43 fCurPos = SkPoint::Make(0,0); | 43 fCurPos = SkPoint::Make(0,0); |
44 fSize = 200; | 44 fSize = 200; |
45 } | 45 } |
46 | 46 |
47 protected: | 47 protected: |
48 SkBitmap fBM; | 48 SkBitmap fBM; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 private: | 115 private: |
116 typedef SampleView INHERITED; | 116 typedef SampleView INHERITED; |
117 }; | 117 }; |
118 | 118 |
119 ////////////////////////////////////////////////////////////////////////////// | 119 ////////////////////////////////////////////////////////////////////////////// |
120 | 120 |
121 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png"
, .05f, .05f); } | 121 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png"
, .05f, .05f); } |
122 static SkViewRegister reg(MyFactory); | 122 static SkViewRegister reg(MyFactory); |
OLD | NEW |