| 1 |
// Copyright 2019 Google LLC. |
| 2 |
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 3 |
#include "tools/fiddle/examples.h" |
| 4 |
REG_FIDDLE(Image_BorrowTextureFrom, 256, 128, false, 3) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
auto dContext = GrAsDirectContext(canvas->recordingContext()); |
| 7 |
if (!dContext) { |
| 8 |
return; |
| 9 |
} |
| 10 |
|
| 11 |
canvas->scale(.25f, .25f); |
| 12 |
int x = 0; |
| 13 |
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) { |
| 14 |
sk_sp<SkImage> image = SkImages::BorrowTextureFrom(dContext, |
| 15 |
backEndTexture, |
| 16 |
origin, |
| 17 |
kRGBA_8888_SkColorType, |
| 18 |
kOpaque_SkAlphaType, |
| 19 |
nullptr); |
| 20 |
canvas->drawImage(image, x, 0); |
| 21 |
x += 512; |
| 22 |
} |
| 23 |
} |
| 24 |
} // END FIDDLE |