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#ifndef SkImageGeneratorNDK_DEFINED 9cb93a386Sopenharmony_ci#define SkImageGeneratorNDK_DEFINED 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#include "include/core/SkTypes.h" 12cb93a386Sopenharmony_ci#ifdef SK_ENABLE_NDK_IMAGES 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ci#include "include/core/SkData.h" 15cb93a386Sopenharmony_ci#include "include/core/SkImageGenerator.h" 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ci#include <memory> 18cb93a386Sopenharmony_ci 19cb93a386Sopenharmony_cinamespace SkImageGeneratorNDK { 20cb93a386Sopenharmony_ci/** 21cb93a386Sopenharmony_ci * Create a generator that uses the Android NDK's APIs for decoding images. 22cb93a386Sopenharmony_ci * 23cb93a386Sopenharmony_ci * Only supported on devices where __ANDROID_API__ >= 30. 24cb93a386Sopenharmony_ci * 25cb93a386Sopenharmony_ci * As with SkCodec, the SkColorSpace passed to getPixels() determines the 26cb93a386Sopenharmony_ci * type of color space transformations to apply. A null SkColorSpace means to 27cb93a386Sopenharmony_ci * apply none. 28cb93a386Sopenharmony_ci * 29cb93a386Sopenharmony_ci * A note on scaling: Calling getPixels() on the resulting SkImageGenerator 30cb93a386Sopenharmony_ci * with dimensions that do not match getInfo() requests a scale. For WebP 31cb93a386Sopenharmony_ci * files, dimensions smaller than those of getInfo are supported. For Jpeg 32cb93a386Sopenharmony_ci * files, dimensions of 1/2, 1/4, and 1/8 are supported. TODO: Provide an 33cb93a386Sopenharmony_ci * API like SkCodecImageGenerator::getScaledDimensions() to report which 34cb93a386Sopenharmony_ci * dimensions are supported? 35cb93a386Sopenharmony_ci */ 36cb93a386Sopenharmony_ciSK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedNDK(sk_sp<SkData>); 37cb93a386Sopenharmony_ci} 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_ci#endif // SK_ENABLE_NDK_IMAGES 40cb93a386Sopenharmony_ci#endif // SkImageGeneratorNDK_DEFINED 41