summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Chromium Automerger <chromium-automerger@android>2013-12-06 13:31:09 +0000
committerAndroid Chromium Automerger <chromium-automerger@android>2013-12-06 13:31:09 +0000
commit4c9cd2dca651afa7717687d832d78ecff44ac79d (patch)
tree7db402854c76ed831f2c8724eea780a306077ba1
parent4791088afac95d948feace84b0bd3c9c84667ceb (diff)
parent69fc44a602f761d53b397a06ff6a5e86d824c134 (diff)
downloadinclude-4c9cd2dca651afa7717687d832d78ecff44ac79d.tar.gz
Merge third_party/skia/include from https://chromium.googlesource.com/external/skia/include.git at 69fc44a602f761d53b397a06ff6a5e86d824c134
This commit was generated by merge_from_chromium.py. Change-Id: I3360b758273ed6d482786c7053812c16bf9b3c54
-rw-r--r--core/SkCanvas.h5
-rw-r--r--core/SkImageDecoder.h18
-rw-r--r--core/SkInstCnt.h92
-rw-r--r--core/SkShader.h3
-rw-r--r--lazy/SkBitmapFactory.h99
-rw-r--r--lazy/SkImageCache.h132
-rw-r--r--lazy/SkLruImageCache.h91
-rw-r--r--lazy/SkPurgeableImageCache.h47
-rw-r--r--ports/SkFontConfigInterface.h1
9 files changed, 68 insertions, 420 deletions
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 @@ public:
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/SkImageDecoder.h b/core/SkImageDecoder.h
index b255e2a..43950ad 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"
@@ -336,6 +335,21 @@ public:
}
/**
+ * Struct containing information about a pixel destination.
+ */
+ struct Target {
+ /**
+ * Pre-allocated memory.
+ */
+ void* fAddr;
+
+ /**
+ * Rowbytes of the allocated memory.
+ */
+ size_t fRowBytes;
+ };
+
+ /**
* Decode memory.
* @param info Output parameter. Returns info about the encoded image.
* @param target Contains the address of pixel memory to decode into
@@ -360,7 +374,7 @@ public:
* </code>
*/
static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImageInfo* info,
- const SkBitmapFactory::Target* target);
+ const Target* target);
/** 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/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 @@ extern bool gPrintInstCount;
// 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* GetInstanceCountPtr() { \
+ static int32_t gInstanceCount; \
+ return &gInstanceCount; \
+ } \
+ \
+ static SkTArray<PFCheckInstCnt>*& GetChildren() { \
+ static SkTArray<PFCheckInstCnt>* gChildren; \
+ return gChildren; \
} \
\
- static int32_t gInstanceCount; \
- static bool gInited; \
- static SkTArray<PFCheckInstCnt>* gChildren; \
} fInstanceCountHelper; \
\
static int32_t GetInstanceCount() { \
- return SkInstanceCountHelper::gInstanceCount; \
+ return *SkInstanceCountHelper::GetInstanceCountPtr(); \
} \
\
static void exitPrint() { \
@@ -77,57 +78,50 @@ extern bool gPrintInstCount;
} \
\
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/SkShader.h b/core/SkShader.h
index 11956ce..cdb7a2f 100644
--- a/core/SkShader.h
+++ b/core/SkShader.h
@@ -334,6 +334,9 @@ public:
* 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/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 @@ public:
SkTArray<FontIdentity>*) {
return false;
}
+ typedef SkRefCnt INHERITED;
};
#endif