| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #include "gm.h" | 8 #include "gm.h" |
| 9 |
| 10 #include "Resources.h" |
| 10 #include "SampleCode.h" | 11 #include "SampleCode.h" |
| 11 #include "SkBlurMaskFilter.h" | 12 #include "SkBlurMaskFilter.h" |
| 13 #include "SkCanvas.h" |
| 12 #include "SkColorPriv.h" | 14 #include "SkColorPriv.h" |
| 13 #include "SkCanvas.h" | |
| 14 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
| 15 #include "SkRandom.h" | 16 #include "SkRandom.h" |
| 16 #include "SkStream.h" | 17 #include "SkStream.h" |
| 17 | 18 |
| 18 // Intended to exercise pixel snapping observed with scaled images (and | 19 // Intended to exercise pixel snapping observed with scaled images (and |
| 19 // with non-scaled images, but for a different reason): Bug 1145 | 20 // with non-scaled images, but for a different reason): Bug 1145 |
| 20 | 21 |
| 21 class SubpixelTranslateView : public SampleView { | 22 class SubpixelTranslateView : public SampleView { |
| 22 public: | 23 public: |
| 23 SubpixelTranslateView(const char imageFilename[], | 24 SubpixelTranslateView(const char imageFilename[], |
| 24 float horizontalVelocity, | 25 float horizontalVelocity, |
| 25 float verticalVelocity) | 26 float verticalVelocity) |
| 26 : fFilename(imageFilename), | 27 : fFilename(imageFilename), |
| 27 fHorizontalVelocity(horizontalVelocity), | 28 fHorizontalVelocity(horizontalVelocity), |
| 28 fVerticalVelocity(verticalVelocity) { | 29 fVerticalVelocity(verticalVelocity) { |
| 29 SkString path(skiagm::GM::GetResourcePath()); | 30 SkString resourcePath = GetResourcePath(); |
| 30 path.append("/"); | 31 resourcePath.append("/"); |
| 31 path.append(fFilename); | 32 resourcePath.append(fFilename); |
| 32 | 33 |
| 33 SkImageDecoder *codec = NULL; | 34 SkImageDecoder* codec = NULL; |
| 34 SkFILEStream stream(path.c_str()); | 35 SkFILEStream stream(resourcePath.c_str()); |
| 35 if (stream.isValid()) { | 36 if (stream.isValid()) { |
| 36 codec = SkImageDecoder::Factory(&stream); | 37 codec = SkImageDecoder::Factory(&stream); |
| 37 } | 38 } |
| 38 if (codec) { | 39 if (codec) { |
| 39 stream.rewind(); | 40 stream.rewind(); |
| 40 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); | 41 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); |
| 41 SkDELETE(codec); | 42 SkDELETE(codec); |
| 42 } else { | 43 } else { |
| 43 fBM.allocN32Pixels(1, 1); | 44 fBM.allocN32Pixels(1, 1); |
| 44 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad | 45 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 117 } |
| 117 | 118 |
| 118 private: | 119 private: |
| 119 typedef SampleView INHERITED; | 120 typedef SampleView INHERITED; |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 ////////////////////////////////////////////////////////////////////////////// | 123 ////////////////////////////////////////////////////////////////////////////// |
| 123 | 124 |
| 124 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png"
, .05f, .05f); } | 125 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png"
, .05f, .05f); } |
| 125 static SkViewRegister reg(MyFactory); | 126 static SkViewRegister reg(MyFactory); |
| OLD | NEW |