Rename SkBitmapRegionDecoder and Create function

We no longer need to worry about namespace
conflicts SkBitmapRegionDecoder in Android (which
we are replacing).

Additionally, the static Create() function does not
need to repeat the name BitmapRegionDecoder.

BUG=skia:

Review URL: https://codereview.chromium.org/1415243007
This commit is contained in:
msarett 2015-11-06 08:56:32 -08:00 committed by Commit bot
parent aa4ba90792
commit 5cb4885b4c
14 changed files with 66 additions and 66 deletions

View File

@ -293,8 +293,8 @@ DM_SRCS = glob(
"tools/SkBitmapRegionCanvas.h",
"tools/SkBitmapRegionCodec.cpp",
"tools/SkBitmapRegionCodec.h",
"tools/SkBitmapRegionDecoderInterface.cpp",
"tools/SkBitmapRegionDecoderInterface.h",
"tools/SkBitmapRegionDecoder.cpp",
"tools/SkBitmapRegionDecoder.h",
"tools/SkBitmapRegionSampler.cpp",
"tools/SkBitmapRegionSampler.h",
"tools/flags/*.cpp",

View File

@ -12,7 +12,7 @@
#include "SkOSFile.h"
BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded,
SkBitmapRegionDecoderInterface::Strategy strategy, SkColorType colorType,
SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType,
uint32_t sampleSize, const SkIRect& subset)
: fBRD(nullptr)
, fData(SkRef(encoded))
@ -24,13 +24,13 @@ BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData*
// Choose a useful name for the region decoding strategy
const char* strategyName;
switch (strategy) {
case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
case SkBitmapRegionDecoder::kOriginal_Strategy:
strategyName = "Original";
break;
case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
case SkBitmapRegionDecoder::kCanvas_Strategy:
strategyName = "Canvas";
break;
case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy:
case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
strategyName = "AndroidCodec";
break;
default:
@ -57,7 +57,7 @@ bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
}
void BitmapRegionDecoderBench::onDelayedSetup() {
fBRD.reset(SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(fData, fStrategy));
fBRD.reset(SkBitmapRegionDecoder::Create(fData, fStrategy));
}
void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {

View File

@ -9,7 +9,7 @@
#define BitmapRegionDecoderBench_DEFINED
#include "Benchmark.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "SkRefCnt.h"
@ -27,7 +27,7 @@ class BitmapRegionDecoderBench : public Benchmark {
public:
// Calls encoded->ref()
BitmapRegionDecoderBench(const char* basename, SkData* encoded,
SkBitmapRegionDecoderInterface::Strategy strategy, SkColorType colorType,
SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType,
uint32_t sampleSize, const SkIRect& subset);
protected:
@ -38,9 +38,9 @@ protected:
private:
SkString fName;
SkAutoTDelete<SkBitmapRegionDecoderInterface> fBRD;
SkAutoTDelete<SkBitmapRegionDecoder> fBRD;
SkAutoTUnref<SkData> fData;
const SkBitmapRegionDecoderInterface::Strategy fStrategy;
const SkBitmapRegionDecoder::Strategy fStrategy;
const SkColorType fColorType;
const uint32_t fSampleSize;
const SkIRect fSubset;

View File

@ -26,7 +26,7 @@
#include "SubsetZoomBench.h"
#include "Stats.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkBBoxHierarchy.h"
#include "SkCanvas.h"
#include "SkCodec.h"
@ -588,11 +588,11 @@ static bool valid_subset_bench(const SkString& path, SkColorType colorType, bool
return true;
}
static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Strategy strategy,
static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy strategy,
SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int* width,
int* height) {
SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(
SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, strategy));
SkAutoTDelete<SkBitmapRegionDecoder> brd(
SkBitmapRegionDecoder::Create(encoded, strategy));
if (nullptr == brd.get()) {
// This is indicates that subset decoding is not supported for a particular image format.
return false;
@ -956,12 +956,12 @@ public:
// Run the BRDBenches
// We will benchmark multiple BRD strategies.
static const struct {
SkBitmapRegionDecoderInterface::Strategy fStrategy;
SkBitmapRegionDecoder::Strategy fStrategy;
const char* fName;
} strategies[] = {
{ SkBitmapRegionDecoderInterface::kOriginal_Strategy, "BRD" },
{ SkBitmapRegionDecoderInterface::kCanvas_Strategy, "BRD_canvas" },
{ SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy, "BRD_android_codec" },
{ SkBitmapRegionDecoder::kOriginal_Strategy, "BRD" },
{ SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" },
{ SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec" },
};
// We intend to create benchmarks that model the use cases in
@ -986,10 +986,10 @@ public:
fBenchType = strategies[fCurrentBRDStrategy].fName;
const SkString& path = fImages[fCurrentBRDImage];
const SkBitmapRegionDecoderInterface::Strategy strategy =
const SkBitmapRegionDecoder::Strategy strategy =
strategies[fCurrentBRDStrategy].fStrategy;
if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy) {
if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy) {
// Disable png and jpeg for SkImageDecoder:
if (!FLAGS_jpgBuildTileIndex) {
if (path.endsWith("JPEG") || path.endsWith("JPG") ||

View File

@ -381,15 +381,15 @@ static void push_codec_srcs(Path path) {
}
}
static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy strategy,
static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy,
CodecSrc::DstColorType dstColorType) {
switch (strategy) {
case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
case SkBitmapRegionDecoder::kCanvas_Strategy:
if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) {
return true;
}
return false;
case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
case SkBitmapRegionDecoder::kOriginal_Strategy:
switch (dstColorType) {
case CodecSrc::kGetFromCanvas_DstColorType:
case CodecSrc::kIndex8_Always_DstColorType:
@ -398,7 +398,7 @@ static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy st
default:
return false;
}
case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy:
case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
switch (dstColorType) {
case CodecSrc::kGetFromCanvas_DstColorType:
case CodecSrc::kIndex8_Always_DstColorType:
@ -413,17 +413,17 @@ static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy st
}
}
static void push_brd_src(Path path, SkBitmapRegionDecoderInterface::Strategy strategy,
static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy,
CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleSize) {
SkString folder;
switch (strategy) {
case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
case SkBitmapRegionDecoder::kCanvas_Strategy:
folder.append("brd_canvas");
break;
case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
case SkBitmapRegionDecoder::kOriginal_Strategy:
folder.append("brd_sample");
break;
case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy:
case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
folder.append("brd_android_codec");
break;
default:
@ -466,10 +466,10 @@ static void push_brd_src(Path path, SkBitmapRegionDecoderInterface::Strategy str
static void push_brd_srcs(Path path) {
const SkBitmapRegionDecoderInterface::Strategy strategies[] = {
SkBitmapRegionDecoderInterface::kCanvas_Strategy,
SkBitmapRegionDecoderInterface::kOriginal_Strategy,
SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy,
const SkBitmapRegionDecoder::Strategy strategies[] = {
SkBitmapRegionDecoder::kCanvas_Strategy,
SkBitmapRegionDecoder::kOriginal_Strategy,
SkBitmapRegionDecoder::kAndroidCodec_Strategy,
};
// Test on a variety of sampleSizes, making sure to include:
@ -492,12 +492,12 @@ static void push_brd_srcs(Path path) {
BRDSrc::kDivisor_Mode,
};
for (SkBitmapRegionDecoderInterface::Strategy strategy : strategies) {
for (SkBitmapRegionDecoder::Strategy strategy : strategies) {
// We disable png testing for kOriginal_Strategy because the implementation leaks
// memory in our forked libpng.
// TODO (msarett): Decide if we want to test pngs in this mode and how we might do this.
if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy &&
if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy &&
(path.endsWith(".png") || path.endsWith(".PNG"))) {
continue;
}
@ -506,7 +506,7 @@ static void push_brd_srcs(Path path) {
// kOriginal_Strategy does not work for jpegs that are scaled to non-powers of two.
// We don't need to test this. We know it doesn't work, and it causes images with
// uninitialized memory to show up on Gold.
if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy &&
if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy &&
(path.endsWith(".jpg") || path.endsWith(".JPG") ||
path.endsWith(".jpeg") || path.endsWith(".JPEG")) && !SkIsPow2(sampleSize)) {
continue;

View File

@ -67,7 +67,7 @@ void GMSrc::modifyGrContextOptions(GrContextOptions* options) const {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoderInterface::Strategy strategy, Mode mode,
BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoder::Strategy strategy, Mode mode,
CodecSrc::DstColorType dstColorType, uint32_t sampleSize)
: fPath(path)
, fStrategy(strategy)
@ -82,13 +82,13 @@ bool BRDSrc::veto(SinkFlags flags) const {
|| flags.approach != SinkFlags::kDirect;
}
static SkBitmapRegionDecoderInterface* create_brd(Path path,
SkBitmapRegionDecoderInterface::Strategy strategy) {
static SkBitmapRegionDecoder* create_brd(Path path,
SkBitmapRegionDecoder::Strategy strategy) {
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
if (!encoded) {
return NULL;
}
return SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, strategy);
return SkBitmapRegionDecoder::Create(encoded, strategy);
}
Error BRDSrc::draw(SkCanvas* canvas) const {
@ -108,7 +108,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
break;
}
SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrategy));
SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy));
if (nullptr == brd.get()) {
return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fPath.c_str()));
}
@ -210,7 +210,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
}
SkISize BRDSrc::size() const {
SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrategy));
SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy));
if (brd) {
return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize),
SkTMax(1, brd->height() / (int) fSampleSize));

View File

@ -12,7 +12,7 @@
#include "SkBBHFactory.h"
#include "SkBBoxHierarchy.h"
#include "SkBitmap.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkCanvas.h"
#include "SkData.h"
#include "SkGPipe.h"
@ -163,7 +163,7 @@ public:
kDivisor_Mode,
};
BRDSrc(Path, SkBitmapRegionDecoderInterface::Strategy, Mode, CodecSrc::DstColorType, uint32_t);
BRDSrc(Path, SkBitmapRegionDecoder::Strategy, Mode, CodecSrc::DstColorType, uint32_t);
Error draw(SkCanvas*) const override;
SkISize size() const override;
@ -171,7 +171,7 @@ public:
bool veto(SinkFlags) const override;
private:
Path fPath;
SkBitmapRegionDecoderInterface::Strategy fStrategy;
SkBitmapRegionDecoder::Strategy fStrategy;
Mode fMode;
CodecSrc::DstColorType fDstColorType;
uint32_t fSampleSize;

View File

@ -53,7 +53,7 @@
'sources': [
'../tools/SkBitmapRegionCanvas.cpp',
'../tools/SkBitmapRegionCodec.cpp',
'../tools/SkBitmapRegionDecoderInterface.cpp',
'../tools/SkBitmapRegionDecoder.cpp',
'../tools/SkBitmapRegionSampler.cpp',
],
'include_dirs': [

View File

@ -573,8 +573,8 @@ DM_SRCS = ['dm/DM.cpp',
'tools/SkBitmapRegionCanvas.h',
'tools/SkBitmapRegionCodec.cpp',
'tools/SkBitmapRegionCodec.h',
'tools/SkBitmapRegionDecoderInterface.cpp',
'tools/SkBitmapRegionDecoderInterface.h',
'tools/SkBitmapRegionDecoder.cpp',
'tools/SkBitmapRegionDecoder.h',
'tools/SkBitmapRegionSampler.cpp',
'tools/SkBitmapRegionSampler.h',
'tools/flags/SkCommandLineFlags.cpp',

View File

@ -6,7 +6,7 @@
*/
#include "SkBitmap.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkCodec.h"
/*
@ -16,7 +16,7 @@
*/
// FIXME (msarett): This implementation does not support WEBP, because WEBP
// does not have a scanline decoder.
class SkBitmapRegionCanvas : public SkBitmapRegionDecoderInterface {
class SkBitmapRegionCanvas : public SkBitmapRegionDecoder {
public:
/*
@ -36,6 +36,6 @@ private:
SkAutoTDelete<SkCodec> fDecoder;
typedef SkBitmapRegionDecoderInterface INHERITED;
typedef SkBitmapRegionDecoder INHERITED;
};

View File

@ -6,13 +6,13 @@
*/
#include "SkBitmap.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkAndroidCodec.h"
/*
* This class implements SkBitmapRegionDecoder using an SkAndroidCodec.
*/
class SkBitmapRegionCodec : public SkBitmapRegionDecoderInterface {
class SkBitmapRegionCodec : public SkBitmapRegionDecoder {
public:
/*
@ -32,6 +32,6 @@ private:
SkAutoTDelete<SkAndroidCodec> fCodec;
typedef SkBitmapRegionDecoderInterface INHERITED;
typedef SkBitmapRegionDecoder INHERITED;
};

View File

@ -7,20 +7,20 @@
#include "SkBitmapRegionCanvas.h"
#include "SkBitmapRegionCodec.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkBitmapRegionSampler.h"
#include "SkAndroidCodec.h"
#include "SkCodec.h"
#include "SkCodecPriv.h"
#include "SkImageDecoder.h"
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
SkData* data, Strategy strategy) {
return SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(new SkMemoryStream(data),
return SkBitmapRegionDecoder::Create(new SkMemoryStream(data),
strategy);
}
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
SkStreamRewindable* stream, Strategy strategy) {
SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {

View File

@ -16,7 +16,7 @@
* This class aims to provide an interface to test multiple implementations of
* SkBitmapRegionDecoder.
*/
class SkBitmapRegionDecoderInterface {
class SkBitmapRegionDecoder {
public:
enum Strategy {
@ -30,7 +30,7 @@ public:
* @param strategy Strategy used for scaling and subsetting
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
*/
static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder(
static SkBitmapRegionDecoder* Create(
SkData* data, Strategy strategy);
/*
@ -38,7 +38,7 @@ public:
* @param strategy Strategy used for scaling and subsetting
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
*/
static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder(
static SkBitmapRegionDecoder* Create(
SkStreamRewindable* stream, Strategy strategy);
/*
@ -73,11 +73,11 @@ public:
int width() const { return fWidth; }
int height() const { return fHeight; }
virtual ~SkBitmapRegionDecoderInterface() {}
virtual ~SkBitmapRegionDecoder() {}
protected:
SkBitmapRegionDecoderInterface(int width, int height)
SkBitmapRegionDecoder(int width, int height)
: fWidth(width)
, fHeight(height)
{}

View File

@ -6,7 +6,7 @@
*/
#include "SkBitmap.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionDecoder.h"
#include "SkImageDecoder.h"
#include "SkTemplates.h"
@ -14,7 +14,7 @@
* This class aims to duplicate the current implementation of
* SkBitmapRegionDecoder in Android.
*/
class SkBitmapRegionSampler : public SkBitmapRegionDecoderInterface {
class SkBitmapRegionSampler : public SkBitmapRegionDecoder {
public:
/*
@ -40,6 +40,6 @@ private:
SkAutoTDelete<SkImageDecoder> fDecoder;
typedef SkBitmapRegionDecoderInterface INHERITED;
typedef SkBitmapRegionDecoder INHERITED;
};