| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 11 #include "SkImage.h" | 11 #include "SkImage.h" |
| 12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
| 13 #include "SkShader.h" | 13 #include "SkShader.h" |
| 14 #include "SkSurface.h" | 14 #include "SkSurface.h" |
| 15 | 15 |
| 16 static SkImage* makebm(SkCanvas* caller, int w, int h) { | 16 static SkImage* makebm(SkCanvas* caller, int w, int h) { |
| 17 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); | 17 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); |
| 18 SkAutoTUnref<SkSurface> surface(caller->newSurface(info)); | 18 SkAutoTUnref<SkSurface> surface(caller->newSurface(info)); |
| 19 if (NULL == surface) { | 19 if (nullptr == surface) { |
| 20 surface.reset(SkSurface::NewRaster(info)); | 20 surface.reset(SkSurface::NewRaster(info)); |
| 21 } | 21 } |
| 22 SkCanvas* canvas = surface->getCanvas(); | 22 SkCanvas* canvas = surface->getCanvas(); |
| 23 | 23 |
| 24 const SkScalar wScalar = SkIntToScalar(w); | 24 const SkScalar wScalar = SkIntToScalar(w); |
| 25 const SkScalar hScalar = SkIntToScalar(h); | 25 const SkScalar hScalar = SkIntToScalar(h); |
| 26 | 26 |
| 27 const SkPoint pt = { wScalar / 2, hScalar / 2 }; | 27 const SkPoint pt = { wScalar / 2, hScalar / 2 }; |
| 28 | 28 |
| 29 const SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar); | 29 const SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 fName.appendf("_aa"); | 72 fName.appendf("_aa"); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 protected: | 76 protected: |
| 77 SkString onShortName() override { return fName; } | 77 SkString onShortName() override { return fName; } |
| 78 | 78 |
| 79 SkISize onISize() override { return SkISize::Make(gSize, gSize); } | 79 SkISize onISize() override { return SkISize::Make(gSize, gSize); } |
| 80 | 80 |
| 81 void onDraw(SkCanvas* canvas) override { | 81 void onDraw(SkCanvas* canvas) override { |
| 82 if (NULL == fImage) { | 82 if (nullptr == fImage) { |
| 83 fImage.reset(makebm(canvas, gSurfaceSize, gSurfaceSize)); | 83 fImage.reset(makebm(canvas, gSurfaceSize, gSurfaceSize)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; | 86 const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; |
| 87 static const int kMaxSrcRectSize = 1 << (SkNextLog2(gSurfaceSize) + 2); | 87 static const int kMaxSrcRectSize = 1 << (SkNextLog2(gSurfaceSize) + 2); |
| 88 | 88 |
| 89 static const int kPadX = 30; | 89 static const int kPadX = 30; |
| 90 static const int kPadY = 40; | 90 static const int kPadY = 40; |
| 91 | 91 |
| 92 int rowCount = 0; | 92 int rowCount = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool fAA; | 134 bool fAA; |
| 135 SkAutoTUnref<SkImage> fImage; | 135 SkAutoTUnref<SkImage> fImage; |
| 136 SkString fName; | 136 SkString fName; |
| 137 | 137 |
| 138 typedef skiagm::GM INHERITED; | 138 typedef skiagm::GM INHERITED; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 DEF_GM( return new DrawMiniBitmapRectGM(true); ) | 141 DEF_GM( return new DrawMiniBitmapRectGM(true); ) |
| 142 DEF_GM( return new DrawMiniBitmapRectGM(false); ) | 142 DEF_GM( return new DrawMiniBitmapRectGM(false); ) |
| 143 | 143 |
| OLD | NEW |