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