Merge from Chromium at DEPS revision 240154
This commit was generated by merge_to_master.py.
Change-Id: If2d65431777653a39236e157ab91ef72cd5517c4
diff --git a/core/SkBitmap.h b/core/SkBitmap.h
index b58925c..c0e299a 100644
--- a/core/SkBitmap.h
+++ b/core/SkBitmap.h
@@ -42,12 +42,6 @@
enum Config {
kNo_Config, //!< bitmap has not been configured
- /**
- * 1-bit per pixel, (0 is transparent, 1 is opaque)
- * Valid as a destination (target of a canvas), but not valid as a src.
- * i.e. you can draw into a 1-bit bitmap, but you cannot draw from one.
- */
- kA1_Config,
kA8_Config, //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
kIndex8_Config, //!< 8-bits per pixel, using SkColorTable to specify the colors
kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
@@ -256,6 +250,13 @@
bool setConfig(const SkImageInfo& info, size_t rowBytes = 0);
+ /**
+ * If the bitmap's config can be represented as SkImageInfo, return true,
+ * and if info is not-null, set it to the bitmap's info. If it cannot be
+ * represented as SkImageInfo, return false and ignore the info parameter.
+ */
+ bool asImageInfo(SkImageInfo* info) const;
+
/** Use this to assign a new pixel address for an existing bitmap. This
will automatically release any pixelref previously installed. Only call
this if you are handling ownership/lifetime of the pixel memory.
@@ -489,14 +490,6 @@
*/
inline uint8_t* getAddr8(int x, int y) const;
- /** Returns the address of the byte containing the pixel specified by x,y
- * for 1bit pixels.
- * In debug build, this asserts that the pixels are allocated and locked,
- * and that the config is 1-bit, however none of these checks are performed
- * in the release build.
- */
- inline uint8_t* getAddr1(int x, int y) const;
-
/** Returns the color corresponding to the pixel specified by x,y for
* colortable based bitmaps.
* In debug build, this asserts that the pixels are allocated and locked,
@@ -818,12 +811,4 @@
return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
}
-// returns the address of the byte that contains the x coordinate
-inline uint8_t* SkBitmap::getAddr1(int x, int y) const {
- SkASSERT(fPixels);
- SkASSERT(fConfig == kA1_Config);
- SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
- return (uint8_t*)fPixels + y * fRowBytes + (x >> 3);
-}
-
#endif
diff --git a/core/SkCanvas.h b/core/SkCanvas.h
index 7bcc09a..6c41680 100644
--- a/core/SkCanvas.h
+++ b/core/SkCanvas.h
@@ -672,6 +672,11 @@
bitmap's original width/height, then the bitmap will be drawn as if it
were in a Shader with CLAMP mode. Thus the color outside of the original
width/height will be the edge color replicated.
+
+ If a shader is present on the paint it will be ignored, except in the
+ case where the bitmap is kA8_Config. In that case, the color is
+ generated by the shader.
+
@param bitmap The bitmap to be drawn
@param left The position of the left side of the bitmap being drawn
@param top The position of the top side of the bitmap being drawn
diff --git a/core/SkColorPriv.h b/core/SkColorPriv.h
index fe4377f..7a74c4a 100644
--- a/core/SkColorPriv.h
+++ b/core/SkColorPriv.h
@@ -269,34 +269,83 @@
}
/**
- * 32b optimized version; currently appears to be 10% faster even on 64b
- * architectures than an equivalent 64b version and 30% faster than
- * SkFourByteInterp(). Third parameter controls blending of the first two:
- * (src, dst, 0) returns dst
- * (src, dst, 256) returns src
- * ** Does not match the results of SkFourByteInterp256() because we use
- * a more accurate scale computation!
- * TODO: migrate Skia function to using an accurate 255->266 alpha
- * conversion.
+ * 0xAARRGGBB -> 0x00AA00GG, 0x00RR00BB
*/
-static inline SkPMColor SkFastFourByteInterp256(SkPMColor src,
- SkPMColor dst,
- unsigned scale) {
- SkASSERT(scale <= 256);
-
- // Reorders ARGB to AG-RB in order to reduce the number of operations.
- const uint32_t mask = 0xFF00FF;
- uint32_t src_rb = src & mask;
- uint32_t src_ag = (src >> 8) & mask;
- uint32_t dst_rb = dst & mask;
- uint32_t dst_ag = (dst >> 8) & mask;
-
- uint32_t ret_rb = src_rb * scale + (256 - scale) * dst_rb;
- uint32_t ret_ag = src_ag * scale + (256 - scale) * dst_ag;
-
- return (ret_ag & ~mask) | ((ret_rb & ~mask) >> 8);
+static inline void SkSplay(uint32_t color, uint32_t* ag, uint32_t* rb) {
+ const uint32_t mask = 0x00FF00FF;
+ *ag = (color >> 8) & mask;
+ *rb = color & mask;
}
+/**
+ * 0xAARRGGBB -> 0x00AA00GG00RR00BB
+ * (note, ARGB -> AGRB)
+ */
+static inline uint64_t SkSplay(uint32_t color) {
+ const uint32_t mask = 0x00FF00FF;
+ uint64_t agrb = (color >> 8) & mask; // 0x0000000000AA00GG
+ agrb <<= 32; // 0x00AA00GG00000000
+ agrb |= color & mask; // 0x00AA00GG00RR00BB
+ return agrb;
+}
+
+/**
+ * 0xAAxxGGxx, 0xRRxxBBxx-> 0xAARRGGBB
+ */
+static inline uint32_t SkUnsplay(uint32_t ag, uint32_t rb) {
+ const uint32_t mask = 0xFF00FF00;
+ return (ag & mask) | ((rb & mask) >> 8);
+}
+
+/**
+ * 0xAAxxGGxxRRxxBBxx -> 0xAARRGGBB
+ * (note, AGRB -> ARGB)
+ */
+static inline uint32_t SkUnsplay(uint64_t agrb) {
+ const uint32_t mask = 0xFF00FF00;
+ return SkPMColor(
+ ((agrb & mask) >> 8) | // 0x00RR00BB
+ ((agrb >> 32) & mask)); // 0xAARRGGBB
+}
+
+static inline SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale) {
+ SkASSERT(scale <= 256);
+
+ // Two 8-bit blends per two 32-bit registers, with space to make sure the math doesn't collide.
+ uint32_t src_ag, src_rb, dst_ag, dst_rb;
+ SkSplay(src, &src_ag, &src_rb);
+ SkSplay(dst, &dst_ag, &dst_rb);
+
+ const uint32_t ret_ag = src_ag * scale + (256 - scale) * dst_ag;
+ const uint32_t ret_rb = src_rb * scale + (256 - scale) * dst_rb;
+
+ return SkUnsplay(ret_ag, ret_rb);
+}
+
+static inline SkPMColor SkFastFourByteInterp256_64(SkPMColor src, SkPMColor dst, unsigned scale) {
+ SkASSERT(scale <= 256);
+ // Four 8-bit blends in one 64-bit register, with space to make sure the math doesn't collide.
+ return SkUnsplay(SkSplay(src) * scale + (256-scale) * SkSplay(dst));
+}
+
+// TODO(mtklein): Replace slow versions with fast versions, using scale + (scale>>7) everywhere.
+
+/**
+ * Same as SkFourByteInterp256, but faster.
+ */
+static inline SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale) {
+ // On a 64-bit machine, _64 is about 10% faster than _32, but ~40% slower on a 32-bit machine.
+ if (sizeof(void*) == 4) {
+ return SkFastFourByteInterp256_32(src, dst, scale);
+ } else {
+ return SkFastFourByteInterp256_64(src, dst, scale);
+ }
+}
+
+/**
+ * Nearly the same as SkFourByteInterp, but faster and a touch more accurate, due to better
+ * srcWeight scaling to [0, 256].
+ */
static inline SkPMColor SkFastFourByteInterp(SkPMColor src,
SkPMColor dst,
U8CPU srcWeight) {
diff --git a/core/SkFlattenableBuffers.h b/core/SkFlattenableBuffers.h
index 575dec8..00cb77a 100644
--- a/core/SkFlattenableBuffers.h
+++ b/core/SkFlattenableBuffers.h
@@ -154,6 +154,12 @@
*/
virtual bool validate(bool isValid);
+ /** This function returns true by default
+ * If isValidating() is true, it will return false if the internal error flag is set.
+ * Otherwise, it will return true.
+ */
+ virtual bool isValid() const { return true; }
+
private:
template <typename T> T* readFlattenableT();
uint32_t fFlags;
diff --git a/core/SkImage.h b/core/SkImage.h
index accfc0d..0bff589 100644
--- a/core/SkImage.h
+++ b/core/SkImage.h
@@ -41,6 +41,7 @@
typedef SkColorType ColorType;
static const SkColorType kAlpha_8_ColorType = kAlpha_8_SkColorType;
+ static const SkColorType kARGB_4444_ColorType = kARGB_4444_SkColorType;
static const SkColorType kRGB_565_ColorType = kRGB_565_SkColorType;
static const SkColorType kRGBA_8888_ColorType = kRGBA_8888_SkColorType;
static const SkColorType kBGRA_8888_ColorType = kBGRA_8888_SkColorType;
diff --git a/core/SkImageDecoder.h b/core/SkImageDecoder.h
index a7e3646..7241458 100644
--- a/core/SkImageDecoder.h
+++ b/core/SkImageDecoder.h
@@ -11,7 +11,6 @@
#define SkImageDecoder_DEFINED
#include "SkBitmap.h"
-#include "SkBitmapFactory.h"
#include "SkImage.h"
#include "SkRect.h"
#include "SkRefCnt.h"
@@ -159,36 +158,6 @@
Chooser* setChooser(Chooser*);
/**
- @Deprecated. Use the struct version instead.
-
- This optional table describes the caller's preferred config based on
- information about the src data. For this table, the src attributes are
- described in terms of depth (index (8), 16, 32/24) and if there is
- per-pixel alpha. These inputs combine to create an index into the
- pref[] table, which contains the caller's preferred config for that
- input, or kNo_Config if there is no preference.
-
- To specify no preference, call setPrefConfigTable(NULL), which is
- the default.
-
- Note, it is still at the discretion of the codec as to what output
- config is actually returned, as it may not be able to support the
- caller's preference.
-
- Here is how the index into the table is computed from the src:
- depth [8, 16, 32/24] -> 0, 2, 4
- alpha [no, yes] -> 0, 1
- The two index values are OR'd together.
- src: 8-index, no-alpha -> 0
- src: 8-index, yes-alpha -> 1
- src: 16bit, no-alpha -> 2 // e.g. 565
- src: 16bit, yes-alpha -> 3 // e.g. 1555
- src: 32/24, no-alpha -> 4
- src: 32/24, yes-alpha -> 5
- */
- void setPrefConfigTable(const SkBitmap::Config pref[6]);
-
- /**
* Optional table describing the caller's preferred config based on
* information about the src data. Each field should be set to the
* preferred config for a src described in the name of the field. The
@@ -366,31 +335,19 @@
}
/**
- * Decode memory.
- * @param info Output parameter. Returns info about the encoded image.
- * @param target Contains the address of pixel memory to decode into
- * (which must be large enough to hold the width in info) and
- * the row bytes to use. If NULL, returns info and does not
- * decode pixels.
- * @return bool Whether the function succeeded.
- *
- * Sample usage:
- * <code>
- * // Determine the image's info: width/height/config
- * SkImageInfo info;
- * bool success = DecodeMemoryToTarget(src, size, &info, NULL);
- * if (!success) return;
- * // Allocate space for the result:
- * SkBitmapFactory::Target target;
- * target.fAddr = malloc/other allocation
- * target.fRowBytes = ...
- * // Now decode the actual pixels into target. &info is optional,
- * // and could be NULL
- * success = DecodeMemoryToTarget(src, size, &info, &target);
- * </code>
+ * Struct containing information about a pixel destination.
*/
- static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImageInfo* info,
- const SkBitmapFactory::Target* target);
+ struct Target {
+ /**
+ * Pre-allocated memory.
+ */
+ void* fAddr;
+
+ /**
+ * Rowbytes of the allocated memory.
+ */
+ size_t fRowBytes;
+ };
/** Decode the image stored in the specified SkStreamRewindable, and store the result
in bitmap. Return true for success or false on failure.
diff --git a/core/SkImageFilter.h b/core/SkImageFilter.h
index 1e9f72e..4c372a4 100644
--- a/core/SkImageFilter.h
+++ b/core/SkImageFilter.h
@@ -156,7 +156,14 @@
virtual ~SkImageFilter();
- explicit SkImageFilter(int maxInputCount, SkFlattenableReadBuffer& rb);
+ /**
+ * Constructs a new SkImageFilter read from an SkFlattenableReadBuffer object.
+ *
+ * @param inputCount The exact number of inputs expected for this SkImageFilter object.
+ * -1 can be used if the filter accepts any number of inputs.
+ * @param rb SkFlattenableReadBuffer object from which the SkImageFilter is read.
+ */
+ explicit SkImageFilter(int inputCount, SkFlattenableReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE;
diff --git a/core/SkImageGenerator.h b/core/SkImageGenerator.h
index e43fbc1..d56f8f8 100644
--- a/core/SkImageGenerator.h
+++ b/core/SkImageGenerator.h
@@ -8,15 +8,43 @@
#ifndef SkImageGenerator_DEFINED
#define SkImageGenerator_DEFINED
+#include "SkDiscardableMemory.h"
#include "SkImageInfo.h"
+class SkBitmap;
class SkData;
+class SkImageGenerator;
+
+/**
+ * Takes ownership of SkImageGenerator. If this method fails for
+ * whatever reason, it will return false and immediatetely delete
+ * the generator. If it succeeds, it will modify destination
+ * bitmap.
+ *
+ * If this fails or when the SkDiscardablePixelRef that is
+ * installed into destination is destroyed, it will call
+ * SkDELETE() on the generator. Therefore, generator should be
+ * allocated with SkNEW() or SkNEW_ARGS().
+ *
+ * @param destination Upon success, this bitmap will be
+ * configured and have a pixelref installed.
+ *
+ * @param factory If not NULL, this object will be used as a
+ * source of discardable memory when decoding. If NULL, then
+ * SkDiscardableMemory::Create() will be called.
+ *
+ * @return true iff successful.
+ */
+SK_API bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
+ SkBitmap* destination,
+ SkDiscardableMemory::Factory* factory = NULL);
+
/**
* An interface that allows a purgeable PixelRef (such as a
* SkDiscardablePixelRef) to decode and re-decode an image as needed.
*/
-class SkImageGenerator {
+class SK_API SkImageGenerator {
public:
/**
* The PixelRef which takes ownership of this SkImageGenerator
@@ -37,6 +65,9 @@
* Return some information about the image, allowing the owner of
* this object to allocate pixels.
*
+ * Repeated calls to this function should give the same results,
+ * allowing the PixelRef to be immutable.
+ *
* @return false if anything goes wrong.
*/
virtual bool getInfo(SkImageInfo* info) = 0;
@@ -46,6 +77,9 @@
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
* bytesPerPixel)
*
+ * Repeated calls to this function should give the same results,
+ * allowing the PixelRef to be immutable.
+ *
* @param info A description of the format (config, size)
* expected by the caller. This can simply be identical
* to the info returned by getInfo().
diff --git a/core/SkImageInfo.h b/core/SkImageInfo.h
index c22249b..1165479 100644
--- a/core/SkImageInfo.h
+++ b/core/SkImageInfo.h
@@ -10,6 +10,9 @@
#include "SkTypes.h"
+class SkFlattenableWriteBuffer;
+class SkFlattenableReadBuffer;
+
/**
* Describes how to interpret the alpha compoent of a pixel.
*/
@@ -63,11 +66,12 @@
enum SkColorType {
kAlpha_8_SkColorType,
kRGB_565_SkColorType,
+ kARGB_4444_SkColorType,
kRGBA_8888_SkColorType,
kBGRA_8888_SkColorType,
- kIndex8_SkColorType,
+ kIndex_8_SkColorType,
- kLastEnum_SkColorType = kIndex8_SkColorType,
+ kLastEnum_SkColorType = kIndex_8_SkColorType,
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
kPMColor_SkColorType = kBGRA_8888_SkColorType
@@ -82,6 +86,7 @@
static const uint8_t gSize[] = {
1, // Alpha_8
2, // RGB_565
+ 2, // ARGB_4444
4, // RGBA_8888
4, // BGRA_8888
1, // kIndex_8
@@ -112,12 +117,26 @@
return SkColorTypeBytesPerPixel(fColorType);
}
+ size_t minRowBytes() const {
+ return fWidth * this->bytesPerPixel();
+ }
+
bool operator==(const SkImageInfo& other) const {
return 0 == memcmp(this, &other, sizeof(other));
}
bool operator!=(const SkImageInfo& other) const {
return 0 != memcmp(this, &other, sizeof(other));
}
+
+ void unflatten(SkFlattenableReadBuffer&);
+ void flatten(SkFlattenableWriteBuffer&) const;
+
+ size_t getSafeSize(size_t rowBytes) const {
+ if (0 == fHeight) {
+ return 0;
+ }
+ return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel();
+ }
};
#endif
diff --git a/core/SkInstCnt.h b/core/SkInstCnt.h
index cab8ebb..e38c42d 100644
--- a/core/SkInstCnt.h
+++ b/core/SkInstCnt.h
@@ -14,7 +14,6 @@
* instance counting machinery. A class is added to the system by adding:
* SK_DECLARE_INST_COUNT at the top of its declaration for derived classes
* SK_DECLARE_INST_COUNT_ROOT at the top of its declaration for a root class
- * SK_DEFINE_INST_COUNT at the top of its .cpp file (for both kinds).
* At the end of an application a call to all the "root" objects'
* CheckInstanceCount methods should be made
*/
@@ -29,47 +28,49 @@
// The non-root classes just register themselves with their parent
#define SK_DECLARE_INST_COUNT(className) \
SK_DECLARE_INST_COUNT_INTERNAL(className, \
- INHERITED::AddInstChild(CheckInstanceCount);,\
- /**/)
-
-#define SK_DECLARE_INST_COUNT_TEMPLATE(className) \
- SK_DECLARE_INST_COUNT_INTERNAL(className, \
- INHERITED::AddInstChild(CheckInstanceCount);, \
- typename)
+ INHERITED::AddInstChild(CheckInstanceCount);)
// The root classes registers a function to print out the memory stats when
// the app ends
#define SK_DECLARE_INST_COUNT_ROOT(className) \
- SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);, /**/)
+ SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);)
-#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep, templateType) \
+#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \
class SkInstanceCountHelper { \
public: \
typedef int (*PFCheckInstCnt)(int level, bool cleanUp); \
SkInstanceCountHelper() { \
+ static bool gInited; \
if (!gInited) { \
initStep \
- gChildren = new SkTArray<PFCheckInstCnt>; \
+ GetChildren() = new SkTArray<PFCheckInstCnt>; \
gInited = true; \
} \
- sk_atomic_inc(&gInstanceCount); \
+ sk_atomic_inc(GetInstanceCountPtr()); \
} \
\
SkInstanceCountHelper(const SkInstanceCountHelper&) { \
- sk_atomic_inc(&gInstanceCount); \
+ sk_atomic_inc(GetInstanceCountPtr()); \
} \
\
~SkInstanceCountHelper() { \
- sk_atomic_dec(&gInstanceCount); \
+ sk_atomic_dec(GetInstanceCountPtr()); \
} \
\
- static int32_t gInstanceCount; \
- static bool gInited; \
- static SkTArray<PFCheckInstCnt>* gChildren; \
+ static int32_t* GetInstanceCountPtr() { \
+ static int32_t gInstanceCount; \
+ return &gInstanceCount; \
+ } \
+ \
+ static SkTArray<PFCheckInstCnt>*& GetChildren() { \
+ static SkTArray<PFCheckInstCnt>* gChildren; \
+ return gChildren; \
+ } \
+ \
} fInstanceCountHelper; \
\
static int32_t GetInstanceCount() { \
- return SkInstanceCountHelper::gInstanceCount; \
+ return *SkInstanceCountHelper::GetInstanceCountPtr(); \
} \
\
static void exitPrint() { \
@@ -77,57 +78,50 @@
} \
\
static int CheckInstanceCount(int level = 0, bool cleanUp = false) { \
- if (gPrintInstCount && 0 != SkInstanceCountHelper::gInstanceCount) {\
+ if (gPrintInstCount && 0 != GetInstanceCount()) { \
SkDebugf("%*c Leaked %s: %d\n", \
4*level, ' ', #className, \
- SkInstanceCountHelper::gInstanceCount); \
+ GetInstanceCount()); \
} \
- if (NULL == SkInstanceCountHelper::gChildren) { \
- return SkInstanceCountHelper::gInstanceCount; \
+ if (NULL == SkInstanceCountHelper::GetChildren()) { \
+ return GetInstanceCount(); \
} \
- int childCount = SkInstanceCountHelper::gChildren->count(); \
- int count = SkInstanceCountHelper::gInstanceCount; \
+ SkTArray<int (*)(int, bool)>* children = \
+ SkInstanceCountHelper::GetChildren(); \
+ int childCount = children->count(); \
+ int count = GetInstanceCount(); \
for (int i = 0; i < childCount; ++i) { \
- count -= (*(*SkInstanceCountHelper::gChildren)[i])(level+1, cleanUp); \
+ count -= (*(*children)[i])(level+1, cleanUp); \
} \
SkASSERT(count >= 0); \
if (gPrintInstCount && childCount > 0 && count > 0) { \
SkDebugf("%*c Leaked ???: %d\n", 4*(level + 1), ' ', count); \
} \
if (cleanUp) { \
- delete SkInstanceCountHelper::gChildren; \
- SkInstanceCountHelper::gChildren = NULL; \
+ delete children; \
+ SkInstanceCountHelper::GetChildren() = NULL; \
} \
- return SkInstanceCountHelper::gInstanceCount; \
+ return GetInstanceCount(); \
} \
\
- static void AddInstChild(templateType SkInstanceCountHelper::PFCheckInstCnt \
- childCheckInstCnt) { \
+ static void AddInstChild(int (*childCheckInstCnt)(int, bool)) { \
if (CheckInstanceCount != childCheckInstCnt && \
- NULL != SkInstanceCountHelper::gChildren) { \
- SkInstanceCountHelper::gChildren->push_back(childCheckInstCnt); \
+ NULL != SkInstanceCountHelper::GetChildren()) { \
+ SkInstanceCountHelper::GetChildren()->push_back(childCheckInstCnt); \
} \
}
-#define SK_DEFINE_INST_COUNT(className) \
- int32_t className::SkInstanceCountHelper::gInstanceCount = 0; \
- bool className::SkInstanceCountHelper::gInited = false; \
- SkTArray<className::SkInstanceCountHelper::PFCheckInstCnt>* \
- className::SkInstanceCountHelper::gChildren = NULL;
-
-#define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) \
- templateInfo int32_t className::SkInstanceCountHelper::gInstanceCount = 0;\
- templateInfo bool className::SkInstanceCountHelper::gInited = false; \
- templateInfo \
- SkTArray<typename className::SkInstanceCountHelper::PFCheckInstCnt>*\
- className::SkInstanceCountHelper::gChildren = NULL;
-
#else
-#define SK_DECLARE_INST_COUNT(className)
-#define SK_DECLARE_INST_COUNT_TEMPLATE(className)
-#define SK_DECLARE_INST_COUNT_ROOT(className)
+// Typically SK_ENABLE_INST_COUNT=0. Make sure the class declares public typedef INHERITED by
+// causing a compile-time error if the typedef is missing. This way SK_ENABLE_INST_COUNT=1 stays
+// compiling.
+#define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED::AddInstChild(); }
+#define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { }
+#endif
+
+// Following are deprecated. They are defined only for backwards API compatibility.
+#define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(className)
#define SK_DEFINE_INST_COUNT(className)
#define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className)
-#endif
#endif // SkInstCnt_DEFINED
diff --git a/core/SkMallocPixelRef.h b/core/SkMallocPixelRef.h
index 2241a51..100a15d 100644
--- a/core/SkMallocPixelRef.h
+++ b/core/SkMallocPixelRef.h
@@ -24,8 +24,6 @@
SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixels = true);
virtual ~SkMallocPixelRef();
- //! Return the allocation size for the pixels
- size_t getSize() const { return fSize; }
void* getAddr() const { return fStorage; }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef)
@@ -38,6 +36,9 @@
SkMallocPixelRef(SkFlattenableReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
+ // Returns the allocation size for the pixels
+ virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE { return fSize; }
+
private:
void* fStorage;
size_t fSize;
diff --git a/core/SkMatrix.h b/core/SkMatrix.h
index dad5ff9..d7726f6 100644
--- a/core/SkMatrix.h
+++ b/core/SkMatrix.h
@@ -574,6 +574,14 @@
SkDEVCODE(void toString(SkString*) const;)
/**
+ * Calculates the minimum stretching factor of the matrix. If the matrix has
+ * perspective -1 is returned.
+ *
+ * @return minumum strecthing factor
+ */
+ SkScalar getMinStretch() const;
+
+ /**
* Calculates the maximum stretching factor of the matrix. If the matrix has
* perspective -1 is returned.
*
diff --git a/core/SkPath.h b/core/SkPath.h
index ac4dd3b..0b2ea61 100644
--- a/core/SkPath.h
+++ b/core/SkPath.h
@@ -151,7 +151,7 @@
* optimization for performance and so some paths that are in
* fact ovals can report false.
*/
- bool isOval(SkRect* rect) const;
+ bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); }
/** Clear any lines and curves from the path, making it empty. This frees up
internal storage associated with those segments.
@@ -931,15 +931,15 @@
private:
enum SerializationOffsets {
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- kNewFormat_SerializationShift = 28, // requires 1 bit
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
+ kNewFormat_SerializationShift = 29, // requires 1 bit
#endif
+ kUnused1_SerializationShift = 28, // 1 free bit
kDirection_SerializationShift = 26, // requires 2 bits
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- // rename to kUnused_SerializationShift
- kOldIsFinite_SerializationShift = 25, // 1 bit
+ kUnused2_SerializationShift = 25, // 1 free bit
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
+ kOldIsOval_SerializationShift = 24, // requires 1 bit
#endif
- kIsOval_SerializationShift = 24, // requires 1 bit
kConvexity_SerializationShift = 16, // requires 8 bits
kFillType_SerializationShift = 8, // requires 8 bits
kSegmentMask_SerializationShift = 0 // requires 4 bits
@@ -952,7 +952,6 @@
uint8_t fSegmentMask;
mutable uint8_t fConvexity;
mutable uint8_t fDirection;
- mutable SkBool8 fIsOval;
#ifdef SK_BUILD_FOR_ANDROID
const SkPath* fSourcePath;
#endif
@@ -1008,7 +1007,7 @@
fPathRef->setBounds(rect);
}
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
friend class SkPathRef; // just for SerializationOffsets
#endif
friend class SkAutoPathBoundsUpdate;
diff --git a/core/SkPathRef.h b/core/SkPathRef.h
index aea0a91..5d55c72 100644
--- a/core/SkPathRef.h
+++ b/core/SkPathRef.h
@@ -23,7 +23,7 @@
* Holds the path verbs and points. It is versioned by a generation ID. None of its public methods
* modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an
* SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs
- * copy-on-write if the SkPathRef is shared by multipls SkPaths. The caller passes the Editor's
+ * copy-on-write if the SkPathRef is shared by multiple SkPaths. The caller passes the Editor's
* constructor a SkAutoTUnref, which may be updated to point to a new SkPathRef after the editor's
* constructor returns.
*
@@ -100,6 +100,8 @@
*/
SkPathRef* pathRef() { return fPathRef; }
+ void setIsOval(bool isOval) { fPathRef->setIsOval(isOval); }
+
private:
SkPathRef* fPathRef;
};
@@ -121,6 +123,24 @@
return SkToBool(fIsFinite);
}
+ /** Returns true if the path is an oval.
+ *
+ * @param rect returns the bounding rect of this oval. It's a circle
+ * if the height and width are the same.
+ *
+ * @return true if this path is an oval.
+ * Tracking whether a path is an oval is considered an
+ * optimization for performance and so some paths that are in
+ * fact ovals can report false.
+ */
+ bool isOval(SkRect* rect) const {
+ if (fIsOval && NULL != rect) {
+ *rect = getBounds();
+ }
+
+ return SkToBool(fIsOval);
+ }
+
bool hasComputedBounds() const {
return !fBoundsIsDirty;
}
@@ -152,7 +172,7 @@
const SkMatrix& matrix);
static SkPathRef* CreateFromBuffer(SkRBuffer* buffer
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
, bool newFormat, int32_t oldPacked
#endif
);
@@ -237,6 +257,7 @@
private:
enum SerializationOffsets {
kIsFinite_SerializationShift = 25, // requires 1 bit
+ kIsOval_SerializationShift = 24, // requires 1 bit
};
SkPathRef() {
@@ -247,6 +268,7 @@
fPoints = NULL;
fFreeSpace = 0;
fGenerationID = kEmptyGenID;
+ fIsOval = false;
SkDEBUGCODE(fEditorsAttached = 0;)
SkDEBUGCODE(this->validate();)
}
@@ -289,6 +311,8 @@
fBoundsIsDirty = true; // this also invalidates fIsFinite
fGenerationID = 0;
+ fIsOval = false;
+
size_t newSize = sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount;
size_t newReserve = sizeof(uint8_t) * reserveVerbs + sizeof(SkPoint) * reservePoints;
size_t minSize = newSize + newReserve;
@@ -394,6 +418,8 @@
*/
static void CreateEmptyImpl(SkPathRef** empty);
+ void setIsOval(bool isOval) { fIsOval = isOval; }
+
enum {
kMinSize = 256,
};
@@ -401,6 +427,7 @@
mutable SkRect fBounds;
mutable uint8_t fBoundsIsDirty;
mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
+ mutable SkBool8 fIsOval;
SkPoint* fPoints; // points to begining of the allocation
uint8_t* fVerbs; // points just past the end of the allocation (verbs grow backwards)
diff --git a/core/SkPicture.h b/core/SkPicture.h
index e371c43..bce343e 100644
--- a/core/SkPicture.h
+++ b/core/SkPicture.h
@@ -218,13 +218,12 @@
// V13: add flag to drawBitmapRectToRect
// parameterize blurs by sigma rather than radius
// V14: Add flags word to PathRef serialization
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
- static const uint32_t PRIOR_PRIOR_PICTURE_VERSION = 12; // TODO: remove when .skps regenerated
+ // V15: Remove A1 bitmpa config (and renumber remaining configs)
+ // V16: Move SkPath's isOval flag to SkPathRef
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V16_AND_ALL_OTHER_INSTANCES_TOO
+ static const uint32_t PRIOR_PICTURE_VERSION = 15; // TODO: remove when .skps regenerated
#endif
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- static const uint32_t PRIOR_PICTURE_VERSION2 = 13; // TODO: remove when .skps regenerated
-#endif
- static const uint32_t PICTURE_VERSION = 14;
+ static const uint32_t PICTURE_VERSION = 16;
// fPlayback, fRecord, fWidth & fHeight are protected to allow derived classes to
// install their own SkPicturePlayback-derived players,SkPictureRecord-derived
diff --git a/core/SkPixelRef.h b/core/SkPixelRef.h
index d90e587..b87b0dc 100644
--- a/core/SkPixelRef.h
+++ b/core/SkPixelRef.h
@@ -16,6 +16,8 @@
#include "SkFlattenable.h"
#include "SkTDArray.h"
+#define SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
+
#ifdef SK_DEBUG
/**
* Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref
@@ -49,9 +51,19 @@
public:
SK_DECLARE_INST_COUNT(SkPixelRef)
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
+ // DEPRECATED -- use a constructor that takes SkImageInfo
explicit SkPixelRef(SkBaseMutex* mutex = NULL);
+#endif
+
+ explicit SkPixelRef(const SkImageInfo&);
+ SkPixelRef(const SkImageInfo&, SkBaseMutex* mutex);
virtual ~SkPixelRef();
+ const SkImageInfo& info() const {
+ return fInfo;
+ }
+
/** Return the pixel memory returned from lockPixels, or null if the
lockCount is 0.
*/
@@ -257,6 +269,16 @@
// default impl returns NULL.
virtual SkData* onRefEncodedData();
+ /**
+ * Returns the size (in bytes) of the internally allocated memory.
+ * This should be implemented in all serializable SkPixelRef derived classes.
+ * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflow this value,
+ * otherwise the rendering code may attempt to read memory out of bounds.
+ *
+ * @return default impl returns 0.
+ */
+ virtual size_t getAllocatedSizeInBytes() const;
+
/** Return the mutex associated with this pixelref. This value is assigned
in the constructor, and cannot change during the lifetime of the object.
*/
@@ -273,6 +295,8 @@
private:
SkBaseMutex* fMutex; // must remain in scope for the life of this object
+ SkImageInfo fInfo;
+
void* fPixels;
SkColorTable* fColorTable; // we do not track ownership, subclass does
int fLockCount;
diff --git a/core/SkPostConfig.h b/core/SkPostConfig.h
index 9ba199f..efb119f 100644
--- a/core/SkPostConfig.h
+++ b/core/SkPostConfig.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,73 +5,77 @@
* found in the LICENSE file.
*/
-
#ifndef SkPostConfig_DEFINED
#define SkPostConfig_DEFINED
#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE)
- #define SK_BUILD_FOR_WIN
+# define SK_BUILD_FOR_WIN
#endif
#if defined(SK_DEBUG) && defined(SK_RELEASE)
- #error "cannot define both SK_DEBUG and SK_RELEASE"
+# error "cannot define both SK_DEBUG and SK_RELEASE"
#elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
- #error "must define either SK_DEBUG or SK_RELEASE"
+# error "must define either SK_DEBUG or SK_RELEASE"
#endif
-#if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG)
- #error "can't have unittests without debug"
+#if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG)
+# error "can't have unittests without debug"
#endif
#if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT)
- #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
+# error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
#elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT)
- #define SK_SCALAR_IS_FLOAT
+# define SK_SCALAR_IS_FLOAT
#endif
+/**
+ * Matrix calculations may be float or double.
+ * The default is double, as that is faster given our impl uses doubles
+ * for intermediate calculations.
+ */
#if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT)
- #error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT"
+# error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT"
#elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT)
- // default is double, as that is faster given our impl uses doubles
- // for intermediate calculations.
- #define SK_MSCALAR_IS_DOUBLE
+# define SK_MSCALAR_IS_DOUBLE
#endif
#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
- #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
+# error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
#elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
- #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
+# error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
#endif
-// ensure the port has defined all of these, or none of them
+/**
+ * Ensure the port has defined all of SK_X32_SHIFT, or none of them.
+ */
#ifdef SK_A32_SHIFT
- #if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
- #error "all or none of the 32bit SHIFT amounts must be defined"
- #endif
+# if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
+# error "all or none of the 32bit SHIFT amounts must be defined"
+# endif
#else
- #if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
- #error "all or none of the 32bit SHIFT amounts must be defined"
- #endif
+# if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
+# error "all or none of the 32bit SHIFT amounts must be defined"
+# endif
#endif
#if !defined(SK_HAS_COMPILER_FEATURE)
- #if defined(__has_feature)
- #define SK_HAS_COMPILER_FEATURE(x) __has_feature(x)
- #else
- #define SK_HAS_COMPILER_FEATURE(x) 0
- #endif
+# if defined(__has_feature)
+# define SK_HAS_COMPILER_FEATURE(x) __has_feature(x)
+# else
+# define SK_HAS_COMPILER_FEATURE(x) 0
+# endif
#endif
#if !defined(SK_ATTRIBUTE)
- #if defined(__clang__) || defined(__GNUC__)
- #define SK_ATTRIBUTE(attr) __attribute__((attr))
- #else
- #define SK_ATTRIBUTE(attr)
- #endif
+# if defined(__clang__) || defined(__GNUC__)
+# define SK_ATTRIBUTE(attr) __attribute__((attr))
+# else
+# define SK_ATTRIBUTE(attr)
+# endif
#endif
#if !defined(SK_SUPPORT_GPU)
- #define SK_SUPPORT_GPU 1
+# define SK_SUPPORT_GPU 1
#endif
/**
@@ -83,127 +86,129 @@
* executed only if the non-returning function was *not* called.
*/
#if !defined(SkNO_RETURN_HINT)
- #if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn)
- static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn));
- static inline void SkNO_RETURN_HINT() {}
- #else
- #define SkNO_RETURN_HINT() do {} while (false)
- #endif
+# if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn)
+ static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn));
+ static inline void SkNO_RETURN_HINT() {}
+# else
+# define SkNO_RETURN_HINT() do {} while (false)
+# endif
#endif
#if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB)
- #error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB"
+# error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB"
#elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB)
- #define SK_HAS_ZLIB
+# define SK_HAS_ZLIB
#endif
///////////////////////////////////////////////////////////////////////////////
#ifndef SkNEW
- #define SkNEW(type_name) (new type_name)
- #define SkNEW_ARGS(type_name, args) (new type_name args)
- #define SkNEW_ARRAY(type_name, count) (new type_name[(count)])
- #define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name)
- #define SkNEW_PLACEMENT_ARGS(buf, type_name, args) \
- (new (buf) type_name args)
- #define SkDELETE(obj) (delete (obj))
- #define SkDELETE_ARRAY(array) (delete[] (array))
+# define SkNEW(type_name) (new type_name)
+# define SkNEW_ARGS(type_name, args) (new type_name args)
+# define SkNEW_ARRAY(type_name, count) (new type_name[(count)])
+# define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name)
+# define SkNEW_PLACEMENT_ARGS(buf, type_name, args) (new (buf) type_name args)
+# define SkDELETE(obj) (delete (obj))
+# define SkDELETE_ARRAY(array) (delete[] (array))
#endif
#ifndef SK_CRASH
-#if 1 // set to 0 for infinite loop, which can help connecting gdb
- #define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
-#else
- #define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
-#endif
+# if 1 // set to 0 for infinite loop, which can help connecting gdb
+# define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
+# else
+# define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
+# endif
#endif
///////////////////////////////////////////////////////////////////////////////
-// SK_ENABLE_INST_COUNT defaults to 1 in DEBUG and 0 in RELEASE
+/**
+ * SK_ENABLE_INST_COUNT controlls printing how many reference counted objects
+ * are still held on exit.
+ * Defaults to 1 in DEBUG and 0 in RELEASE.
+ * FIXME: currently always 0, since it fails if multiple threads run at once
+ * (see skbug.com/1219 ).
+ */
#ifndef SK_ENABLE_INST_COUNT
- #ifdef SK_DEBUG
- // FIXME: fails if multiple threads run at once (see skbug.com/1219 )
- #define SK_ENABLE_INST_COUNT 0
- #else
- #define SK_ENABLE_INST_COUNT 0
- #endif
+# ifdef SK_DEBUG
+# define SK_ENABLE_INST_COUNT 0
+# else
+# define SK_ENABLE_INST_COUNT 0
+# endif
#endif
///////////////////////////////////////////////////////////////////////////////
#if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT)
- // if this is defined, we convert floats to 2scompliment ints for compares
- #ifndef SK_SCALAR_SLOW_COMPARES
- #define SK_SCALAR_SLOW_COMPARES
- #endif
- #ifndef SK_USE_FLOATBITS
- #define SK_USE_FLOATBITS
- #endif
+ // if this is defined, we convert floats to 2s compliment ints for compares.
+# ifndef SK_SCALAR_SLOW_COMPARES
+# define SK_SCALAR_SLOW_COMPARES
+# endif
+# ifndef SK_USE_FLOATBITS
+# define SK_USE_FLOATBITS
+# endif
#endif
#ifdef SK_BUILD_FOR_WIN
- // we want lean_and_mean when we include windows.h
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
- #endif
- #ifndef NOMINMAX
- #define NOMINMAX
- #define NOMINMAX_WAS_LOCALLY_DEFINED
- #endif
-
- #include <windows.h>
-
- #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
- #undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
- #undef WIN32_LEAN_AND_MEAN
- #endif
-
- #ifdef NOMINMAX_WAS_LOCALLY_DEFINED
- #undef NOMINMAX_WAS_LOCALLY_DEFINED
- #undef NOMINMAX
- #endif
-
- #ifndef SK_DEBUGBREAK
- #define SK_DEBUGBREAK(cond) do { if (!(cond)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false)
- #endif
-
- #ifndef SK_A32_SHIFT
- #define SK_A32_SHIFT 24
- #define SK_R32_SHIFT 16
- #define SK_G32_SHIFT 8
- #define SK_B32_SHIFT 0
- #endif
-
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# endif
+# ifndef NOMINMAX
+# define NOMINMAX
+# define NOMINMAX_WAS_LOCALLY_DEFINED
+# endif
+#
+# include <windows.h>
+#
+# ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# undef WIN32_LEAN_AND_MEAN
+# endif
+# ifdef NOMINMAX_WAS_LOCALLY_DEFINED
+# undef NOMINMAX_WAS_LOCALLY_DEFINED
+# undef NOMINMAX
+# endif
+#
+# ifndef SK_DEBUGBREAK
+# define SK_DEBUGBREAK(p) do { if (!(p)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false)
+# endif
+#
+# ifndef SK_A32_SHIFT
+# define SK_A32_SHIFT 24
+# define SK_R32_SHIFT 16
+# define SK_G32_SHIFT 8
+# define SK_B32_SHIFT 0
+# endif
+#
#else
- #ifdef SK_DEBUG
- #include <stdio.h>
- #ifndef SK_DEBUGBREAK
- #define SK_DEBUGBREAK(cond) do { if (cond) break; \
+# ifdef SK_DEBUG
+# include <stdio.h>
+# ifndef SK_DEBUGBREAK
+# define SK_DEBUGBREAK(cond) do { if (cond) break; \
SkDebugf("%s:%d: failed assertion \"%s\"\n", \
__FILE__, __LINE__, #cond); SK_CRASH(); } while (false)
- #endif
- #endif
+# endif
+# endif
#endif
-/*
+/**
* We check to see if the SHIFT value has already been defined.
* if not, we define it ourself to some default values. We default to OpenGL
* order (in memory: r,g,b,a)
*/
#ifndef SK_A32_SHIFT
- #ifdef SK_CPU_BENDIAN
- #define SK_R32_SHIFT 24
- #define SK_G32_SHIFT 16
- #define SK_B32_SHIFT 8
- #define SK_A32_SHIFT 0
- #else
- #define SK_R32_SHIFT 0
- #define SK_G32_SHIFT 8
- #define SK_B32_SHIFT 16
- #define SK_A32_SHIFT 24
- #endif
+# ifdef SK_CPU_BENDIAN
+# define SK_R32_SHIFT 24
+# define SK_G32_SHIFT 16
+# define SK_B32_SHIFT 8
+# define SK_A32_SHIFT 0
+# else
+# define SK_R32_SHIFT 0
+# define SK_G32_SHIFT 8
+# define SK_B32_SHIFT 16
+# define SK_A32_SHIFT 24
+# endif
#endif
/**
@@ -223,166 +228,121 @@
* SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine.
*/
#ifdef SK_CPU_BENDIAN
- #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
+# define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
(SK_ ## C3 ## 32_SHIFT == 0 && \
SK_ ## C2 ## 32_SHIFT == 8 && \
SK_ ## C1 ## 32_SHIFT == 16 && \
SK_ ## C0 ## 32_SHIFT == 24)
#else
- #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
+# define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
(SK_ ## C0 ## 32_SHIFT == 0 && \
SK_ ## C1 ## 32_SHIFT == 8 && \
SK_ ## C2 ## 32_SHIFT == 16 && \
SK_ ## C3 ## 32_SHIFT == 24)
#endif
-// stdlib macros
-
-#if 0
-#if !defined(strlen) && defined(SK_DEBUG)
- extern size_t sk_strlen(const char*);
- #define strlen(s) sk_strlen(s)
-#endif
-#ifndef sk_strcpy
- #define sk_strcpy(dst, src) strcpy(dst, src)
-#endif
-#ifndef sk_strchr
- #define sk_strchr(s, c) strchr(s, c)
-#endif
-#ifndef sk_strrchr
- #define sk_strrchr(s, c) strrchr(s, c)
-#endif
-#ifndef sk_strcmp
- #define sk_strcmp(s, t) strcmp(s, t)
-#endif
-#ifndef sk_strncmp
- #define sk_strncmp(s, t, n) strncmp(s, t, n)
-#endif
-#ifndef sk_memcpy
- #define sk_memcpy(dst, src, n) memcpy(dst, src, n)
-#endif
-#ifndef memmove
- #define memmove(dst, src, n) memmove(dst, src, n)
-#endif
-#ifndef sk_memset
- #define sk_memset(dst, val, n) memset(dst, val, n)
-#endif
-#ifndef sk_memcmp
- #define sk_memcmp(s, t, n) memcmp(s, t, n)
-#endif
-
-#define sk_strequal(s, t) (!sk_strcmp(s, t))
-#define sk_strnequal(s, t, n) (!sk_strncmp(s, t, n))
-#endif
-
//////////////////////////////////////////////////////////////////////
#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC)
- #ifndef SkLONGLONG
- #ifdef SK_BUILD_FOR_WIN32
- #define SkLONGLONG __int64
- #else
- #define SkLONGLONG long long
- #endif
- #endif
+# ifndef SkLONGLONG
+# ifdef SK_BUILD_FOR_WIN32
+# define SkLONGLONG __int64
+# else
+# define SkLONGLONG long long
+# endif
+# endif
#endif
//////////////////////////////////////////////////////////////////////////////////////////////
#ifndef SK_BUILD_FOR_WINCE
-#include <string.h>
-#include <stdlib.h>
+# include <string.h>
+# include <stdlib.h>
#else
-#define _CMNINTRIN_DECLARE_ONLY
-#include "cmnintrin.h"
+# define _CMNINTRIN_DECLARE_ONLY
+# include "cmnintrin.h"
#endif
#if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32
-//#define _CRTDBG_MAP_ALLOC
-#ifdef free
-#undef free
-#endif
-#include <crtdbg.h>
-#undef free
-
-#ifdef SK_DEBUGx
-#if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
- void * operator new(
- size_t cb,
- int nBlockUse,
- const char * szFileName,
- int nLine,
- int foo
- );
- void * operator new[](
- size_t cb,
- int nBlockUse,
- const char * szFileName,
- int nLine,
- int foo
- );
- void operator delete(
- void *pUserData,
- int, const char*, int, int
- );
- void operator delete(
- void *pUserData
- );
- void operator delete[]( void * p );
- #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
-#else
- #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
-#endif
- #define new DEBUG_CLIENTBLOCK
-#else
-#define DEBUG_CLIENTBLOCK
-#endif // _DEBUG
-
-
-#endif
-
+# ifdef free
+# undef free
+# endif
+# include <crtdbg.h>
+# undef free
+#
+# ifdef SK_DEBUGx
+# if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
+ void * operator new(
+ size_t cb,
+ int nBlockUse,
+ const char * szFileName,
+ int nLine,
+ int foo
+ );
+ void * operator new[](
+ size_t cb,
+ int nBlockUse,
+ const char * szFileName,
+ int nLine,
+ int foo
+ );
+ void operator delete(
+ void *pUserData,
+ int, const char*, int, int
+ );
+ void operator delete(
+ void *pUserData
+ );
+ void operator delete[]( void * p );
+# define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
+# else
+# define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
+# endif
+# define new DEBUG_CLIENTBLOCK
+# else
+# define DEBUG_CLIENTBLOCK
+# endif
#endif
//////////////////////////////////////////////////////////////////////
#ifndef SK_OVERRIDE
- #if defined(_MSC_VER)
- #define SK_OVERRIDE override
- #elif defined(__clang__)
- // Clang defaults to C++03 and warns about using override. Squelch that. Intentionally no
- // push/pop here so all users of SK_OVERRIDE ignore the warning too. This is like passing
- // -Wno-c++11-extensions, except that GCC won't die (because it won't see this pragma).
- #pragma clang diagnostic ignored "-Wc++11-extensions"
-
- #if __has_feature(cxx_override_control)
- // Some documentation suggests we should be using __attribute__((override)),
- // but it doesn't work.
- #define SK_OVERRIDE override
- #elif defined(__has_extension)
- #if __has_extension(cxx_override_control)
- #define SK_OVERRIDE override
- #endif
- #endif
- #endif
- #ifndef SK_OVERRIDE
- #define SK_OVERRIDE
- #endif
+# if defined(_MSC_VER)
+# define SK_OVERRIDE override
+# elif defined(__clang__)
+ // Using __attribute__((override)) on clang does not appear to always work.
+ // Clang defaults to C++03 and warns about using override. Squelch that. Intentionally no
+ // push/pop here so all users of SK_OVERRIDE ignore the warning too. This is like passing
+ // -Wno-c++11-extensions, except that GCC won't die (because it won't see this pragma).
+# pragma clang diagnostic ignored "-Wc++11-extensions"
+#
+# if __has_feature(cxx_override_control)
+# define SK_OVERRIDE override
+# elif defined(__has_extension) && __has_extension(cxx_override_control)
+# define SK_OVERRIDE override
+# endif
+# endif
+# ifndef SK_OVERRIDE
+# define SK_OVERRIDE
+# endif
#endif
//////////////////////////////////////////////////////////////////////
#if !defined(SK_UNUSED)
- #define SK_UNUSED SK_ATTRIBUTE(unused)
+# define SK_UNUSED SK_ATTRIBUTE(unused)
#endif
#if !defined(SK_ATTR_DEPRECATED)
- // we ignore msg for now...
- #define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
+ // FIXME: we ignore msg for now...
+# define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
#endif
-// If your judgment is better than the compiler's (i.e. you've profiled it),
-// you can use SK_ALWAYS_INLINE to force inlining. E.g.
-// inline void someMethod() { ... } // may not be inlined
-// SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined
+/**
+ * If your judgment is better than the compiler's (i.e. you've profiled it),
+ * you can use SK_ALWAYS_INLINE to force inlining. E.g.
+ * inline void someMethod() { ... } // may not be inlined
+ * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined
+ */
#if !defined(SK_ALWAYS_INLINE)
# if defined(SK_BUILD_FOR_WIN)
# define SK_ALWAYS_INLINE __forceinline
@@ -394,34 +354,37 @@
//////////////////////////////////////////////////////////////////////
#if defined(__clang__) || defined(__GNUC__)
-#define SK_PREFETCH(ptr) __builtin_prefetch(ptr)
-#define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1)
+# define SK_PREFETCH(ptr) __builtin_prefetch(ptr)
+# define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1)
#else
-#define SK_PREFETCH(ptr)
-#define SK_WRITE_PREFETCH(ptr)
+# define SK_PREFETCH(ptr)
+# define SK_WRITE_PREFETCH(ptr)
#endif
//////////////////////////////////////////////////////////////////////
+
#ifndef SK_PRINTF_LIKE
-#if defined(__clang__) || defined(__GNUC__)
-#define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
-#else
-#define SK_PRINTF_LIKE(A, B)
-#endif
+# if defined(__clang__) || defined(__GNUC__)
+# define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
+# else
+# define SK_PRINTF_LIKE(A, B)
+# endif
#endif
//////////////////////////////////////////////////////////////////////
#ifndef SK_SIZE_T_SPECIFIER
-#if defined(_MSC_VER)
-#define SK_SIZE_T_SPECIFIER "%Iu"
-#else
-#define SK_SIZE_T_SPECIFIER "%zu"
-#endif
+# if defined(_MSC_VER)
+# define SK_SIZE_T_SPECIFIER "%Iu"
+# else
+# define SK_SIZE_T_SPECIFIER "%zu"
+# endif
#endif
//////////////////////////////////////////////////////////////////////
#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
+# define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
#endif
+
+#endif // SkPostConfig_DEFINED
diff --git a/core/SkShader.h b/core/SkShader.h
index 11956ce..cdb7a2f 100644
--- a/core/SkShader.h
+++ b/core/SkShader.h
@@ -334,6 +334,9 @@
* exceed implementation limits (currently at 64K - 1)) then SkEmptyShader
* may be returned.
*
+ * If the src is kA8_Config then that mask will be colorized using the color on
+ * the paint.
+ *
* @param src The bitmap to use inside the shader
* @param tmx The tiling mode to use when sampling the bitmap in the x-direction.
* @param tmy The tiling mode to use when sampling the bitmap in the y-direction.
diff --git a/core/SkString.h b/core/SkString.h
index 291bd65..ce87312 100644
--- a/core/SkString.h
+++ b/core/SkString.h
@@ -11,6 +11,7 @@
#define SkString_DEFINED
#include "SkScalar.h"
+#include "SkTArray.h"
#include <stdarg.h>
@@ -244,4 +245,7 @@
a.swap(b);
}
+// Split str on any characters in delimiters into out. (Think, strtok with a sane API.)
+void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out);
+
#endif
diff --git a/core/SkTInternalLList.h b/core/SkTInternalLList.h
index a6b6f15..0b67d4a 100644
--- a/core/SkTInternalLList.h
+++ b/core/SkTInternalLList.h
@@ -227,7 +227,7 @@
void validate() const {
SkASSERT(!fHead == !fTail);
Iter iter;
- for (T* item = iter.init(*this, Iter::kHead_IterStart); NULL != (item = iter.next()); ) {
+ for (T* item = iter.init(*this, Iter::kHead_IterStart); NULL != item; item = iter.next()) {
SkASSERT(this->isInList(item));
if (NULL == item->fPrev) {
SkASSERT(fHead == item);
diff --git a/core/SkWeakRefCnt.h b/core/SkWeakRefCnt.h
index 0102cbb..e2a7308 100644
--- a/core/SkWeakRefCnt.h
+++ b/core/SkWeakRefCnt.h
@@ -23,7 +23,7 @@
getRefCnt() > 1.
In addition to strong ownership, an owner may instead obtain a weak
- reference by calling weak_ref(). A call to weak_ref() must be balanced my a
+ reference by calling weak_ref(). A call to weak_ref() must be balanced by a
call to weak_unref(). To obtain a strong reference from a weak reference,
call try_ref(). If try_ref() returns true, the owner's pointer is now also
a strong reference on which unref() must be called. Note that this does not
@@ -122,7 +122,7 @@
// so our destructor won't complain
fWeakCnt = 1;
#endif
- SkRefCnt::internal_dispose();
+ this->INHERITED::internal_dispose();
}
}
diff --git a/effects/SkBitmapSource.h b/effects/SkBitmapSource.h
index 138987e..699186e 100644
--- a/effects/SkBitmapSource.h
+++ b/effects/SkBitmapSource.h
@@ -14,6 +14,7 @@
class SK_API SkBitmapSource : public SkImageFilter {
public:
explicit SkBitmapSource(const SkBitmap& bitmap);
+ SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource)
@@ -25,6 +26,7 @@
private:
SkBitmap fBitmap;
+ SkRect fSrcRect, fDstRect;
typedef SkImageFilter INHERITED;
};
diff --git a/effects/SkDropShadowImageFilter.h b/effects/SkDropShadowImageFilter.h
index 501df7c..5a58a0a 100644
--- a/effects/SkDropShadowImageFilter.h
+++ b/effects/SkDropShadowImageFilter.h
@@ -12,6 +12,7 @@
class SK_API SkDropShadowImageFilter : public SkImageFilter {
public:
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor, SkImageFilter* input = NULL);
+ SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
protected:
@@ -20,7 +21,7 @@
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
private:
- SkScalar fDx, fDy, fSigma;
+ SkScalar fDx, fDy, fSigmaX, fSigmaY;
SkColor fColor;
typedef SkImageFilter INHERITED;
};
diff --git a/gpu/GrContext.h b/gpu/GrContext.h
index 03665d7..1770fa6 100644
--- a/gpu/GrContext.h
+++ b/gpu/GrContext.h
@@ -50,11 +50,6 @@
*/
static GrContext* Create(GrBackend, GrBackendContext);
- /**
- * Returns the number of GrContext instances for the current thread.
- */
- static int GetThreadInstanceCount();
-
virtual ~GrContext();
/**
diff --git a/gpu/GrTextureAccess.h b/gpu/GrTextureAccess.h
index 059800f..87b8d82 100644
--- a/gpu/GrTextureAccess.h
+++ b/gpu/GrTextureAccess.h
@@ -36,7 +36,7 @@
this->reset(tileXAndY, filterMode);
}
- GrTextureParams(SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
this->reset(tileModes, filterMode);
}
@@ -60,7 +60,7 @@
fFilterMode = filterMode;
}
- void reset(SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
fTileModes[0] = tileModes[0];
fTileModes[1] = tileModes[1];
fFilterMode = filterMode;
diff --git a/gpu/GrTypes.h b/gpu/GrTypes.h
index ff8f442..0bb432d 100644
--- a/gpu/GrTypes.h
+++ b/gpu/GrTypes.h
@@ -238,8 +238,9 @@
kA8_GrMaskFormat, //!< 1-byte per pixel
kA565_GrMaskFormat, //!< 2-bytes per pixel
kA888_GrMaskFormat, //!< 4-bytes per pixel
+ kARGB_GrMaskFormat, //!< 4-bytes per pixel, color format
- kLast_GrMaskFormat = kA888_GrMaskFormat
+ kLast_GrMaskFormat = kARGB_GrMaskFormat
};
static const int kMaskFormatCount = kLast_GrMaskFormat + 1;
@@ -247,11 +248,15 @@
* Return the number of bytes-per-pixel for the specified mask format.
*/
static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
- SkASSERT((unsigned)format <= 2);
+ SkASSERT((unsigned)format <= 3);
// kA8 (0) -> 1
// kA565 (1) -> 2
// kA888 (2) -> 4
- return 1 << (int)format;
+ // kARGB (3) -> 4
+ static const int sBytesPerPixel[] = { 1, 2, 4, 4 };
+ SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, array_size_mismatch);
+
+ return sBytesPerPixel[(int) format];
}
/**
diff --git a/gpu/SkGpuDevice.h b/gpu/SkGpuDevice.h
index d37f63d..198bad3 100644
--- a/gpu/SkGpuDevice.h
+++ b/gpu/SkGpuDevice.h
@@ -197,14 +197,16 @@
const SkRect&,
const GrTextureParams& params,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags);
+ SkCanvas::DrawBitmapRectFlags flags,
+ bool bicubic);
void drawTiledBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
const SkIRect& clippedSrcRect,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags,
- int tileSize);
+ int tileSize,
+ bool bicubic);
/**
* Returns non-initialized instance.
diff --git a/gpu/SkGrPixelRef.h b/gpu/SkGrPixelRef.h
index da4b8fa..c29c27f 100644
--- a/gpu/SkGrPixelRef.h
+++ b/gpu/SkGrPixelRef.h
@@ -47,7 +47,8 @@
* cache and would like the pixel ref to unlock it in its destructor then transferCacheLock
* should be set to true.
*/
- SkGrPixelRef(GrSurface* surface, bool transferCacheLock = false);
+ SkGrPixelRef(GrSurface*, bool transferCacheLock = false);
+ SkGrPixelRef(const SkImageInfo&, GrSurface*, bool transferCacheLock = false);
virtual ~SkGrPixelRef();
// override from SkPixelRef
diff --git a/gpu/gl/SkNativeGLContext.h b/gpu/gl/SkNativeGLContext.h
index a18c443..7254de1 100644
--- a/gpu/gl/SkNativeGLContext.h
+++ b/gpu/gl/SkNativeGLContext.h
@@ -19,7 +19,7 @@
#include <X11/Xlib.h>
#include <GL/glx.h>
#elif defined(SK_BUILD_FOR_WIN32)
- #include <Windows.h>
+ #include <windows.h>
#include <GL/GL.h>
#endif
diff --git a/lazy/SkBitmapFactory.h b/lazy/SkBitmapFactory.h
deleted file mode 100644
index 8a39a48..0000000
--- a/lazy/SkBitmapFactory.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkBitmapFactory_DEFINED
-#define SkBitmapFactory_DEFINED
-
-#include "SkImage.h"
-#include "SkTypes.h"
-
-class SkBitmap;
-class SkData;
-class SkImageCache;
-
-/**
- * Factory for creating a bitmap from encoded data.
- */
-class SkBitmapFactory {
-
-public:
- /**
- * Struct containing information about a pixel destination.
- */
- struct Target {
- /**
- * Pre-allocated memory.
- */
- void* fAddr;
-
- /**
- * Rowbytes of the allocated memory.
- */
- size_t fRowBytes;
- };
-
- /**
- * Signature for a function to decode an image from encoded data.
- */
- typedef bool (*DecodeProc)(const void* data, size_t length, SkImageInfo*, const Target*);
-
- /**
- * Create a bitmap factory which uses DecodeProc for decoding.
- * @param DecodeProc Must not be NULL.
- */
- SkBitmapFactory(DecodeProc);
-
- ~SkBitmapFactory();
-
- /**
- * Set an image cache to use on pixelrefs provided by installPixelRef. Mutually exclusive
- * with fCacheSelector.
- */
- void setImageCache(SkImageCache* cache);
-
- /**
- * Sets up an SkBitmap from encoded data. On success, the SkBitmap will have its Config,
- * width, height, rowBytes and pixelref set. If fImageCache is non-NULL, or if fCacheSelector
- * is set and returns non-NULL, the pixelref will lazily decode, and that SkImageCache will
- * handle the pixel memory. Otherwise installPixelRef will do an immediate decode.
- * @param SkData Encoded data.
- * @param SkBitmap to install the pixel ref on.
- * @return bool Whether or not a pixel ref was successfully installed.
- */
- bool installPixelRef(SkData*, SkBitmap*);
-
- /**
- * An object for selecting an SkImageCache to use based on an SkImageInfo.
- */
- class CacheSelector : public SkRefCnt {
-
- public:
- SK_DECLARE_INST_COUNT(CacheSelector)
- /**
- * Return an SkImageCache to use based on the provided SkImageInfo. If the caller decides
- * to hang on to the result, it will call ref, so the implementation should not add a ref
- * as a result of this call.
- */
- virtual SkImageCache* selectCache(const SkImageInfo&) = 0;
-
- private:
- typedef SkRefCnt INHERITED;
- };
-
- /**
- * Set the function to be used to select which SkImageCache to use. Mutually exclusive with
- * fImageCache.
- */
- void setCacheSelector(CacheSelector*);
-
-private:
- DecodeProc fDecodeProc;
- SkImageCache* fImageCache;
- CacheSelector* fCacheSelector;
-};
-
-#endif // SkBitmapFactory_DEFINED
diff --git a/lazy/SkImageCache.h b/lazy/SkImageCache.h
deleted file mode 100644
index 6d30ae7..0000000
--- a/lazy/SkImageCache.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkImageCache_DEFINED
-#define SkImageCache_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkTypes.h"
-
-/**
- * Interface for a cache that manages pixel memory.
- */
-class SkImageCache : public SkRefCnt {
-
-public:
- SK_DECLARE_INST_COUNT(SkImageCache)
-
- typedef intptr_t ID;
-
- /**
- * Allocate memory whose lifetime is managed by the cache. On success, MUST be balanced with a
- * call to releaseCache and a call to throwAwayCache.
- * @param bytes Number of bytes needed.
- * @param ID Output parameter which must not be NULL. On success, ID will be set to a value
- * associated with that memory which can be used as a parameter to the other functions
- * in SkImageCache. On failure, ID is unchanged.
- * @return Pointer to the newly allocated memory, or NULL. This memory is safe to use until
- * releaseCache is called with ID.
- */
- virtual void* allocAndPinCache(size_t bytes, ID*) = 0;
-
- /**
- * Output parameter for pinCache, stating whether the memory still contains the data it held
- * when releaseCache was last called for the same ID.
- */
- enum DataStatus {
- /**
- * The data has been purged, and therefore needs to be rewritten to the returned memory.
- */
- kUninitialized_DataStatus,
-
- /**
- * The memory still contains the data it held when releaseCache was last called with the
- * same ID.
- */
- kRetained_DataStatus,
- };
-
- /**
- * Re-request the memory associated with ID and pin it so that it will not be reclaimed until
- * the next call to releaseCache with the same ID.
- * @param ID Unique ID for the memory block.
- * @param status Output parameter which must not be NULL. On success (i.e. the return value is
- * not NULL), status will be set to one of two states representing the cached memory. If
- * status is set to kRetained_DataStatus, the memory contains the same data it did
- * before releaseCache was called with this ID. If status is set to
- * kUninitialized_DataStatus, the memory is still pinned, but the previous data is no
- * longer available. If the return value is NULL, status is unchanged.
- * @return Pointer: If non-NULL, points to the previously allocated memory, in which case
- * this call must be balanced with a call to releaseCache. If NULL, the memory
- * has been reclaimed, and throwAwayCache MUST NOT be called.
- */
- virtual void* pinCache(ID, DataStatus* status) = 0;
-
- /**
- * Inform the cache that it is safe to free the block of memory corresponding to ID. After
- * calling this function, the pointer returned by allocAndPinCache or pinCache must not be
- * used again. In order to access the same memory after this, pinCache must be called with
- * the same ID.
- * @param ID Unique ID for the memory block which is now safe to age out of the cache.
- */
- virtual void releaseCache(ID) = 0;
-
- /**
- * Inform the cache that the block of memory associated with ID will not be asked for again.
- * After this call, ID is no longer valid. Must not be called while the associated memory is
- * pinned. Must be called to balance a successful allocAndPinCache.
- */
- virtual void throwAwayCache(ID) = 0;
-
- /**
- * ID which does not correspond to any valid cache.
- */
- static const ID UNINITIALIZED_ID = 0;
-
-#ifdef SK_DEBUG
- /**
- * Debug only status of a memory block.
- */
- enum MemoryStatus {
- /**
- * It is safe to use the pointer returned by the most recent of allocAndPinCache(ID) or
- * pinCache(ID) with the same ID.
- */
- kPinned_MemoryStatus,
-
- /**
- * The pointer returned by the most recent call to allocAndPinCache(ID) or pinCache(ID) has
- * since been released by releaseCache(ID). In order to reuse it, pinCache(ID) must be
- * called again. Note that after calling releaseCache(ID), the status of that particular
- * ID may not be kUnpinned_MemoryStatus, depending on the implementation, but it will not
- * be kPinned_MemoryStatus.
- */
- kUnpinned_MemoryStatus,
-
- /**
- * The memory associated with ID has been thrown away. No calls should be made using the
- * same ID.
- */
- kFreed_MemoryStatus,
- };
-
- /**
- * Debug only function to get the status of a particular block of memory. Safe to call after
- * throwAwayCache has been called with this ID.
- */
- virtual MemoryStatus getMemoryStatus(intptr_t ID) const = 0;
-
- /**
- * Debug only function to clear all unpinned caches.
- */
- virtual void purgeAllUnpinnedCaches() = 0;
-#endif
-
-private:
- typedef SkRefCnt INHERITED;
-};
-#endif // SkImageCache_DEFINED
diff --git a/lazy/SkLruImageCache.h b/lazy/SkLruImageCache.h
deleted file mode 100644
index 5170a05..0000000
--- a/lazy/SkLruImageCache.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkLruImageCache_DEFINED
-#define SkLruImageCache_DEFINED
-
-#include "SkImageCache.h"
-#include "SkThread.h"
-#include "SkTInternalLList.h"
-
-class CachedPixels;
-
-/**
- * SkImageCache implementation that uses an LRU cache to age out old images.
- */
-class SkLruImageCache : public SkImageCache {
-
-public:
- SK_DECLARE_INST_COUNT(SkLruImageCache)
-
- SkLruImageCache(size_t budget);
-
- virtual ~SkLruImageCache();
-
-#ifdef SK_DEBUG
- virtual MemoryStatus getMemoryStatus(ID) const SK_OVERRIDE;
- virtual void purgeAllUnpinnedCaches() SK_OVERRIDE;
-#endif
-
- /**
- * Set the byte limit on cached pixels. If more bytes are used than this, the cache will free
- * unpinned memory until under the new limit or until all unpinned memory is freed. This will
- * never free pinned memory, so the cache can potentially remain over the limit. The limit is
- * enforced each time memory is allocated or released.
- * 0 is a special flag for an infinite budget.
- * @return size_t The previous limit.
- */
- size_t setImageCacheLimit(size_t newLimit);
-
- /**
- * Return the number of bytes of memory currently in use by the cache. Can include memory that
- * is no longer pinned, but has not been freed.
- */
- size_t getImageCacheUsed() const { return fRamUsed; }
-
- virtual void* allocAndPinCache(size_t bytes, ID*) SK_OVERRIDE;
- virtual void* pinCache(ID, SkImageCache::DataStatus*) SK_OVERRIDE;
- virtual void releaseCache(ID) SK_OVERRIDE;
- virtual void throwAwayCache(ID) SK_OVERRIDE;
-
-private:
- // Linked list of recently used. Head is the most recently used, and tail is the least.
- SkTInternalLList<CachedPixels> fLRU;
- typedef SkTInternalLList<CachedPixels>::Iter Iter;
-
-#ifdef SK_DEBUG
- // fMutex is mutable so that getMemoryStatus can be const
- mutable
-#endif
- SkMutex fMutex;
- size_t fRamBudget;
- size_t fRamUsed;
-
- /**
- * Find the CachedPixels represented by ID, or NULL if not in the cache. Mutex must be locked
- * before calling.
- */
- CachedPixels* findByID(ID) const;
-
- /**
- * If over budget, throw away pixels which are not currently in use until below budget or there
- * are no more pixels eligible to be thrown away. Mutex must be locked before calling.
- */
- void purgeIfNeeded();
-
- /**
- * Purge until below limit. Mutex must be locked before calling.
- */
- void purgeTilAtOrBelow(size_t limit);
-
- /**
- * Remove a set of CachedPixels. Mutex must be locked before calling.
- */
- void removePixels(CachedPixels*);
-};
-
-#endif // SkLruImageCache_DEFINED
diff --git a/lazy/SkPurgeableImageCache.h b/lazy/SkPurgeableImageCache.h
deleted file mode 100644
index 24525b0..0000000
--- a/lazy/SkPurgeableImageCache.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkPurgeableImageCache_DEFINED
-#define SkPurgeableImageCache_DEFINED
-
-#include "SkImageCache.h"
-
-#ifdef SK_DEBUG
- #include "SkTDArray.h"
-#endif
-
-/**
- * Implementation for SkImageCache that uses system defined purgeable memory.
- */
-class SkPurgeableImageCache : public SkImageCache {
-
-public:
- SK_DECLARE_INST_COUNT(SkPurgeableImageCache)
-
- static SkImageCache* Create();
-
- virtual void* allocAndPinCache(size_t bytes, ID*) SK_OVERRIDE;
- virtual void* pinCache(ID, SkImageCache::DataStatus*) SK_OVERRIDE;
- virtual void releaseCache(ID) SK_OVERRIDE;
- virtual void throwAwayCache(ID) SK_OVERRIDE;
-
-#ifdef SK_DEBUG
- virtual MemoryStatus getMemoryStatus(ID) const SK_OVERRIDE;
- virtual void purgeAllUnpinnedCaches() SK_OVERRIDE;
- virtual ~SkPurgeableImageCache();
-#endif
-
-private:
- SkPurgeableImageCache();
-
-#ifdef SK_DEBUG
- SkTDArray<ID> fRecs;
- int findRec(ID) const;
-#endif
- void removeRec(ID);
-};
-#endif // SkPurgeableImageCache_DEFINED
diff --git a/ports/SkFontConfigInterface.h b/ports/SkFontConfigInterface.h
index 661c3be..8c12a56 100644
--- a/ports/SkFontConfigInterface.h
+++ b/ports/SkFontConfigInterface.h
@@ -106,6 +106,7 @@
SkTArray<FontIdentity>*) {
return false;
}
+ typedef SkRefCnt INHERITED;
};
#endif
diff --git a/ports/SkFontMgr.h b/ports/SkFontMgr.h
index accb0c5..97ae2f1 100644
--- a/ports/SkFontMgr.h
+++ b/ports/SkFontMgr.h
@@ -105,7 +105,6 @@
virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0;
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0;
- // TODO: make this pure-virtual once all ports know about it
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
unsigned styleBits) = 0;
private:
diff --git a/utils/SkCondVar.h b/utils/SkCondVar.h
index 15f16e6..861a2ab 100644
--- a/utils/SkCondVar.h
+++ b/utils/SkCondVar.h
@@ -11,7 +11,7 @@
#ifdef SK_USE_POSIX_THREADS
#include <pthread.h>
#elif defined(SK_BUILD_FOR_WIN32)
-#include <Windows.h>
+#include <windows.h>
#endif
/**
diff --git a/utils/SkJSONCPP.h b/utils/SkJSONCPP.h
new file mode 100644
index 0000000..8dbb40c
--- /dev/null
+++ b/utils/SkJSONCPP.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * A common place to put the jsoncpp library includes, as opposed to littering
+ * the pragmas repeatedly through our code.
+ */
+#ifndef SkJSONCPP_DEFINED
+#define SkJSONCPP_DEFINED
+
+#ifdef SK_BUILD_FOR_WIN
+ // json includes xlocale which generates warning 4530 because we're
+ // compiling without exceptions;
+ // see https://code.google.com/p/skia/issues/detail?id=1067
+ #pragma warning(push)
+ #pragma warning(disable : 4530)
+#endif
+#include "json/reader.h"
+#include "json/value.h"
+#ifdef SK_BUILD_FOR_WIN
+ #pragma warning(pop)
+#endif
+
+#endif
diff --git a/utils/SkWGL.h b/utils/SkWGL.h
index 6803e03..5f630a1 100644
--- a/utils/SkWGL.h
+++ b/utils/SkWGL.h
@@ -27,7 +27,7 @@
#define WIN32_LEAN_AND_MEAN
#define SK_LOCAL_LEAN_AND_MEAN
#endif
-#include <Windows.h>
+#include <windows.h>
#if defined(SK_LOCAL_LEAN_AND_MEAN)
#undef WIN32_LEAN_AND_MEAN
#undef SK_LOCAL_LEAN_AND_MEAN
diff --git a/utils/win/SkAutoCoInitialize.h b/utils/win/SkAutoCoInitialize.h
index 709fa6b..f671e68 100644
--- a/utils/win/SkAutoCoInitialize.h
+++ b/utils/win/SkAutoCoInitialize.h
@@ -11,7 +11,7 @@
#define SkAutoCo_DEFINED
#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
+#include <windows.h>
#include "SkTemplates.h"
/**
diff --git a/utils/win/SkIStream.h b/utils/win/SkIStream.h
index e4e045c..deb3f3b 100644
--- a/utils/win/SkIStream.h
+++ b/utils/win/SkIStream.h
@@ -11,7 +11,7 @@
#define SkIStream_DEFINED
#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
+#include <windows.h>
#include <ole2.h>
class SkStream;
diff --git a/views/SkOSWindow_Android.h b/views/SkOSWindow_Android.h
index 77c156c..ae4e880 100644
--- a/views/SkOSWindow_Android.h
+++ b/views/SkOSWindow_Android.h
@@ -29,12 +29,7 @@
int fStencilBits;
};
- bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */, AttachmentInfo* info) {
- // These are the values requested in SkiaSampleView.java
- info->fSampleCount = 0;
- info->fStencilBits = 8;
- return true;
- }
+ bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info);
void detach() {}
void present() {}