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