2015-10-22 14:29:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifndef BitmapRegionDecoder_DEFINED
|
|
|
|
#define BitmapRegionDecoder_DEFINED
|
2017-02-10 14:06:38 +00:00
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#include "client_utils/android/BRDAllocator.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/codec/SkAndroidCodec.h"
|
|
|
|
#include "include/core/SkBitmap.h"
|
2020-05-04 14:02:45 +00:00
|
|
|
#include "include/core/SkData.h"
|
2015-10-22 14:29:19 +00:00
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
namespace android {
|
|
|
|
namespace skia {
|
2015-10-22 14:29:19 +00:00
|
|
|
|
2020-05-21 15:14:31 +00:00
|
|
|
class BitmapRegionDecoder final {
|
2020-05-04 14:02:45 +00:00
|
|
|
public:
|
|
|
|
static std::unique_ptr<BitmapRegionDecoder> Make(sk_sp<SkData> data);
|
2015-10-22 14:29:19 +00:00
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
bool decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
|
2015-10-27 19:50:25 +00:00
|
|
|
const SkIRect& desiredSubset, int sampleSize,
|
2017-04-11 13:51:32 +00:00
|
|
|
SkColorType colorType, bool requireUnpremul,
|
2020-05-21 15:14:31 +00:00
|
|
|
sk_sp<SkColorSpace> prefColorSpace);
|
2015-10-22 14:29:19 +00:00
|
|
|
|
2020-05-21 15:14:31 +00:00
|
|
|
SkEncodedImageFormat getEncodedFormat() { return fCodec->getEncodedFormat(); }
|
2015-10-27 20:12:59 +00:00
|
|
|
|
2020-05-21 15:14:31 +00:00
|
|
|
SkColorType computeOutputColorType(SkColorType requestedColorType) {
|
2017-04-14 13:23:45 +00:00
|
|
|
return fCodec->computeOutputColorType(requestedColorType);
|
|
|
|
}
|
|
|
|
|
|
|
|
sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
2020-05-21 15:14:31 +00:00
|
|
|
sk_sp<SkColorSpace> prefColorSpace = nullptr) {
|
2017-04-14 13:23:45 +00:00
|
|
|
return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
|
|
|
|
}
|
|
|
|
|
2020-05-21 15:14:31 +00:00
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
|
2015-10-22 14:29:19 +00:00
|
|
|
private:
|
2020-05-04 14:02:45 +00:00
|
|
|
BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec);
|
2015-10-22 14:29:19 +00:00
|
|
|
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<SkAndroidCodec> fCodec;
|
2015-10-22 14:29:19 +00:00
|
|
|
};
|
2020-05-04 14:02:45 +00:00
|
|
|
|
|
|
|
} // namespace skia
|
|
|
|
} // namespace android
|
|
|
|
#endif // BitmapRegionDecoder_DEFINED
|