Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | #if 0 // Disabled until updated to use current API. |
| 2 | // Copyright 2019 Google LLC. |
| 3 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 4 | #include "fiddle/examples.h" |
| 5 | // HASH=6de6f3ef699a72ff26da1b26b23a3316 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Surface_characterize, 256, 64, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | void draw(SkCanvas* canvas) { |
| 8 | SkPaint paint; |
| 9 | paint.setTextSize(32); |
| 10 | GrContext* context = canvas->getGrContext(); |
| 11 | if (!context) { |
| 12 | canvas->drawString("GPU only!", 20, 40, paint); |
| 13 | return; |
| 14 | } |
| 15 | sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget( |
| 16 | context, SkBudgeted::kYes, SkImageInfo::MakeN32Premul(64, 64)); |
| 17 | SkSurfaceCharacterization characterization; |
| 18 | if (!gpuSurface->characterize(&characterization)) { |
| 19 | canvas->drawString("characterization unsupported", 20, 40, paint); |
| 20 | return; |
| 21 | } |
| 22 | // start of threadable work |
| 23 | SkDeferredDisplayListRecorder recorder(characterization); |
| 24 | SkCanvas* subCanvas = recorder.getCanvas(); |
| 25 | subCanvas->clear(SK_ColorGREEN); |
| 26 | std::unique_ptr<SkDeferredDisplayList> displayList = recorder.detach(); |
| 27 | // end of threadable work |
| 28 | gpuSurface->draw(displayList.get()); |
| 29 | sk_sp<SkImage> img = gpuSurface->makeImageSnapshot(); |
| 30 | canvas->drawImage(std::move(img), 0, 0); |
| 31 | } |
| 32 | } // END FIDDLE |
| 33 | #endif // Disabled until updated to use current API. |