1 /* 2 * Copyright 2023 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 #ifndef ProtectedUtils_DEFINED 9 #define ProtectedUtils_DEFINED 10 11 #include "include/core/SkColor.h" 12 #include "include/core/SkRefCnt.h" 13 14 class GrDirectContext; 15 class SkImage; 16 class SkSurface; 17 class SkSurfaceProps; 18 struct SkISize; 19 20 #ifdef SK_GRAPHITE 21 namespace skgpu { 22 enum class Protected : bool; 23 } 24 namespace skgpu::graphite { 25 class Recorder; 26 } 27 #endif 28 29 namespace ProtectedUtils { 30 31 /* 32 * These factories create Surfaces and Images with an explicitly specified protected status. 33 * If the Surface/Image cannot be created with the specified protected status nullptr will 34 * be returned. 35 */ 36 37 sk_sp<SkSurface> CreateProtectedSkSurface(GrDirectContext*, 38 SkISize size, 39 bool textureable, 40 bool isProtected, 41 const SkSurfaceProps* = nullptr); 42 43 void CheckImageBEProtection(SkImage*, bool expectingProtected); 44 45 sk_sp<SkImage> CreateProtectedSkImage(GrDirectContext*, 46 SkISize size, 47 SkColor4f color, 48 bool isProtected); 49 50 #ifdef SK_GRAPHITE 51 sk_sp<SkSurface> CreateProtectedSkSurface(skgpu::graphite::Recorder*, 52 SkISize size, 53 skgpu::Protected); 54 55 sk_sp<SkImage> CreateProtectedSkImage(skgpu::graphite::Recorder*, 56 SkISize size, 57 SkColor4f color, 58 skgpu::Protected); 59 #endif 60 61 } // namespace ProtectedUtils 62 63 #endif // ProtectedUtils_DEFINED 64