diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2014-05-02 17:30:43 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2014-05-02 17:30:43 +0000 |
commit | f1b4bc491030b76963a3380a90d5aa0dac4ca279 (patch) | |
tree | 52f694d3334bedaef7fb91d00beaca766403a3d3 | |
parent | 0ffbc548eea1f2bace29697d3e9040a9f8daa521 (diff) | |
parent | 131e138f57d72cde1c1549ba33301b2d5ea5c3e9 (diff) | |
download | include-f1b4bc491030b76963a3380a90d5aa0dac4ca279.tar.gz |
Merge third_party/skia/include from https://chromium.googlesource.com/external/skia/include.git at 131e138f57d72cde1c1549ba33301b2d5ea5c3e9
This commit was generated by merge_from_chromium.py.
Change-Id: If6ea7da1269c010f39fb719fc1fb2a3f5511269e
-rw-r--r-- | core/SkColorShader.h | 8 | ||||
-rw-r--r-- | core/SkComposeShader.h | 9 | ||||
-rw-r--r-- | core/SkEmptyShader.h | 6 | ||||
-rw-r--r-- | core/SkShader.h | 28 | ||||
-rw-r--r-- | core/SkXfermode.h | 52 | ||||
-rw-r--r-- | effects/SkBlurMaskFilter.h | 6 | ||||
-rw-r--r-- | effects/SkPerlinNoiseShader.h | 7 | ||||
-rw-r--r-- | effects/SkTransparentShader.h | 6 | ||||
-rw-r--r-- | utils/SkThreadPool.h | 25 |
9 files changed, 59 insertions, 88 deletions
diff --git a/core/SkColorShader.h b/core/SkColorShader.h index 9e19a71..f993959 100644 --- a/core/SkColorShader.h +++ b/core/SkColorShader.h @@ -27,10 +27,7 @@ public: virtual bool isOpaque() const SK_OVERRIDE; - virtual SkShader::Context* createContext(const SkBitmap& device, - const SkPaint& paint, - const SkMatrix& matrix, - void* storage) const SK_OVERRIDE; + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE { return sizeof(ColorShaderContext); @@ -38,8 +35,7 @@ public: class ColorShaderContext : public SkShader::Context { public: - ColorShaderContext(const SkColorShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + ColorShaderContext(const SkColorShader& shader, const ContextRec&); virtual uint32_t getFlags() const SK_OVERRIDE; virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; diff --git a/core/SkComposeShader.h b/core/SkComposeShader.h index d42da0c..ac3c32b 100644 --- a/core/SkComposeShader.h +++ b/core/SkComposeShader.h @@ -34,18 +34,15 @@ public: SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); virtual ~SkComposeShader(); - virtual bool validContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE; - virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, void*) const SK_OVERRIDE; + virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE; + virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class ComposeShaderContext : public SkShader::Context { public: // When this object gets destroyed, it will call contextA and contextB's destructor // but it will NOT free the memory. - ComposeShaderContext(const SkComposeShader&, const SkBitmap&, - const SkPaint&, const SkMatrix&, + ComposeShaderContext(const SkComposeShader&, const ContextRec&, SkShader::Context* contextA, SkShader::Context* contextB); SkShader::Context* getShaderContextA() const { return fShaderContextA; } diff --git a/core/SkEmptyShader.h b/core/SkEmptyShader.h index 7494eff..d1a067f 100644 --- a/core/SkEmptyShader.h +++ b/core/SkEmptyShader.h @@ -27,13 +27,11 @@ public: return sizeof(SkShader::Context); } - virtual bool validContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE { + virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE { return false; } - virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, void*) const SK_OVERRIDE { + virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_OVERRIDE { // validContext returns false. return NULL; } diff --git a/core/SkShader.h b/core/SkShader.h index b0a7fd9..32707d7 100644 --- a/core/SkShader.h +++ b/core/SkShader.h @@ -119,10 +119,26 @@ public: */ virtual bool isOpaque() const { return false; } + /** + * ContextRec acts as a parameter bundle for creating Contexts. + */ + struct ContextRec { + ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL) {} + ContextRec(const ContextRec& other) + : fDevice(other.fDevice), fPaint(other.fPaint), fMatrix(other.fMatrix) {} + ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) + : fDevice(&device) + , fPaint(&paint) + , fMatrix(&matrix) {} + + const SkBitmap* fDevice; // the bitmap we are drawing into + const SkPaint* fPaint; // the current paint associated with the draw + const SkMatrix* fMatrix; // the current matrix in the canvas + }; + class Context : public ::SkNoncopyable { public: - Context(const SkShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + Context(const SkShader& shader, const ContextRec&); virtual ~Context(); @@ -200,8 +216,7 @@ public: * Subclasses should be sure to call their INHERITED::validContext() if * they override this method. */ - virtual bool validContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, SkMatrix* totalInverse = NULL) const; + virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const; /** * Create the actual object that does the shading. @@ -211,10 +226,7 @@ public: * * Base class implementation returns NULL. */ - virtual Context* createContext(const SkBitmap& device, - const SkPaint& paint, - const SkMatrix& matrix, - void* storage) const; + virtual Context* createContext(const ContextRec&, void* storage) const; /** * Return the size of a Context returned by createContext. diff --git a/core/SkXfermode.h b/core/SkXfermode.h index 9bad1e8..88f3f62 100644 --- a/core/SkXfermode.h +++ b/core/SkXfermode.h @@ -17,8 +17,6 @@ class GrEffectRef; class GrTexture; class SkString; -//#define SK_SUPPORT_LEGACY_PROCXFERMODE - /** \class SkXfermode * * SkXfermode is the base class for objects that are called to implement custom @@ -246,54 +244,4 @@ private: typedef SkFlattenable INHERITED; }; -/////////////////////////////////////////////////////////////////////////////// - -#ifdef SK_SUPPORT_LEGACY_PROCXFERMODE -/** \class SkProcXfermode - - SkProcXfermode is a xfermode that applies the specified proc to its colors. - This class is not exported to java. -*/ -class SK_API SkProcXfermode : public SkXfermode { -public: - static SkProcXfermode* Create(SkXfermodeProc proc) { - return SkNEW_ARGS(SkProcXfermode, (proc)); - } - - // overrides from SkXfermode - virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, - const SkAlpha aa[]) const SK_OVERRIDE; - virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, - const SkAlpha aa[]) const SK_OVERRIDE; - virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, - const SkAlpha aa[]) const SK_OVERRIDE; - - SK_TO_STRING_OVERRIDE() - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) - -protected: - SkProcXfermode(SkReadBuffer&); - virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; - - // allow subclasses to update this after we unflatten - void setProc(SkXfermodeProc proc) { - fProc = proc; - } - - SkXfermodeProc getProc() const { - return fProc; - } - -#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS -public: -#endif - SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} - -private: - SkXfermodeProc fProc; - - typedef SkXfermode INHERITED; -}; -#endif - #endif diff --git a/effects/SkBlurMaskFilter.h b/effects/SkBlurMaskFilter.h index ddb163e..5fcf463 100644 --- a/effects/SkBlurMaskFilter.h +++ b/effects/SkBlurMaskFilter.h @@ -26,6 +26,12 @@ public: }; #endif + /** + * If radius > 0, return the corresponding sigma, else return 0. Use this to convert from the + * (legacy) idea of specify the blur "radius" to the standard notion of specifying its sigma. + */ + static SkScalar ConvertRadiusToSigma(SkScalar radius); + enum BlurFlags { kNone_BlurFlag = 0x00, /** The blur layer's radius is not affected by transforms */ diff --git a/effects/SkPerlinNoiseShader.h b/effects/SkPerlinNoiseShader.h index 5b27029..2766df0 100644 --- a/effects/SkPerlinNoiseShader.h +++ b/effects/SkPerlinNoiseShader.h @@ -72,15 +72,12 @@ public: } - virtual SkShader::Context* createContext( - const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, void* storage) const SK_OVERRIDE; + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class PerlinNoiseShaderContext : public SkShader::Context { public: - PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const ContextRec&); virtual ~PerlinNoiseShaderContext() {} virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; diff --git a/effects/SkTransparentShader.h b/effects/SkTransparentShader.h index 790e5ae..55513eb 100644 --- a/effects/SkTransparentShader.h +++ b/effects/SkTransparentShader.h @@ -14,15 +14,13 @@ class SK_API SkTransparentShader : public SkShader { public: SkTransparentShader() {} - virtual SkShader::Context* createContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, void* storage) const + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class TransparentShaderContext : public SkShader::Context { public: - TransparentShaderContext(const SkTransparentShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + TransparentShaderContext(const SkTransparentShader& shader, const ContextRec&); virtual ~TransparentShaderContext(); virtual uint32_t getFlags() const SK_OVERRIDE; diff --git a/utils/SkThreadPool.h b/utils/SkThreadPool.h index a75bed8..295b1b4 100644 --- a/utils/SkThreadPool.h +++ b/utils/SkThreadPool.h @@ -50,6 +50,11 @@ public: void add(SkTRunnable<T>*); /** + * Same as add, but adds the runnable as the very next to run rather than enqueueing it. + */ + void addNext(SkTRunnable<T>*); + + /** * Block until all added SkRunnables have completed. Once called, calling add() is undefined. */ void wait(); @@ -66,6 +71,9 @@ public: kHalting_State, // There's no work to do and no thread is busy. All threads can shut down. }; + void addSomewhere(SkTRunnable<T>* r, + void (SkTInternalLList<LinkedRunnable>::*)(LinkedRunnable*)); + SkTInternalLList<LinkedRunnable> fQueue; SkCondVar fReady; SkTDArray<SkThread*> fThreads; @@ -111,7 +119,8 @@ struct ThreadLocal<void> { } // namespace SkThreadPoolPrivate template <typename T> -void SkTThreadPool<T>::add(SkTRunnable<T>* r) { +void SkTThreadPool<T>::addSomewhere(SkTRunnable<T>* r, + void (SkTInternalLList<LinkedRunnable>::* f)(LinkedRunnable*)) { if (r == NULL) { return; } @@ -126,11 +135,21 @@ void SkTThreadPool<T>::add(SkTRunnable<T>* r) { linkedRunnable->fRunnable = r; fReady.lock(); SkASSERT(fState != kHalting_State); // Shouldn't be able to add work when we're halting. - fQueue.addToHead(linkedRunnable); + (fQueue.*f)(linkedRunnable); fReady.signal(); fReady.unlock(); } +template <typename T> +void SkTThreadPool<T>::add(SkTRunnable<T>* r) { + this->addSomewhere(r, &SkTInternalLList<LinkedRunnable>::addToTail); +} + +template <typename T> +void SkTThreadPool<T>::addNext(SkTRunnable<T>* r) { + this->addSomewhere(r, &SkTInternalLList<LinkedRunnable>::addToHead); +} + template <typename T> void SkTThreadPool<T>::wait() { @@ -174,7 +193,7 @@ template <typename T> // We've got the lock back here, no matter if we ran wait or not. // The queue is not empty, so we have something to run. Claim it. - LinkedRunnable* r = pool->fQueue.tail(); + LinkedRunnable* r = pool->fQueue.head(); pool->fQueue.remove(r); |