| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2016 Google Inc. | 2  * Copyright 2016 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 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. | 
| 9 | 9 | 
| 10 #include "gm.h" | 10 #include "gm.h" | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 120         return nullptr; | 120         return nullptr; | 
| 121     } | 121     } | 
| 122 | 122 | 
| 123     void onDraw(SkCanvas* canvas) override { | 123     void onDraw(SkCanvas* canvas) override { | 
| 124         GrContext *context = canvas->getGrContext(); | 124         GrContext *context = canvas->getGrContext(); | 
| 125         if (!context) { | 125         if (!context) { | 
| 126             skiagm::GM::DrawGpuOnlyMessage(canvas); | 126             skiagm::GM::DrawGpuOnlyMessage(canvas); | 
| 127             return; | 127             return; | 
| 128         } | 128         } | 
| 129 | 129 | 
| 130         static const int kWidth = 50; | 130         constexpr int kWidth = 50; | 
| 131         static const int kHeight = 50; | 131         constexpr int kHeight = 50; | 
| 132         static const SkScalar kPad = 5.f; | 132         constexpr SkScalar kPad = 5.f; | 
| 133 | 133 | 
| 134         SkPMColor pixels[kWidth * kHeight]; | 134         SkPMColor pixels[kWidth * kHeight]; | 
| 135         this->fillPixels(kWidth, kHeight, pixels); | 135         this->fillPixels(kWidth, kHeight, pixels); | 
| 136         sk_sp<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, 
     kHeight, pixels)); | 136         sk_sp<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, 
     kHeight, pixels)); | 
| 137 | 137 | 
| 138         if (!rectImg) { | 138         if (!rectImg) { | 
| 139             SkPaint paint; | 139             SkPaint paint; | 
| 140             paint.setAntiAlias(true); | 140             paint.setAntiAlias(true); | 
| 141             static const char* kMsg = "Could not create rectangle texture image.
     "; | 141             const char* kMsg = "Could not create rectangle texture image."; | 
| 142             canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint); | 142             canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint); | 
| 143             return; | 143             return; | 
| 144         } | 144         } | 
| 145 | 145 | 
| 146         static const SkFilterQuality kQualities[] = { | 146         constexpr SkFilterQuality kQualities[] = { | 
| 147             kNone_SkFilterQuality, | 147             kNone_SkFilterQuality, | 
| 148             kLow_SkFilterQuality, | 148             kLow_SkFilterQuality, | 
| 149             kMedium_SkFilterQuality, | 149             kMedium_SkFilterQuality, | 
| 150             kHigh_SkFilterQuality, | 150             kHigh_SkFilterQuality, | 
| 151         }; | 151         }; | 
| 152 | 152 | 
| 153         static const SkScalar kScales[] = { 1.0f, 1.2f, 0.75f }; | 153         constexpr SkScalar kScales[] = { 1.0f, 1.2f, 0.75f }; | 
| 154 | 154 | 
| 155         canvas->translate(kPad, kPad); | 155         canvas->translate(kPad, kPad); | 
| 156         for (auto s : kScales) { | 156         for (auto s : kScales) { | 
| 157             canvas->save(); | 157             canvas->save(); | 
| 158             canvas->scale(s, s); | 158             canvas->scale(s, s); | 
| 159             for (auto q : kQualities) { | 159             for (auto q : kQualities) { | 
| 160                 SkPaint plainPaint; | 160                 SkPaint plainPaint; | 
| 161                 plainPaint.setFilterQuality(q); | 161                 plainPaint.setFilterQuality(q); | 
| 162                 canvas->drawImage(rectImg.get(), 0, 0, &plainPaint); | 162                 canvas->drawImage(rectImg.get(), 0, 0, &plainPaint); | 
| 163                 canvas->translate(kWidth + kPad, 0); | 163                 canvas->translate(kWidth + kPad, 0); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 182     } | 182     } | 
| 183 | 183 | 
| 184 private: | 184 private: | 
| 185     typedef GM INHERITED; | 185     typedef GM INHERITED; | 
| 186 }; | 186 }; | 
| 187 | 187 | 
| 188 DEF_GM(return new RectangleTexture;) | 188 DEF_GM(return new RectangleTexture;) | 
| 189 } | 189 } | 
| 190 | 190 | 
| 191 #endif | 191 #endif | 
| OLD | NEW | 
|---|