1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2020 Google LLC 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "include/core/SkColor.h" 9cb93a386Sopenharmony_ci#include "include/core/SkRefCnt.h" 10cb93a386Sopenharmony_ci#include "include/gpu/GrTypes.h" 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ciclass GrDirectContext; 13cb93a386Sopenharmony_ciclass SkColorSpace; 14cb93a386Sopenharmony_ciclass SkImage; 15cb93a386Sopenharmony_ciclass SkPixmap; 16cb93a386Sopenharmony_cistruct SkISize; 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_cinamespace sk_gpu_test { 19cb93a386Sopenharmony_ci/** 20cb93a386Sopenharmony_ci * Creates a backend texture with pixmap contents and wraps it in a SkImage that safely deletes 21cb93a386Sopenharmony_ci * the texture when it goes away. Unlike using makeTextureImage() on a non-GPU image, this will 22cb93a386Sopenharmony_ci * fail rather than fallback if the pixmaps's color type doesn't map to a supported texture format. 23cb93a386Sopenharmony_ci * For testing purposes the texture can be made renderable to exercise different code paths for 24cb93a386Sopenharmony_ci * renderable textures/formats. 25cb93a386Sopenharmony_ci */ 26cb93a386Sopenharmony_cisk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*, 27cb93a386Sopenharmony_ci const SkPixmap&, 28cb93a386Sopenharmony_ci GrRenderable, 29cb93a386Sopenharmony_ci GrSurfaceOrigin); 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci/** Creates an image of with a solid color. */ 32cb93a386Sopenharmony_cisk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*, 33cb93a386Sopenharmony_ci const SkImageInfo& info, 34cb93a386Sopenharmony_ci SkColor4f, 35cb93a386Sopenharmony_ci GrMipmapped = GrMipmapped::kNo, 36cb93a386Sopenharmony_ci GrRenderable = GrRenderable::kNo, 37cb93a386Sopenharmony_ci GrSurfaceOrigin = GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin); 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_ci} // namespace sk_gpu_test 40