| 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" |
| 11 #include "SampleCode.h" | 11 #include "SampleCode.h" |
| 12 #include "SkBlurMaskFilter.h" | 12 #include "SkBlurMaskFilter.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "SkColorPriv.h" | 14 #include "SkColorPriv.h" |
| 15 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
| 16 #include "SkPath.h" | 16 #include "SkPath.h" |
| 17 #include "SkRandom.h" | 17 #include "SkRandom.h" |
| 18 #include "SkStream.h" | 18 #include "SkStream.h" |
| 19 #include "SkTime.h" | 19 #include "SkTime.h" |
| 20 | 20 |
| 21 // Intended to exercise pixel snapping observed with scaled images (and | 21 // Intended to exercise pixel snapping observed with scaled images (and |
| 22 // with non-scaled images, but for a different reason): Bug 1145 | 22 // with non-scaled images, but for a different reason): Bug 1145 |
| 23 | 23 |
| 24 class IdentityScaleView : public SampleView { | 24 class IdentityScaleView : public SampleView { |
| 25 public: | 25 public: |
| 26 IdentityScaleView(const char imageFilename[]) { | 26 IdentityScaleView(const char imageFilename[]) { |
| 27 SkString resourcePath = GetResourcePath(imageFilename); | 27 SkString resourcePath = GetResourcePath(imageFilename); |
| 28 SkImageDecoder* codec = NULL; | 28 SkImageDecoder* codec = nullptr; |
| 29 SkFILEStream stream(resourcePath.c_str()); | 29 SkFILEStream stream(resourcePath.c_str()); |
| 30 if (stream.isValid()) { | 30 if (stream.isValid()) { |
| 31 codec = SkImageDecoder::Factory(&stream); | 31 codec = SkImageDecoder::Factory(&stream); |
| 32 } | 32 } |
| 33 if (codec) { | 33 if (codec) { |
| 34 stream.rewind(); | 34 stream.rewind(); |
| 35 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); | 35 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode
Pixels_Mode); |
| 36 delete codec; | 36 delete codec; |
| 37 } else { | 37 } else { |
| 38 fBM.allocN32Pixels(1, 1); | 38 fBM.allocN32Pixels(1, 1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 SkRect r = { 100, 100, 356, 356 }; | 74 SkRect r = { 100, 100, 356, 356 }; |
| 75 SkPath clipPath; | 75 SkPath clipPath; |
| 76 clipPath.addRoundRect(r, SkIntToScalar(5), SkIntToScalar(5)); | 76 clipPath.addRoundRect(r, SkIntToScalar(5), SkIntToScalar(5)); |
| 77 canvas->clipPath(clipPath, SkRegion::kIntersect_Op, SkToBool(1)); | 77 canvas->clipPath(clipPath, SkRegion::kIntersect_Op, SkToBool(1)); |
| 78 text = "Scaled = 0"; | 78 text = "Scaled = 0"; |
| 79 } | 79 } |
| 80 canvas->drawBitmap( fBM, 100, 100, &paint ); | 80 canvas->drawBitmap( fBM, 100, 100, &paint ); |
| 81 canvas->restore(); | 81 canvas->restore(); |
| 82 canvas->drawText( text, strlen(text), 100, 400, paint ); | 82 canvas->drawText( text, strlen(text), 100, 400, paint ); |
| 83 this->inval(NULL); | 83 this->inval(nullptr); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 typedef SampleView INHERITED; | 87 typedef SampleView INHERITED; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 ////////////////////////////////////////////////////////////////////////////// | 90 ////////////////////////////////////////////////////////////////////////////// |
| 91 | 91 |
| 92 static SkView* MyFactory() { return new IdentityScaleView("mandrill_256.png"); } | 92 static SkView* MyFactory() { return new IdentityScaleView("mandrill_256.png"); } |
| 93 static SkViewRegister reg(MyFactory); | 93 static SkViewRegister reg(MyFactory); |
| OLD | NEW |