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/ganesh/GrTypes.h" 13 14 class SkColorSpace; 15 class SkImage; 16 class SkPixmap; 17 struct SkISize; 18 19 #ifdef SK_GANESH 20 class GrDirectContext; 21 #endif 22 23 #ifdef SK_GRAPHITE 24 namespace skgpu::graphite { 25 class Recorder; 26 } 27 using Origin = skgpu::Origin; // TODO: Can we migrate Ganesh to use this? 28 #endif 29 30 namespace sk_gpu_test { 31 32 using Mipmapped = skgpu::Mipmapped; 33 using Protected = skgpu::Protected; 34 using Renderable = skgpu::Renderable; 35 36 #ifdef SK_GANESH 37 /** 38 * Creates a backend texture with pixmap contents and wraps it in a SkImage that safely deletes 39 * the texture when it goes away. Unlike using makeTextureImage() on a non-GPU image, this will 40 * fail rather than fallback if the pixmaps's color type doesn't map to a supported texture format. 41 * For testing purposes the texture can be made renderable to exercise different code paths for 42 * renderable textures/formats. 43 */ 44 sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*, 45 const SkPixmap&, 46 Renderable, 47 GrSurfaceOrigin, 48 Protected = Protected::kNo); 49 50 /** Creates a solid color image. */ 51 sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*, 52 const SkImageInfo& info, 53 SkColor4f, 54 Mipmapped = Mipmapped::kNo, 55 Renderable = Renderable::kNo, 56 GrSurfaceOrigin = GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin, 57 Protected isProtected = Protected::kNo); 58 #endif // SK_GANESH 59 60 #ifdef SK_GRAPHITE 61 /* 62 * Graphite versions of MakeBackendTextureImage 63 */ 64 sk_sp<SkImage> MakeBackendTextureImage(skgpu::graphite::Recorder*, 65 const SkPixmap&, 66 Mipmapped, 67 Renderable, 68 Origin, 69 Protected = Protected::kNo); 70 71 /** Creates a solid color image. */ 72 sk_sp<SkImage> MakeBackendTextureImage(skgpu::graphite::Recorder*, 73 const SkImageInfo&, 74 SkColor4f, 75 Mipmapped, 76 Renderable, 77 Origin, 78 Protected = Protected::kNo); 79 80 #endif // SK_GRAPHITE 81 82 } // namespace sk_gpu_test 83