Add SkEncodedFormat, used by SkCodec.

Needed by Android to determine the format.

Review URL: https://codereview.chromium.org/1018953003
This commit is contained in:
scroggo 2015-03-20 11:55:55 -07:00 committed by Commit bot
parent 01a78130dc
commit 1dd3ea9d45
6 changed files with 41 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#ifndef SkCodec_DEFINED
#define SkCodec_DEFINED
#include "SkEncodedFormat.h"
#include "SkImageGenerator.h"
#include "SkImageInfo.h"
#include "SkSize.h"
@ -50,6 +51,11 @@ public:
return this->onGetScaledDimensions(desiredScale);
}
/**
* Format of the encoded data.
*/
SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
protected:
SkCodec(const SkImageInfo&, SkStream*);
@ -73,6 +79,8 @@ protected:
return fInfo.dimensions();
}
virtual SkEncodedFormat onGetEncodedFormat() const = 0;
/**
* If the stream was previously read, attempt to rewind.
* @returns:

View File

@ -0,0 +1,27 @@
/*
* 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 SkEncodedFormat_DEFINED
#define SkEncodedFormat_DEFINED
/**
* Enum describing format of encoded data.
*/
enum SkEncodedFormat {
kUnknown_SkEncodedFormat,
kBMP_SkEncodedFormat,
kGIF_SkEncodedFormat,
kICO_SkEncodedFormat,
kJPEG_SkEncodedFormat,
kPNG_SkEncodedFormat,
kWBMP_SkEncodedFormat,
kWEBP_SkEncodedFormat,
kPKM_SkEncodedFormat,
kKTX_SkEncodedFormat,
kASTC_SkEncodedFormat,
};
#endif // SkEncodedFormat_DEFINED

View File

@ -26,6 +26,7 @@ class SkImageDecoder : SkNoncopyable {
public:
virtual ~SkImageDecoder();
// TODO (scroggo): Merge with SkEncodedFormat
enum Format {
kUnknown_Format,
kBMP_Format,

View File

@ -17,6 +17,7 @@ class SkWStream;
class SkImageEncoder {
public:
// TODO (scroggo): Merge with SkEncodedFormat.
enum Type {
kUnknown_Type,
kBMP_Type,

View File

@ -7,6 +7,7 @@
#include "SkCodec.h"
#include "SkColorTable.h"
#include "SkEncodedFormat.h"
#include "SkImageInfo.h"
#include "SkMaskSwizzler.h"
#include "SkStream.h"
@ -60,6 +61,7 @@ protected:
size_t dstRowBytes, const Options&, SkPMColor*,
int*) SK_OVERRIDE;
SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kBMP_SkEncodedFormat; }
private:
/*

View File

@ -6,6 +6,7 @@
*/
#include "SkCodec.h"
#include "SkEncodedFormat.h"
#include "SkImageInfo.h"
extern "C" {
@ -24,6 +25,7 @@ public:
protected:
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*)
SK_OVERRIDE;
SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kPNG_SkEncodedFormat; }
private:
png_structp fPng_ptr;
png_infop fInfo_ptr;