Remove SkBitmapRegionDecoder and SkBRDAllocator
Bug: skia:10154 Once ag/11371053 lands, Android will only be referencing the new version at android::skia::BitmapRegionDecoder. Remove the old code that remained for the transition. Change-Id: Ic532d705e8f2861f56dcaa0ac1c68dd2b0712035 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291357 Commit-Queue: Leon Scroggins <scroggo@google.com> Auto-Submit: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
This commit is contained in:
parent
3eadce263c
commit
43182bccce
1
BUILD.gn
1
BUILD.gn
@ -929,7 +929,6 @@ component("skia") {
|
|||||||
sources += [
|
sources += [
|
||||||
"src/android/SkAndroidFrameworkUtils.cpp",
|
"src/android/SkAndroidFrameworkUtils.cpp",
|
||||||
"src/android/SkAnimatedImage.cpp",
|
"src/android/SkAnimatedImage.cpp",
|
||||||
"src/android/SkBitmapRegionDecoder.cpp",
|
|
||||||
"src/codec/SkAndroidCodec.cpp",
|
"src/codec/SkAndroidCodec.cpp",
|
||||||
"src/codec/SkAndroidCodecAdapter.cpp",
|
"src/codec/SkAndroidCodecAdapter.cpp",
|
||||||
"src/codec/SkBmpBaseCodec.cpp",
|
"src/codec/SkBmpBaseCodec.cpp",
|
||||||
|
@ -9,6 +9,8 @@ Milestone 85
|
|||||||
|
|
||||||
* <insert new release notes here>
|
* <insert new release notes here>
|
||||||
|
|
||||||
|
* Move SkBitmapRegionDecoder into client_utils/android.
|
||||||
|
|
||||||
* Remove SkSurface::MakeFromBackendTextureAsRenderTarget.
|
* Remove SkSurface::MakeFromBackendTextureAsRenderTarget.
|
||||||
This factory existed to work around issues with GL_TEXTURE_RECTANGLE that existed
|
This factory existed to work around issues with GL_TEXTURE_RECTANGLE that existed
|
||||||
in Chrome's command buffer. Those issues have since been resolved. Use
|
in Chrome's command buffer. Those issues have since been resolved. Use
|
||||||
|
@ -34,10 +34,17 @@ std::unique_ptr<BitmapRegionDecoder> BitmapRegionDecoder::Make(sk_sp<SkData> dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitmapRegionDecoder::BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec)
|
BitmapRegionDecoder::BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec)
|
||||||
: INHERITED(codec->getInfo().width(), codec->getInfo().height())
|
: fCodec(std::move(codec))
|
||||||
, fCodec(std::move(codec))
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
int BitmapRegionDecoder::width() const {
|
||||||
|
return fCodec->getInfo().width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int BitmapRegionDecoder::height() const {
|
||||||
|
return fCodec->getInfo().height();
|
||||||
|
}
|
||||||
|
|
||||||
bool BitmapRegionDecoder::decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
|
bool BitmapRegionDecoder::decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
|
||||||
const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
|
const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
|
||||||
bool requireUnpremul, sk_sp<SkColorSpace> dstColorSpace) {
|
bool requireUnpremul, sk_sp<SkColorSpace> dstColorSpace) {
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
#define BitmapRegionDecoder_DEFINED
|
#define BitmapRegionDecoder_DEFINED
|
||||||
|
|
||||||
#include "client_utils/android/BRDAllocator.h"
|
#include "client_utils/android/BRDAllocator.h"
|
||||||
// Temporary, until Android switches to the new class.
|
|
||||||
#include "include/android/SkBitmapRegionDecoder.h"
|
|
||||||
#include "include/codec/SkAndroidCodec.h"
|
#include "include/codec/SkAndroidCodec.h"
|
||||||
#include "include/core/SkBitmap.h"
|
#include "include/core/SkBitmap.h"
|
||||||
#include "include/core/SkData.h"
|
#include "include/core/SkData.h"
|
||||||
@ -18,33 +16,33 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
namespace skia {
|
namespace skia {
|
||||||
|
|
||||||
class BitmapRegionDecoder final : public SkBitmapRegionDecoder {
|
class BitmapRegionDecoder final {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<BitmapRegionDecoder> Make(sk_sp<SkData> data);
|
static std::unique_ptr<BitmapRegionDecoder> Make(sk_sp<SkData> data);
|
||||||
|
|
||||||
bool decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
|
bool decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
|
||||||
const SkIRect& desiredSubset, int sampleSize,
|
const SkIRect& desiredSubset, int sampleSize,
|
||||||
SkColorType colorType, bool requireUnpremul,
|
SkColorType colorType, bool requireUnpremul,
|
||||||
sk_sp<SkColorSpace> prefColorSpace) override;
|
sk_sp<SkColorSpace> prefColorSpace);
|
||||||
|
|
||||||
SkEncodedImageFormat getEncodedFormat() override { return fCodec->getEncodedFormat(); }
|
SkEncodedImageFormat getEncodedFormat() { return fCodec->getEncodedFormat(); }
|
||||||
|
|
||||||
SkColorType computeOutputColorType(SkColorType requestedColorType) override {
|
SkColorType computeOutputColorType(SkColorType requestedColorType) {
|
||||||
return fCodec->computeOutputColorType(requestedColorType);
|
return fCodec->computeOutputColorType(requestedColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
||||||
sk_sp<SkColorSpace> prefColorSpace = nullptr) override {
|
sk_sp<SkColorSpace> prefColorSpace = nullptr) {
|
||||||
return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
|
return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int width() const;
|
||||||
|
int height() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec);
|
BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec);
|
||||||
|
|
||||||
std::unique_ptr<SkAndroidCodec> fCodec;
|
std::unique_ptr<SkAndroidCodec> fCodec;
|
||||||
|
|
||||||
typedef SkBitmapRegionDecoder INHERITED;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace skia
|
} // namespace skia
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SkBRDAllocator_DEFINED
|
|
||||||
#define SkBRDAllocator_DEFINED
|
|
||||||
|
|
||||||
#include "client_utils/android/BRDAllocator.h"
|
|
||||||
|
|
||||||
// Temporary until Android switches over to BRDAllocator directly.
|
|
||||||
class SkBRDAllocator : public android::skia::BRDAllocator {};
|
|
||||||
|
|
||||||
#endif // SkBRDAllocator_DEFINED
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SkBitmapRegionDecoder_DEFINED
|
|
||||||
#define SkBitmapRegionDecoder_DEFINED
|
|
||||||
|
|
||||||
#include "include/android/SkBRDAllocator.h"
|
|
||||||
#include "include/core/SkBitmap.h"
|
|
||||||
#include "include/core/SkEncodedImageFormat.h"
|
|
||||||
#include "include/core/SkStream.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This class aims to provide an interface to test multiple implementations of
|
|
||||||
* SkBitmapRegionDecoder.
|
|
||||||
*/
|
|
||||||
class SK_API SkBitmapRegionDecoder {
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum Strategy {
|
|
||||||
kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsetting
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param stream Takes ownership of the stream
|
|
||||||
* @param strategy Strategy used for scaling and subsetting
|
|
||||||
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
|
|
||||||
*/
|
|
||||||
static SkBitmapRegionDecoder* Create(
|
|
||||||
SkStreamRewindable* stream, Strategy strategy);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode a scaled region of the encoded image stream
|
|
||||||
*
|
|
||||||
* @param bitmap Container for decoded pixels. It is assumed that the pixels
|
|
||||||
* are initially unallocated and will be allocated by this function.
|
|
||||||
* @param allocator Allocator for the pixels. If this is NULL, the default
|
|
||||||
* allocator (HeapAllocator) will be used.
|
|
||||||
* @param desiredSubset Subset of the original image to decode.
|
|
||||||
* @param sampleSize An integer downscaling factor for the decode.
|
|
||||||
* @param colorType Preferred output colorType.
|
|
||||||
* New implementations should return NULL if they do not support
|
|
||||||
* decoding to this color type.
|
|
||||||
* The old kOriginal_Strategy will decode to a default color type
|
|
||||||
* if this color type is unsupported.
|
|
||||||
* @param requireUnpremul If the image is not opaque, we will use this to determine the
|
|
||||||
* alpha type to use.
|
|
||||||
* @param prefColorSpace If non-null and supported, this is the color space that we will
|
|
||||||
* decode into. Otherwise, we will choose a default.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual bool decodeRegion(SkBitmap* bitmap, android::skia::BRDAllocator* allocator,
|
|
||||||
const SkIRect& desiredSubset, int sampleSize,
|
|
||||||
SkColorType colorType, bool requireUnpremul,
|
|
||||||
sk_sp<SkColorSpace> prefColorSpace = nullptr) = 0;
|
|
||||||
|
|
||||||
virtual SkEncodedImageFormat getEncodedFormat() = 0;
|
|
||||||
|
|
||||||
virtual SkColorType computeOutputColorType(SkColorType requestedColorType) = 0;
|
|
||||||
|
|
||||||
virtual sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
|
||||||
sk_sp<SkColorSpace> prefColorSpace = nullptr) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
int width() const { return fWidth; }
|
|
||||||
int height() const { return fHeight; }
|
|
||||||
|
|
||||||
virtual ~SkBitmapRegionDecoder() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
SkBitmapRegionDecoder(int width, int height)
|
|
||||||
: fWidth(width)
|
|
||||||
, fHeight(height)
|
|
||||||
{}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const int fWidth;
|
|
||||||
const int fHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "include/core/SkTypes.h"
|
|
||||||
#ifdef SK_ENABLE_ANDROID_UTILS
|
|
||||||
#include "client_utils/android/BitmapRegionDecoder.h"
|
|
||||||
#include "include/android/SkBitmapRegionDecoder.h"
|
|
||||||
#include "include/codec/SkAndroidCodec.h"
|
|
||||||
#include "include/codec/SkCodec.h"
|
|
||||||
#include "include/core/SkData.h"
|
|
||||||
#include "include/core/SkStream.h"
|
|
||||||
#include "src/codec/SkCodecPriv.h"
|
|
||||||
|
|
||||||
// Note: This file is only temporary while we switch Android over to BitmapRegionDecoder
|
|
||||||
// directly.
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
struct Context {
|
|
||||||
std::unique_ptr<SkStreamRewindable> stream;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void release_proc(const void* ptr, void* context) {
|
|
||||||
delete reinterpret_cast<Context*>(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
|
|
||||||
SkStreamRewindable* stream, Strategy strategy) {
|
|
||||||
std::unique_ptr<SkStreamRewindable> streamDeleter(stream);
|
|
||||||
const void* memoryBase = streamDeleter->getMemoryBase();
|
|
||||||
if (!memoryBase) {
|
|
||||||
// All existing clients use an SkMemoryStream.
|
|
||||||
SkASSERT(false);
|
|
||||||
SkCodecPrintf("Error: Need an SkMemoryStream to create an SkBitmapRegionDecoder!");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
Context* context = new Context;
|
|
||||||
context->stream = std::move(streamDeleter);
|
|
||||||
auto data = SkData::MakeWithProc(memoryBase, context->stream->getLength(), release_proc,
|
|
||||||
context);
|
|
||||||
return android::skia::BitmapRegionDecoder::Make(std::move(data)).release();
|
|
||||||
}
|
|
||||||
#endif // SK_ENABLE_ANDROID_UTILS
|
|
Loading…
Reference in New Issue
Block a user