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. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 4 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 5 | // HASH=eeec9e07e604b44d0208899a2fe5bef5 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Image_makeTextureImage, 256, 256, false, 5) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | void draw(SkCanvas* canvas) { |
| 8 | auto drawImage = [=](sk_sp<SkImage> image, GrContext* context, const char* label) -> void { |
| 9 | if (nullptr == image || nullptr == context) { |
| 10 | return; |
| 11 | } |
| 12 | SkPaint paint; |
| 13 | paint.setAntiAlias(true); |
| 14 | sk_sp<SkImage> texture(image->makeTextureImage(context, nullptr)); |
| 15 | canvas->drawImage(texture, 0, 0); |
| 16 | canvas->drawString(label, 20, texture->height() / 4, paint); |
| 17 | }; |
| 18 | sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source)); |
| 19 | GrContext* context = canvas->getGrContext(); |
| 20 | sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(context, backEndTexture, |
| 21 | kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, |
| 22 | kOpaque_SkAlphaType, nullptr)); |
| 23 | drawImage(image, context, "image"); |
| 24 | canvas->translate(image->width(), 0); |
| 25 | drawImage(bitmapImage, context, "source"); |
| 26 | canvas->translate(-image->width(), image->height()); |
| 27 | drawImage(textureImage, context, "backEndTexture"); |
| 28 | } |
| 29 | } // END FIDDLE |
| 30 | #endif // Disabled until updated to use current API. |