summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Chromium Automerger <chromium-automerger@android>2014-04-23 19:28:45 +0000
committerAndroid Chromium Automerger <chromium-automerger@android>2014-04-23 19:28:45 +0000
commit575a5f0136a5228c5e0d576e4bc17ef59774efae (patch)
treeddf8d094ec0c1a94e87f2c8717d4395ddac97385
parentf499466a7686b0b01b8b153adfb0b7f06ae879ae (diff)
parentcfb32ead7d0bd08495f48486156ee9bc98045e69 (diff)
downloadinclude-575a5f0136a5228c5e0d576e4bc17ef59774efae.tar.gz
Merge third_party/skia/include from https://chromium.googlesource.com/external/skia/include.git at cfb32ead7d0bd08495f48486156ee9bc98045e69
This commit was generated by merge_from_chromium.py. Change-Id: I3caea84e92840296b200522d654caeaa725022a5
-rw-r--r--core/SkBBHFactory.h8
-rw-r--r--core/SkCanvas.h29
-rw-r--r--core/SkColorShader.h41
-rw-r--r--core/SkComposeShader.h37
-rw-r--r--core/SkEmptyShader.h26
-rw-r--r--core/SkPathEffect.h27
-rw-r--r--core/SkPicture.h3
-rw-r--r--core/SkShader.h167
-rw-r--r--effects/SkDashPathEffect.h5
-rw-r--r--effects/SkPerlinNoiseShader.h40
-rw-r--r--effects/SkTransparentShader.h30
-rw-r--r--utils/SkDeferredCanvas.h22
-rw-r--r--utils/SkDumpCanvas.h18
-rw-r--r--utils/SkLuaCanvas.h18
-rw-r--r--utils/SkNWayCanvas.h18
-rw-r--r--utils/SkProxyCanvas.h18
-rw-r--r--utils/mac/SkCGUtils.h19
17 files changed, 336 insertions, 190 deletions
diff --git a/core/SkBBHFactory.h b/core/SkBBHFactory.h
index bd85d94..4c03844 100644
--- a/core/SkBBHFactory.h
+++ b/core/SkBBHFactory.h
@@ -13,7 +13,7 @@
class SkBBoxHierarchy;
-class SkBBHFactory {
+class SK_API SkBBHFactory {
public:
/**
* Allocate a new SkBBoxHierarchy. Return NULL on failure.
@@ -22,7 +22,7 @@ public:
virtual ~SkBBHFactory() {};
};
-class SkQuadTreeFactory : public SkBBHFactory {
+class SK_API SkQuadTreeFactory : public SkBBHFactory {
public:
virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
private:
@@ -30,14 +30,14 @@ private:
};
-class SkRTreeFactory : public SkBBHFactory {
+class SK_API SkRTreeFactory : public SkBBHFactory {
public:
virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
private:
typedef SkBBHFactory INHERITED;
};
-class SkTileGridFactory : public SkBBHFactory {
+class SK_API SkTileGridFactory : public SkBBHFactory {
public:
struct TileGridInfo {
/** Tile placement interval */
diff --git a/core/SkCanvas.h b/core/SkCanvas.h
index 0a81969..91fb642 100644
--- a/core/SkCanvas.h
+++ b/core/SkCanvas.h
@@ -26,6 +26,13 @@
//#define SK_SUPPORT_LEGACY_GETTOTALCLIP
//#define SK_SUPPORT_LEGACY_GETTOPDEVICE
+//#define SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
+#ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
+ #define SK_LEGACY_DRAWTEXT_VIRTUAL virtual
+#else
+ #define SK_LEGACY_DRAWTEXT_VIRTUAL
+#endif
+
class SkBounder;
class SkBaseDevice;
class SkDraw;
@@ -868,7 +875,7 @@ public:
@param y The y-coordinate of the origin of the text being drawn
@param paint The paint used for the text (e.g. color, size, style)
*/
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
+ SK_LEGACY_DRAWTEXT_VIRTUAL void drawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, const SkPaint& paint);
/** Draw the text, with each character/glyph origin specified by the pos[]
@@ -878,7 +885,7 @@ public:
@param pos Array of positions, used to position each character
@param paint The paint used for the text (e.g. color, size, style)
*/
- virtual void drawPosText(const void* text, size_t byteLength,
+ SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint);
/** Draw the text, with each character/glyph origin specified by the x
@@ -890,7 +897,7 @@ public:
@param constY The shared Y coordinate for all of the positions
@param paint The paint used for the text (e.g. color, size, style)
*/
- virtual void drawPosTextH(const void* text, size_t byteLength,
+ SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint);
@@ -920,7 +927,7 @@ public:
mapped onto the path
@param paint The paint used for the text
*/
- virtual void drawTextOnPath(const void* text, size_t byteLength,
+ SK_LEGACY_DRAWTEXT_VIRTUAL void drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint);
@@ -1186,6 +1193,20 @@ protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x,
+ SkScalar y, const SkPaint& paint);
+
+ virtual void onDrawPosText(const void* text, size_t byteLength,
+ const SkPoint pos[], const SkPaint& paint);
+
+ virtual void onDrawPosTextH(const void* text, size_t byteLength,
+ const SkScalar xpos[], SkScalar constY,
+ const SkPaint& paint);
+
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength,
+ const SkPath& path, const SkMatrix* matrix,
+ const SkPaint& paint);
+
enum ClipEdgeStyle {
kHard_ClipEdgeStyle,
kSoft_ClipEdgeStyle
diff --git a/core/SkColorShader.h b/core/SkColorShader.h
index 975156c..56e5add 100644
--- a/core/SkColorShader.h
+++ b/core/SkColorShader.h
@@ -30,16 +30,35 @@ public:
*/
SkColorShader(SkColor c);
- virtual ~SkColorShader();
-
- virtual uint32_t getFlags() SK_OVERRIDE;
- virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
virtual bool isOpaque() const SK_OVERRIDE;
- virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix) SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
- virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
+
+ virtual SkShader::Context* createContext(const SkBitmap& device,
+ const SkPaint& paint,
+ const SkMatrix& matrix,
+ void* storage) const SK_OVERRIDE;
+
+ virtual size_t contextSize() const SK_OVERRIDE {
+ return sizeof(ColorShaderContext);
+ }
+
+ class ColorShaderContext : public SkShader::Context {
+ public:
+ ColorShaderContext(const SkColorShader& shader, const SkBitmap& device,
+ const SkPaint& paint, const SkMatrix& matrix);
+
+ virtual uint32_t getFlags() const SK_OVERRIDE;
+ virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
+ virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
+ virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+ virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
+
+ private:
+ SkPMColor fPMColor;
+ uint32_t fFlags;
+ uint16_t fColor16;
+
+ typedef SkShader::Context INHERITED;
+ };
// we return false for this, use asAGradient
virtual BitmapType asABitmap(SkBitmap* outTexture,
@@ -56,11 +75,7 @@ protected:
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
-
SkColor fColor; // ignored if fInheritColor is true
- SkPMColor fPMColor; // cached after setContext()
- uint32_t fFlags; // cached after setContext()
- uint16_t fColor16; // cached after setContext()
SkBool8 fInheritColor;
typedef SkShader INHERITED;
diff --git a/core/SkComposeShader.h b/core/SkComposeShader.h
index b54e5ef..d42da0c 100644
--- a/core/SkComposeShader.h
+++ b/core/SkComposeShader.h
@@ -34,10 +34,38 @@ public:
SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
virtual ~SkComposeShader();
- virtual bool setContext(const SkBitmap&, const SkPaint&,
- const SkMatrix&) SK_OVERRIDE;
- virtual void endContext() SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ 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 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&,
+ SkShader::Context* contextA, SkShader::Context* contextB);
+
+ SkShader::Context* getShaderContextA() const { return fShaderContextA; }
+ SkShader::Context* getShaderContextB() const { return fShaderContextB; }
+
+ virtual ~ComposeShaderContext();
+
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+
+ private:
+ SkShader::Context* fShaderContextA;
+ SkShader::Context* fShaderContextB;
+
+ typedef SkShader::Context INHERITED;
+ };
+
+#ifdef SK_DEBUG
+ SkShader* getShaderA() { return fShaderA; }
+ SkShader* getShaderB() { return fShaderB; }
+#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
@@ -47,7 +75,6 @@ protected:
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
-
SkShader* fShaderA;
SkShader* fShaderB;
SkXfermode* fMode;
diff --git a/core/SkEmptyShader.h b/core/SkEmptyShader.h
index d2ebb61..7494eff 100644
--- a/core/SkEmptyShader.h
+++ b/core/SkEmptyShader.h
@@ -15,20 +15,28 @@
/**
* \class SkEmptyShader
- * A Shader that always draws nothing. Its setContext always returns false,
- * so it never expects that its shadeSpan() methods will get called.
+ * A Shader that always draws nothing. Its createContext always returns NULL.
*/
class SK_API SkEmptyShader : public SkShader {
public:
SkEmptyShader() {}
- virtual uint32_t getFlags() SK_OVERRIDE;
- virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
- virtual bool setContext(const SkBitmap&, const SkPaint&,
- const SkMatrix&) SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
- virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
+ virtual size_t contextSize() const SK_OVERRIDE {
+ // Even though createContext returns NULL we have to return a value of at least
+ // sizeof(SkShader::Context) to satisfy SkSmallAllocator.
+ return sizeof(SkShader::Context);
+ }
+
+ virtual bool validContext(const SkBitmap&, const SkPaint&,
+ const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE {
+ return false;
+ }
+
+ virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&,
+ const SkMatrix&, void*) const SK_OVERRIDE {
+ // validContext returns false.
+ return NULL;
+ }
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
diff --git a/core/SkPathEffect.h b/core/SkPathEffect.h
index 86ccf86..638287d 100644
--- a/core/SkPathEffect.h
+++ b/core/SkPathEffect.h
@@ -104,6 +104,33 @@ public:
const SkStrokeRec&, const SkMatrix&,
const SkRect* cullR) const;
+ /**
+ * If the PathEffect can be represented as a dash pattern, asADash will return kDash_DashType
+ * and None otherwise. If a non NULL info is passed in, the various DashInfo will be filled
+ * in if the PathEffect can be a dash pattern. If passed in info has an fCount equal or
+ * greater to that of the effect, it will memcpy the values of the dash intervals into the
+ * info. Thus the general approach will be call asADash once with default info to get DashType
+ * and fCount. If effect can be represented as a dash pattern, allocate space for the intervals
+ * in info, then call asADash again with the same info and the intervals will get copied in.
+ */
+
+ enum DashType {
+ kNone_DashType, //!< ignores the info parameter
+ kDash_DashType, //!< fills in all of the info parameter
+ };
+
+ struct DashInfo {
+ DashInfo() : fIntervals(NULL), fCount(0), fPhase(0) {}
+
+ SkScalar* fIntervals; //!< Length of on/off intervals for dashed lines
+ // Even values represent ons, and odds offs
+ int32_t fCount; //!< Number of intervals in the dash. Should be even number
+ SkScalar fPhase; //!< Offset into the dashed interval pattern
+ // mod the sum of all intervals
+ };
+
+ virtual DashType asADash(DashInfo* info) const;
+
SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
protected:
diff --git a/core/SkPicture.h b/core/SkPicture.h
index bf9ec4f..996d857 100644
--- a/core/SkPicture.h
+++ b/core/SkPicture.h
@@ -324,13 +324,14 @@ protected:
// V22: SK_PICT_FACTORY_TAG's size is now the chunk size in bytes
// V23: SkPaint::FilterLevel became a real enum
// V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping
+ // V25: SkDashPathEffect now only writes phase and interval array when flattening
// Note: If the picture version needs to be increased then please follow the
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
// Only SKPs within the min/current picture version range (inclusive) can be read.
static const uint32_t MIN_PICTURE_VERSION = 19;
- static const uint32_t CURRENT_PICTURE_VERSION = 24;
+ static const uint32_t CURRENT_PICTURE_VERSION = 25;
mutable uint32_t fUniqueID;
diff --git a/core/SkShader.h b/core/SkShader.h
index 6566e69..cc2cc75 100644
--- a/core/SkShader.h
+++ b/core/SkShader.h
@@ -38,7 +38,7 @@ public:
virtual ~SkShader();
/**
- * Returns true if the local matrix is not an identity matrix.
+ * Returns true if the local matrix is not an identity matrix.
*/
bool hasLocalMatrix() const { return !fLocalMatrix.isIdentity(); }
@@ -96,7 +96,7 @@ public:
*/
kIntrinsicly16_Flag = 0x04,
- /** set (after setContext) if the spans only vary in X (const in Y).
+ /** set if the spans only vary in X (const in Y).
e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient
that varies from left-to-right. This flag specifies this for
shadeSpan().
@@ -112,84 +112,111 @@ public:
};
/**
- * Called sometimes before drawing with this shader. Return the type of
- * alpha your shader will return. The default implementation returns 0.
- * Your subclass should override if it can (even sometimes) report a
- * non-zero value, since that will enable various blitters to perform
- * faster.
- */
- virtual uint32_t getFlags() { return 0; }
-
- /**
* Returns true if the shader is guaranteed to produce only opaque
* colors, subject to the SkPaint using the shader to apply an opaque
* alpha value. Subclasses should override this to allow some
- * optimizations. isOpaque() can be called at any time, unlike getFlags,
- * which only works properly when the context is set.
+ * optimizations.
*/
virtual bool isOpaque() const { return false; }
- /**
- * Return the alpha associated with the data returned by shadeSpan16(). If
- * kHasSpan16_Flag is not set, this value is meaningless.
- */
- virtual uint8_t getSpan16Alpha() const { return fPaintAlpha; }
+ class Context : public ::SkNoncopyable {
+ public:
+ Context(const SkShader& shader, const SkBitmap& device,
+ const SkPaint& paint, const SkMatrix& matrix);
- /**
- * Called once before drawing, with the current paint and device matrix.
- * Return true if your shader supports these parameters, or false if not.
- * If false is returned, nothing will be drawn. If true is returned, then
- * a balancing call to endContext() will be made before the next call to
- * setContext.
- *
- * Subclasses should be sure to call their INHERITED::setContext() if they
- * override this method.
- */
- virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix);
+ virtual ~Context();
- /**
- * Assuming setContext returned true, endContext() will be called when
- * the draw using the shader has completed. It is an error for setContext
- * to be called twice w/o an intervening call to endContext().
- *
- * Subclasses should be sure to call their INHERITED::endContext() if they
- * override this method.
- */
- virtual void endContext();
+ /**
+ * Called sometimes before drawing with this shader. Return the type of
+ * alpha your shader will return. The default implementation returns 0.
+ * Your subclass should override if it can (even sometimes) report a
+ * non-zero value, since that will enable various blitters to perform
+ * faster.
+ */
+ virtual uint32_t getFlags() const { return 0; }
- SkDEBUGCODE(bool setContextHasBeenCalled() const { return SkToBool(fInSetContext); })
+ /**
+ * Return the alpha associated with the data returned by shadeSpan16(). If
+ * kHasSpan16_Flag is not set, this value is meaningless.
+ */
+ virtual uint8_t getSpan16Alpha() const { return fPaintAlpha; }
- /**
- * Called for each span of the object being drawn. Your subclass should
- * set the appropriate colors (with premultiplied alpha) that correspond
- * to the specified device coordinates.
- */
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
+ /**
+ * Called for each span of the object being drawn. Your subclass should
+ * set the appropriate colors (with premultiplied alpha) that correspond
+ * to the specified device coordinates.
+ */
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
+
+ typedef void (*ShadeProc)(void* ctx, int x, int y, SkPMColor[], int count);
+ virtual ShadeProc asAShadeProc(void** ctx);
+
+ /**
+ * Called only for 16bit devices when getFlags() returns
+ * kOpaqueAlphaFlag | kHasSpan16_Flag
+ */
+ virtual void shadeSpan16(int x, int y, uint16_t[], int count);
+
+ /**
+ * Similar to shadeSpan, but only returns the alpha-channel for a span.
+ * The default implementation calls shadeSpan() and then extracts the alpha
+ * values from the returned colors.
+ */
+ virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
- typedef void (*ShadeProc)(void* ctx, int x, int y, SkPMColor[], int count);
- virtual ShadeProc asAShadeProc(void** ctx);
+ /**
+ * Helper function that returns true if this shader's shadeSpan16() method
+ * can be called.
+ */
+ bool canCallShadeSpan16() {
+ return SkShader::CanCallShadeSpan16(this->getFlags());
+ }
+
+ protected:
+ // Reference to shader, so we don't have to dupe information.
+ const SkShader& fShader;
+
+ enum MatrixClass {
+ kLinear_MatrixClass, // no perspective
+ kFixedStepInX_MatrixClass, // fast perspective, need to call fixedStepInX() each
+ // scanline
+ kPerspective_MatrixClass // slow perspective, need to mappoints each pixel
+ };
+ static MatrixClass ComputeMatrixClass(const SkMatrix&);
+
+ uint8_t getPaintAlpha() const { return fPaintAlpha; }
+ const SkMatrix& getTotalInverse() const { return fTotalInverse; }
+ MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
+
+ private:
+ SkMatrix fTotalInverse;
+ uint8_t fPaintAlpha;
+ uint8_t fTotalInverseClass;
+
+ typedef SkNoncopyable INHERITED;
+ };
/**
- * Called only for 16bit devices when getFlags() returns
- * kOpaqueAlphaFlag | kHasSpan16_Flag
+ * Subclasses should be sure to call their INHERITED::validContext() if
+ * they override this method.
*/
- virtual void shadeSpan16(int x, int y, uint16_t[], int count);
+ virtual bool validContext(const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix, SkMatrix* totalInverse = NULL) const;
/**
- * Similar to shadeSpan, but only returns the alpha-channel for a span.
- * The default implementation calls shadeSpan() and then extracts the alpha
- * values from the returned colors.
+ * Create the actual object that does the shading.
+ * Returns NULL if validContext() returns false.
+ * Size of storage must be >= contextSize.
*/
- virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
+ virtual Context* createContext(const SkBitmap& device,
+ const SkPaint& paint,
+ const SkMatrix& matrix,
+ void* storage) const = 0;
/**
- * Helper function that returns true if this shader's shadeSpan16() method
- * can be called.
+ * Return the size of a Context returned by createContext.
*/
- bool canCallShadeSpan16() {
- return SkShader::CanCallShadeSpan16(this->getFlags());
- }
+ virtual size_t contextSize() const = 0;
/**
* Helper to check the flags to know if it is legal to call shadeSpan16()
@@ -322,7 +349,7 @@ public:
* The incoming color to the effect has r=g=b=a all extracted from the SkPaint's alpha.
* The output color should be the computed SkShader premul color modulated by the incoming
* color. The GrContext may be used by the effect to create textures. The GPU device does not
- * call setContext. Instead we pass the SkPaint here in case the shader needs paint info.
+ * call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
*/
virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) const;
@@ -362,26 +389,14 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
protected:
- enum MatrixClass {
- kLinear_MatrixClass, // no perspective
- kFixedStepInX_MatrixClass, // fast perspective, need to call fixedStepInX() each scanline
- kPerspective_MatrixClass // slow perspective, need to mappoints each pixel
- };
- static MatrixClass ComputeMatrixClass(const SkMatrix&);
-
- // These can be called by your subclass after setContext() has been called
- uint8_t getPaintAlpha() const { return fPaintAlpha; }
- const SkMatrix& getTotalInverse() const { return fTotalInverse; }
- MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
SkShader(SkReadBuffer& );
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+
private:
SkMatrix fLocalMatrix;
- SkMatrix fTotalInverse;
- uint8_t fPaintAlpha;
- uint8_t fTotalInverseClass;
- SkDEBUGCODE(SkBool8 fInSetContext;)
+
+ bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) const;
typedef SkFlattenable INHERITED;
};
diff --git a/effects/SkDashPathEffect.h b/effects/SkDashPathEffect.h
index 41f8f5a..f69e905 100644
--- a/effects/SkDashPathEffect.h
+++ b/effects/SkDashPathEffect.h
@@ -49,6 +49,8 @@ public:
const SkStrokeRec&, const SkMatrix&,
const SkRect*) const SK_OVERRIDE;
+ virtual DashType asADash(DashInfo* info) const SK_OVERRIDE;
+
virtual Factory getFactory() const SK_OVERRIDE;
static SkFlattenable* CreateProc(SkReadBuffer&);
@@ -63,8 +65,11 @@ public:
SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase);
private:
+ void setInternalMembers(SkScalar phase);
+
SkScalar* fIntervals;
int32_t fCount;
+ SkScalar fPhase;
// computed from phase
SkScalar fInitialDashLength;
int32_t fInitialDashIndex;
diff --git a/effects/SkPerlinNoiseShader.h b/effects/SkPerlinNoiseShader.h
index dfd5a8c..5b27029 100644
--- a/effects/SkPerlinNoiseShader.h
+++ b/effects/SkPerlinNoiseShader.h
@@ -72,10 +72,32 @@ public:
}
- virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix);
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRIDE;
+ virtual SkShader::Context* createContext(
+ const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix, 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);
+ virtual ~PerlinNoiseShaderContext() {}
+
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ virtual void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRIDE;
+
+ private:
+ SkPMColor shade(const SkPoint& point, StitchData& stitchData) const;
+ SkScalar calculateTurbulenceValueForPoint(
+ int channel, const PaintingData& paintingData,
+ StitchData& stitchData, const SkPoint& point) const;
+ SkScalar noise2D(int channel, const PaintingData& paintingData,
+ const StitchData& stitchData, const SkPoint& noiseVector) const;
+
+ SkMatrix fMatrix;
+
+ typedef SkShader::Context INHERITED;
+ };
virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
@@ -92,14 +114,6 @@ private:
const SkISize* tileSize);
virtual ~SkPerlinNoiseShader();
- SkScalar noise2D(int channel, const PaintingData& paintingData,
- const StitchData& stitchData, const SkPoint& noiseVector) const;
-
- SkScalar calculateTurbulenceValueForPoint(int channel, const PaintingData& paintingData,
- StitchData& stitchData, const SkPoint& point) const;
-
- SkPMColor shade(const SkPoint& point, StitchData& stitchData) const;
-
// TODO (scroggo): Once all SkShaders are created from a factory, and we have removed the
// constructor that creates SkPerlinNoiseShader from an SkReadBuffer, several fields can
// be made constant.
@@ -110,8 +124,6 @@ private:
/*const*/ SkScalar fSeed;
/*const*/ SkISize fTileSize;
/*const*/ bool fStitchTiles;
- // TODO (scroggo): Once setContext creates a new object, place this on that object.
- SkMatrix fMatrix;
PaintingData* fPaintingData;
diff --git a/effects/SkTransparentShader.h b/effects/SkTransparentShader.h
index 7428d44..790e5ae 100644
--- a/effects/SkTransparentShader.h
+++ b/effects/SkTransparentShader.h
@@ -14,21 +14,31 @@ class SK_API SkTransparentShader : public SkShader {
public:
SkTransparentShader() {}
- virtual uint32_t getFlags() SK_OVERRIDE;
- virtual bool setContext(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix) SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+ virtual SkShader::Context* createContext(const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix, 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);
+ virtual ~TransparentShaderContext();
+
+ virtual uint32_t getFlags() const SK_OVERRIDE;
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+
+ private:
+ const SkBitmap* fDevice;
+
+ typedef SkShader::Context INHERITED;
+ };
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTransparentShader)
private:
- // these are a cache from the call to setContext()
- const SkBitmap* fDevice;
- uint8_t fAlpha;
-
SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
typedef SkShader INHERITED;
diff --git a/utils/SkDeferredCanvas.h b/utils/SkDeferredCanvas.h
index e12cbf0..c4a41ca 100644
--- a/utils/SkDeferredCanvas.h
+++ b/utils/SkDeferredCanvas.h
@@ -162,17 +162,6 @@ public:
SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) SK_OVERRIDE;
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint)
- SK_OVERRIDE;
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) SK_OVERRIDE;
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) SK_OVERRIDE;
virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
@@ -190,8 +179,15 @@ protected:
virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
- virtual void onDrawDRRect(const SkRRect&, const SkRRect&,
- const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
diff --git a/utils/SkDumpCanvas.h b/utils/SkDumpCanvas.h
index b0b1847..6fc679b 100644
--- a/utils/SkDumpCanvas.h
+++ b/utils/SkDumpCanvas.h
@@ -90,16 +90,6 @@ public:
const SkPaint* paint) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) SK_OVERRIDE;
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) SK_OVERRIDE;
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) SK_OVERRIDE;
virtual void drawPicture(SkPicture&) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
@@ -120,6 +110,14 @@ protected:
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
diff --git a/utils/SkLuaCanvas.h b/utils/SkLuaCanvas.h
index 38e089e..3efbdb9 100644
--- a/utils/SkLuaCanvas.h
+++ b/utils/SkLuaCanvas.h
@@ -36,16 +36,6 @@ public:
const SkPaint* paint) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) SK_OVERRIDE;
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) SK_OVERRIDE;
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) SK_OVERRIDE;
virtual void drawPicture(SkPicture&) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
@@ -63,6 +53,14 @@ protected:
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
diff --git a/utils/SkNWayCanvas.h b/utils/SkNWayCanvas.h
index 051674b..60d5151 100644
--- a/utils/SkNWayCanvas.h
+++ b/utils/SkNWayCanvas.h
@@ -43,16 +43,6 @@ public:
const SkPaint* paint = NULL) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint*) SK_OVERRIDE;
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint&) SK_OVERRIDE;
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint&) SK_OVERRIDE;
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY,
- const SkPaint&) SK_OVERRIDE;
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint&) SK_OVERRIDE;
virtual void drawPicture(SkPicture&) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
@@ -79,6 +69,14 @@ protected:
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
diff --git a/utils/SkProxyCanvas.h b/utils/SkProxyCanvas.h
index 76426bd..8d8796c 100644
--- a/utils/SkProxyCanvas.h
+++ b/utils/SkProxyCanvas.h
@@ -42,16 +42,6 @@ public:
const SkPaint* paint = NULL) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint = NULL) SK_OVERRIDE;
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) SK_OVERRIDE;
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) SK_OVERRIDE;
virtual void drawPicture(SkPicture&) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
@@ -76,6 +66,14 @@ protected:
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
diff --git a/utils/mac/SkCGUtils.h b/utils/mac/SkCGUtils.h
index 54c858c..a0fe666 100644
--- a/utils/mac/SkCGUtils.h
+++ b/utils/mac/SkCGUtils.h
@@ -8,7 +8,8 @@
#ifndef SkCGUtils_DEFINED
#define SkCGUtils_DEFINED
-#include "SkTypes.h"
+#include "SkSize.h"
+#include "SkImageInfo.h"
#ifdef SK_BUILD_FOR_MAC
#include <ApplicationServices/ApplicationServices.h>
@@ -23,6 +24,22 @@ class SkData;
class SkStream;
/**
+ * Given a CGImage, allocate an SkBitmap and copy the image's pixels into it. If scaleToFit is not
+ * null, use it to determine the size of the bitmap, and scale the image to fill the bitmap.
+ * Otherwise use the image's width/height.
+ *
+ * On failure, return false, and leave bitmap unchanged.
+ */
+SK_API bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef src, SkISize* scaleToFit = NULL);
+
+/**
+ * Copy the pixels from src into the memory specified by info/rowBytes/dstPixels. On failure,
+ * return false (e.g. ImageInfo incompatible with src).
+ */
+SK_API bool SkCopyPixelsFromCGImage(const SkImageInfo& info, size_t rowBytes, void* dstPixels,
+ CGImageRef src);
+
+/**
* Create an imageref from the specified bitmap using the specified colorspace.
* If space is NULL, then CGColorSpaceCreateDeviceRGB() is used.
*/