2019-03-15 18:22:51 +00:00
|
|
|
// Copyright 2019 Google LLC.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/fiddle/examples.h"
|
2019-03-15 18:22:51 +00:00
|
|
|
// HASH=b034517e39394b7543f06ec885e36d7d
|
2019-03-18 20:06:34 +00:00
|
|
|
REG_FIDDLE(Image_MakeFromAdoptedTexture, 256, 256, false, 5) {
|
2019-03-15 18:22:51 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
2020-07-29 16:50:56 +00:00
|
|
|
GrDirectContext* dContext = GrAsDirectContext(canvas->recordingContext());
|
|
|
|
// Example does not support DDL.
|
|
|
|
if (!dContext) {
|
2019-03-15 18:22:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
canvas->scale(.5f, .5f);
|
|
|
|
canvas->clear(0x7f3f5f7f);
|
|
|
|
int x = 0, y = 0;
|
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
|
|
|
|
for (auto alpha : { kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType } ) {
|
2020-07-29 16:50:56 +00:00
|
|
|
sk_sp<SkImage> image = SkImage::MakeFromAdoptedTexture(dContext,
|
2019-03-15 18:22:51 +00:00
|
|
|
backEndTexture, origin,
|
|
|
|
kRGBA_8888_SkColorType, alpha);
|
|
|
|
canvas->drawImage(image, x, y);
|
|
|
|
x += 160;
|
|
|
|
}
|
|
|
|
x -= 160 * 3;
|
|
|
|
y += 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // END FIDDLE
|