1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.ink.rendering.android 18 19 import android.graphics.Bitmap 20 import androidx.ink.brush.ExperimentalInkCustomBrushApi 21 22 /** 23 * Interface for a callback to allow the caller to provide a particular [Bitmap] corresponding to a 24 * client-provided texture ID. 25 */ 26 @ExperimentalInkCustomBrushApi 27 public fun interface TextureBitmapStore { 28 /** 29 * Retrieve a [Bitmap] for the given texture id. This may be called synchronously during 30 * `onDraw`, so loading of texture files from disk and decoding them into [Bitmap] objects 31 * should be done on init. The result may be cached by consumers, so this should return a 32 * deterministic result for a given input. 33 * 34 * Textures can be disabled by having load always return null. null should also be returned when 35 * a texture can not be loaded. If null is returned, the texture layer in question should be 36 * ignored, allowing for graceful fallback. It's recommended that implementations log when a 37 * texture can not be loaded. 38 * 39 * @return The texture bitmap, if any, associated with the given id. 40 */ getnull41 public operator fun get(clientTextureId: String): Bitmap? 42 } 43