aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-05-16 13:07:43 -0400
committerDerek Sollenberger <djsollen@google.com>2011-05-17 07:52:26 -0400
commit35e2e62b55598210f6999fc2ea26ff8f41446ffe (patch)
tree4fca2ca7d02d58e56d9b146b770ecb1e8da8d8af /include
parentf173507281c41ccde5f0ef849cd720639d7e25d0 (diff)
downloadexternal_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.zip
external_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.tar.gz
external_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.tar.bz2
Skia Merge (revision 1327)
Change-Id: I46f41274d07a3d7bac4728f8841c7f5e89dc9181
Diffstat (limited to 'include')
-rw-r--r--include/core/Sk64.h2
-rw-r--r--include/core/SkAdvancedTypefaceMetrics.h6
-rw-r--r--include/core/SkBitmap.h62
-rw-r--r--include/core/SkBuffer.h31
-rw-r--r--include/core/SkCanvas.h48
-rw-r--r--include/core/SkClampRange.h46
-rw-r--r--include/core/SkClipStack.h6
-rw-r--r--include/core/SkColor.h4
-rw-r--r--include/core/SkColorFilter.h28
-rw-r--r--include/core/SkDevice.h61
-rw-r--r--include/core/SkFixed.h8
-rw-r--r--include/core/SkFlattenable.h74
-rw-r--r--include/core/SkFontHost.h3
-rw-r--r--include/core/SkMask.h5
-rw-r--r--include/core/SkMaskFilter.h16
-rw-r--r--include/core/SkMatrix.h54
-rw-r--r--include/core/SkMetaData.h2
-rw-r--r--include/core/SkPath.h63
-rw-r--r--include/core/SkPicture.h2
-rw-r--r--include/core/SkPoint.h57
-rw-r--r--include/core/SkPreConfig.h16
-rw-r--r--include/core/SkPtrRecorder.h70
-rw-r--r--include/core/SkReader32.h6
-rw-r--r--include/core/SkRect.h189
-rw-r--r--include/core/SkScalar.h9
-rw-r--r--include/core/SkStream.h2
-rw-r--r--include/core/SkString.h5
-rw-r--r--include/core/SkThread_platform.h4
-rw-r--r--include/core/SkTypeface.h12
-rw-r--r--include/core/SkWriter32.h29
-rw-r--r--include/core/SkXfermode.h56
-rw-r--r--include/effects/Sk2DPathEffect.h6
-rw-r--r--include/effects/SkAvoidXfermode.h14
-rw-r--r--include/effects/SkBlurMaskFilter.h2
-rw-r--r--include/effects/SkColorMatrixFilter.h17
-rw-r--r--include/effects/SkEmbossMaskFilter.h3
-rw-r--r--include/effects/SkKernel33MaskFilter.h3
-rw-r--r--include/effects/SkLayerDrawLooper.h34
-rw-r--r--include/effects/SkLayerRasterizer.h3
-rw-r--r--include/effects/SkPixelXorXfermode.h5
-rw-r--r--include/effects/SkTransparentShader.h6
-rw-r--r--include/gpu/SkGpuDevice.h4
-rw-r--r--include/gpu/SkGr.h34
-rw-r--r--include/utils/SkProxyCanvas.h2
-rw-r--r--include/utils/unix/XkeysToSkKeys.h23
-rw-r--r--include/utils/unix/keysym2ucs.h8
46 files changed, 820 insertions, 320 deletions
diff --git a/include/core/Sk64.h b/include/core/Sk64.h
index ff28544..b40b27f 100644
--- a/include/core/Sk64.h
+++ b/include/core/Sk64.h
@@ -24,7 +24,7 @@
Sk64 is a 64-bit math package that does not require long long support from the compiler.
*/
-struct Sk64 {
+struct SK_API Sk64 {
int32_t fHi; //!< the high 32 bits of the number (including sign)
uint32_t fLo; //!< the low 32 bits of the number
diff --git a/include/core/SkAdvancedTypefaceMetrics.h b/include/core/SkAdvancedTypefaceMetrics.h
index f536a56..1b81909 100644
--- a/include/core/SkAdvancedTypefaceMetrics.h
+++ b/include/core/SkAdvancedTypefaceMetrics.h
@@ -82,6 +82,8 @@ public:
kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data.
kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data.
kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only).
+ kToUnicode_PerGlyphInfo = 0x8, // Populate ToUnicode table, ignored
+ // for Type 1 fonts
};
template <typename Data>
@@ -113,6 +115,10 @@ public:
// The names of each glyph, only populated for postscript fonts.
SkTScopedPtr<SkAutoTArray<SkString> > fGlyphNames;
+
+ // The mapping from glyph to Unicode, only populated if
+ // kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics.
+ SkTDArray<SkUnichar> fGlyphToUnicode;
};
namespace skia_advanced_typeface_metrics_utils {
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 349489e..91143c1 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -37,8 +37,11 @@ class SkGpuTexture;
The SkBitmap class specifies a raster bitmap. A bitmap has an integer width
and height, and a format (config), and a pointer to the actual pixels.
- Bitmaps can be drawn into a SkCanvas, but they are also used to specify the target
- of a SkCanvas' drawing operations.
+ Bitmaps can be drawn into a SkCanvas, but they are also used to specify the
+ target of a SkCanvas' drawing operations.
+ A const SkBitmap exposes getAddr(), which lets a caller write its pixels;
+ the constness is considered to apply to the bitmap's configuration, not
+ its contents.
*/
class SK_API SkBitmap {
public:
@@ -334,7 +337,7 @@ public:
SkColorTable* getColorTable() const { return fColorTable; }
/** Returns a non-zero, unique value corresponding to the pixels in our
- pixelref, or 0 if we do not have a pixelref. Each time the pixels are
+ pixelref (or raw pixels set via setPixels). Each time the pixels are
changed (and notifyPixelsChanged is called), a different generation ID
will be returned.
*/
@@ -390,6 +393,15 @@ public:
bool scrollRect(const SkIRect* subset, int dx, int dy,
SkRegion* inval = NULL) const;
+ /**
+ * Return the SkColor of the specified pixel. In most cases this will
+ * require un-premultiplying the color. Alpha only configs (A1 and A8)
+ * return black with the appropriate alpha set. The value is undefined
+ * for kNone_Config or if x or y are out of bounds, or if the bitmap
+ * does not have any pixels (or has not be locked with lockPixels()).
+ */
+ SkColor getColor(int x, int y) const;
+
/** Returns the address of the specified pixel. This performs a runtime
check to know the size of the pixels, and will return the same answer
as the corresponding size-specific method (e.g. getAddr16). Since the
@@ -401,30 +413,41 @@ public:
*/
void* getAddr(int x, int y) const;
- /** Return the SkColor of the specified pixel. In most cases this will
- require un-premultiplying the color. Alpha only configs (A1 and A8)
- return black with the appropriate alpha set. The value is undefined
- for kNone_Config or if x or y are out of bounds.
- */
- SkColor getColor(int x, int y) const;
-
/** Returns the address of the pixel specified by x,y for 32bit pixels.
- */
+ * In debug build, this asserts that the pixels are allocated and locked,
+ * and that the config is 32-bit, however none of these checks are performed
+ * in the release build.
+ */
inline uint32_t* getAddr32(int x, int y) const;
+
/** Returns the address of the pixel specified by x,y for 16bit pixels.
- */
+ * In debug build, this asserts that the pixels are allocated and locked,
+ * and that the config is 16-bit, however none of these checks are performed
+ * in the release build.
+ */
inline uint16_t* getAddr16(int x, int y) const;
+
/** Returns the address of the pixel specified by x,y for 8bit pixels.
- */
+ * In debug build, this asserts that the pixels are allocated and locked,
+ * and that the config is 8-bit, however none of these checks are performed
+ * in the release build.
+ */
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.
- */
+ * 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.
- */
+ * colortable based bitmaps.
+ * In debug build, this asserts that the pixels are allocated and locked,
+ * that the config is kIndex8, and that the colortable is allocated,
+ * however none of these checks are performed in the release build.
+ */
inline SkPMColor getIndex8Color(int x, int y) const;
/** Set dst to be a setset of this bitmap. If possible, it will share the
@@ -551,6 +574,10 @@ private:
// or a cache of the returned value from fPixelRef->lockPixels()
mutable void* fPixels;
mutable SkColorTable* fColorTable; // only meaningful for kIndex8
+ // When there is no pixel ref (setPixels was called) we still need a
+ // gen id for SkDevice implementations that may cache a copy of the
+ // pixels (e.g. as a gpu texture)
+ mutable int fRawPixelGenerationID;
enum Flags {
kImageIsOpaque_Flag = 0x01
@@ -777,4 +804,3 @@ inline uint8_t* SkBitmap::getAddr1(int x, int y) const {
}
#endif
-
diff --git a/include/core/SkBuffer.h b/include/core/SkBuffer.h
index bc11a1e..6745650 100644
--- a/include/core/SkBuffer.h
+++ b/include/core/SkBuffer.h
@@ -32,16 +32,14 @@ public:
/** Initialize RBuffer with a data pointer, but no specified length.
This signals the RBuffer to not perform range checks during reading.
*/
- SkRBuffer(const void* data)
- {
+ SkRBuffer(const void* data) {
fData = (const char*)data;
fPos = (const char*)data;
fStop = 0; // no bounds checking
}
/** Initialize RBuffer with a data point and length.
*/
- SkRBuffer(const void* data, size_t size)
- {
+ SkRBuffer(const void* data, size_t size) {
SkASSERT(data != 0 || size == 0);
fData = (const char*)data;
fPos = (const char*)data;
@@ -65,7 +63,12 @@ public:
/** Read the specified number of bytes from the data pointer. If buffer is not
null, copy those bytes into buffer.
*/
- void read(void* buffer, size_t size) { if (size) this->readNoSizeCheck(buffer, size); }
+ void read(void* buffer, size_t size) {
+ if (size) {
+ this->readNoSizeCheck(buffer, size);
+ }
+ }
+
const void* skip(size_t size); // return start of skipped data
size_t skipToAlign4();
@@ -100,26 +103,28 @@ public:
SkWBuffer(void* data) { reset(data); }
SkWBuffer(void* data, size_t size) { reset(data, size); }
- void reset(void* data)
- {
+ void reset(void* data) {
fData = (char*)data;
fPos = (char*)data;
fStop = 0; // no bounds checking
}
- void reset(void* data, size_t size)
- {
+
+ void reset(void* data, size_t size) {
SkASSERT(data != 0 || size == 0);
fData = (char*)data;
fPos = (char*)data;
fStop = (char*)data + size;
}
- void* data() const { return fData; }
size_t pos() const { return fPos - fData; }
- size_t size() const { return fStop - fData; }
- bool eof() const { return fPos >= fStop; }
void* skip(size_t size); // return start of skipped data
- void write(const void* buffer, size_t size) { if (size) this->writeNoSizeCheck(buffer, size); }
+
+ void write(const void* buffer, size_t size) {
+ if (size) {
+ this->writeNoSizeCheck(buffer, size);
+ }
+ }
+
size_t padToAlign4();
void writePtr(const void* x) { this->writeNoSizeCheck(&x, sizeof(x)); }
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 39fd998..273153f 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -75,22 +75,6 @@ public:
///////////////////////////////////////////////////////////////////////////
- /** If the Device supports GL viewports, return true and set size (if not
- null) to the size of the viewport. If it is not supported, ignore size
- and return false.
-
- DEPRECATED: the gpu-device backend takes care of managing the viewport
- */
- virtual bool getViewport(SkIPoint* size) const;
-
- /** If the Device supports GL viewports, return true and set the viewport
- to the specified x and y dimensions. If it is not supported, ignore x
- and y and return false.
-
- DEPRECATED: the gpu-device backend takes care of managing the viewport
- */
- virtual bool setViewport(int x, int y);
-
/** Return the canvas' device object, which may be null. The device holds
the bitmap of the pixels that the canvas draws into. The reference count
of the returned device is not changed by this call.
@@ -126,12 +110,15 @@ public:
SkDevice* setBitmapDevice(const SkBitmap& bitmap, bool forLayer = false);
/**
- * Return the current device factory, or NULL.
+ * Return the current device factory, or NULL. The reference count of
+ * the returned factory is not changed.
*/
SkDeviceFactory* getDeviceFactory() const { return fDeviceFactory; }
/**
- * Replace any existing factory with the specified factory.
+ * Replace any existing factory with the specified factory, unrefing the
+ * previous (if any), and refing the new one (if any). For convenience,
+ * the factory parameter is also returned.
*/
SkDeviceFactory* setDeviceFactory(SkDeviceFactory*);
@@ -391,10 +378,27 @@ public:
void drawColor(SkColor color,
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
- /** Fill the entire canvas' bitmap (restricted to the current clip) with the
- specified paint.
- @param paint The paint used to fill the canvas
- */
+ /**
+ * This erases the entire drawing surface to the specified color,
+ * irrespective of the clip. It does not blend with the previous pixels,
+ * but always overwrites them.
+ *
+ * It is roughly equivalent to the following:
+ * canvas.save();
+ * canvas.clipRect(hugeRect, kReplace_Op);
+ * paint.setColor(color);
+ * paint.setXfermodeMode(kSrc_Mode);
+ * canvas.drawPaint(paint);
+ * canvas.restore();
+ * though it is almost always much more efficient.
+ */
+ virtual void clear(SkColor);
+
+ /**
+ * Fill the entire canvas' bitmap (restricted to the current clip) with the
+ * specified paint.
+ * @param paint The paint used to fill the canvas
+ */
virtual void drawPaint(const SkPaint& paint);
enum PointMode {
diff --git a/include/core/SkClampRange.h b/include/core/SkClampRange.h
new file mode 100644
index 0000000..9acf1ad
--- /dev/null
+++ b/include/core/SkClampRange.h
@@ -0,0 +1,46 @@
+/*
+ Copyright 2011 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#ifndef SkClampRange_DEFINED
+#define SkClampRange_DEFINED
+
+#include "SkFixed.h"
+
+/**
+ * Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class
+ * computes the (up to) 3 spans there are:
+ *
+ * range0: use constant value V0
+ * range1: iterate as usual fx += dx
+ * range2: use constant value V1
+ */
+struct SkClampRange {
+ int fCount0; // count for fV0
+ int fCount1; // count for interpolating (fV0...fV1)
+ int fCount2; // count for fV1
+ SkFixed fFx1; // initial fx value for the fCount1 range.
+ // only valid if fCount1 > 0
+ int fV0, fV1;
+ bool fOverflowed; // true if we had to clamp due to numerical overflow
+
+ void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
+
+private:
+ void initFor1(SkFixed fx);
+};
+
+#endif
+
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index 850a3f0..ae0b974 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -10,8 +10,13 @@ class SkPath;
class SK_API SkClipStack {
public:
SkClipStack();
+ SkClipStack(const SkClipStack& b);
~SkClipStack() {}
+ SkClipStack& operator=(const SkClipStack& b);
+ bool operator==(const SkClipStack& b) const;
+ bool operator!=(const SkClipStack& b) const { return !(*this == b); }
+
void reset();
int getSaveCount() const { return fSaveCount; }
@@ -37,6 +42,7 @@ public:
B2FIter(const SkClipStack& stack);
struct Clip {
+ friend bool operator==(const Clip& a, const Clip& b);
const SkRect* fRect; // if non-null, this is a rect clip
const SkPath* fPath; // if non-null, this is a path clip
SkRegion::Op fOp;
diff --git a/include/core/SkColor.h b/include/core/SkColor.h
index 6b86e7e..1f82aa7 100644
--- a/include/core/SkColor.h
+++ b/include/core/SkColor.h
@@ -104,7 +104,7 @@ static inline SkColor SkColorSetA(SkColor c, U8CPU a) {
@param blue blue component value [0..255]
@param hsv 3 element array which holds the resulting HSV components.
*/
-void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]);
+SK_API void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]);
/** Convert the argb color to its HSV components.
hsv[0] is Hue [0 .. 360)
@@ -127,7 +127,7 @@ static inline void SkColorToHSV(SkColor color, SkScalar hsv[3])
@param hsv 3 element array which holds the input HSV components.
@return the resulting argb color
*/
-SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]);
+SK_API SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]);
/** Convert HSV components to an ARGB color. The alpha component set to 0xFF.
hsv[0] is Hue [0 .. 360)
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 3bdf815..3e9aee8 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -21,8 +21,15 @@
#include "SkFlattenable.h"
#include "SkXfermode.h"
-class SkColorFilter : public SkFlattenable {
+class SK_API SkColorFilter : public SkFlattenable {
public:
+ /**
+ * If the filter can be represented by a source color plus Mode, this
+ * returns true, and sets (if not NULL) the color and mode appropriately.
+ * If not, this returns false and ignores the parameters.
+ */
+ virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode);
+
/** Called with a scanline of colors, as if there was a shader installed.
The implementation writes out its filtered version into result[].
Note: shader and result may be the same buffer.
@@ -58,6 +65,15 @@ public:
*/
virtual uint32_t getFlags() { return 0; }
+ /**
+ * Apply this colorfilter to the specified SkColor. This routine handles
+ * converting to SkPMColor, calling the filter, and then converting back
+ * to SkColor. This method is not virtual, but will call filterSpan()
+ * which is virtual.
+ */
+ SkColor filterColor(SkColor);
+
+
/** Create a colorfilter that uses the specified color and mode.
If the Mode is DST, this function will return NULL (since that
mode will have no effect on the result).
@@ -83,11 +99,11 @@ public:
are ignored.
*/
static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
-
+
protected:
SkColorFilter() {}
SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {}
-
+
private:
typedef SkFlattenable INHERITED;
};
@@ -107,17 +123,17 @@ public:
virtual void shadeSpan16(int x, int y, uint16_t result[], int count);
virtual void beginSession();
virtual void endSession();
-
+
protected:
SkFilterShader(SkFlattenableReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer& );
virtual Factory getFactory() { return CreateProc; }
private:
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkFilterShader, (buffer)); }
SkShader* fShader;
SkColorFilter* fFilter;
-
+
typedef SkShader INHERITED;
};
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 8889fb4..46bcf1a 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -36,8 +36,9 @@ class SkRegion;
to pass into SkCanvas. Doing so will eliminate the need to extend
SkCanvas as well.
*/
-class SK_API SkDeviceFactory {
+class SK_API SkDeviceFactory : public SkRefCnt {
public:
+ SkDeviceFactory();
virtual ~SkDeviceFactory();
virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width,
int height, bool isOpaque, bool isLayer) = 0;
@@ -65,9 +66,12 @@ public:
SkDevice(SkCanvas*, const SkBitmap& bitmap, bool forOffscreen);
virtual ~SkDevice();
- virtual SkDeviceFactory* getDeviceFactory() {
- return SkNEW(SkRasterDeviceFactory);
- }
+ /**
+ * Return the factory that will create this subclass of SkDevice.
+ * The returned factory is cached by the device, and so its reference count
+ * is not changed by this call.
+ */
+ SkDeviceFactory* getDeviceFactory();
enum Capabilities {
kGL_Capability = 0x1, //!< mask indicating GL support
@@ -115,10 +119,15 @@ public:
*/
const SkBitmap& accessBitmap(bool changePixels);
- /** Helper to erase the entire device to the specified color (including
- alpha).
- */
- void eraseColor(SkColor eraseColor);
+ /** Clears the entire device to the specified color (including alpha).
+ * Ignores the clip.
+ */
+ virtual void clear(SkColor color);
+
+ /**
+ * Deprecated name for clear.
+ */
+ void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
/** Called when this device is installed into a Canvas. Balanaced by a call
to unlockPixels() when the device is removed from a Canvas.
@@ -146,6 +155,31 @@ public:
virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
const SkClipStack&);
+ /**
+ * Observer interface for listening to the calls to
+ * SkDevice::setMatrixClip(...). Users of SkDevice instances should
+ * implement matrixClipChanged(...) to receive notifications.
+ */
+ class SkMatrixClipObserver : public SkRefCnt {
+ public:
+ virtual void matrixClipChanged(const SkMatrix&, const SkRegion&,
+ const SkClipStack&) = 0;
+ };
+
+ /** Assign the clip observer. Note that an extra reference is added to the
+ * observer, and removed at SkDevice construction, or re-assignment of a
+ * different observer.
+ */
+ void setMatrixClipObserver(SkMatrixClipObserver* observer);
+
+ /** Return the device's associated SkMatrixClipObserver, or NULL.
+ * If non-null is returned, the reference count of the object is not
+ * modified.
+ */
+ SkMatrixClipObserver* getMatrixClipObserver() const {
+ return fMatrixClipObserver;
+ }
+
/** Called when this device gains focus (i.e becomes the current device
for drawing).
*/
@@ -242,6 +276,13 @@ public:
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
protected:
+ /**
+ * subclasses must override this to return a new (or ref'd) instance of
+ * a device factory that will create this subclass of device. This value
+ * is cached, so it should get called at most once for a given instance.
+ */
+ virtual SkDeviceFactory* onNewDeviceFactory();
+
/** Update as needed the pixel value in the bitmap, so that the caller can access
the pixels directly. Note: only the pixels field should be altered. The config/width/height/rowbytes
must remain unchanged.
@@ -264,6 +305,10 @@ private:
SkBitmap fBitmap;
SkIPoint fOrigin;
SkMetaData* fMetaData;
+
+ SkMatrixClipObserver* fMatrixClipObserver;
+
+ SkDeviceFactory* fCachedDeviceFactory;
};
#endif
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index 2a2456e..c58c6de 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -30,7 +30,7 @@ typedef int32_t SkFixed;
#define SK_Fixed1 (1 << 16)
#define SK_FixedHalf (1 << 15)
#define SK_FixedMax (0x7FFFFFFF)
-#define SK_FixedMin (0x1)
+#define SK_FixedMin (-SK_FixedMax)
#define SK_FixedNaN ((int) 0x80000000)
#define SK_FixedPI (0x3243F)
#define SK_FixedSqrt2 (92682)
@@ -118,7 +118,11 @@ inline SkFixed SkFixedSquare_portable(SkFixed value)
uint32_t a = SkAbs32(value);
uint32_t ah = a >> 16;
uint32_t al = a & 0xFFFF;
- return ah * a + al * ah + (al * al >> 16);
+ SkFixed result = ah * a + al * ah + (al * al >> 16);
+ if (result >= 0)
+ return result;
+ else // Overflow.
+ return SK_FixedMax;
}
#define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index ad4062f..03bcab8 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -70,6 +70,16 @@ protected:
SkFlattenable(SkFlattenableReadBuffer&) {}
};
+// helpers for matrix and region
+
+class SkMatrix;
+extern void SkReadMatrix(SkReader32*, SkMatrix*);
+extern void SkWriteMatrix(SkWriter32*, const SkMatrix&);
+
+class SkRegion;
+extern void SkReadRegion(SkReader32*, SkRegion*);
+extern void SkWriteRegion(SkWriter32*, const SkRegion&);
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -118,48 +128,22 @@ private:
#include "SkPtrRecorder.h"
-class SkRefCntRecorder : public SkPtrRecorder {
+/**
+ * Subclass of SkTPtrSet specialed to call ref() and unref() when the
+ * base class's incPtr() and decPtr() are called. This makes it a valid owner
+ * of each ptr, which is released when the set is reset or destroyed.
+ */
+class SkRefCntSet : public SkTPtrSet<SkRefCnt*> {
public:
- virtual ~SkRefCntRecorder();
-
- /** Add a refcnt object to the set and ref it if not already present,
- or if it is already present, do nothing. Either way, returns 0 if obj
- is null, or a base-1 index if obj is not null.
- */
- uint32_t record(SkRefCnt* ref) {
- return this->recordPtr(ref);
- }
-
- // This does not change the owner counts on the objects
- void get(SkRefCnt* array[]) const {
- this->getPtrs((void**)array);
- }
-
+ virtual ~SkRefCntSet();
+
protected:
// overrides
virtual void incPtr(void*);
virtual void decPtr(void*);
-
-private:
- typedef SkPtrRecorder INHERITED;
};
-class SkFactoryRecorder : public SkPtrRecorder {
-public:
- /** Add a factory to the set. If it is null return 0, otherwise return a
- base-1 index for the factory.
- */
- uint32_t record(SkFlattenable::Factory fact) {
- return this->recordPtr((void*)fact);
- }
-
- void get(SkFlattenable::Factory array[]) const {
- this->getPtrs((void**)array);
- }
-
-private:
- typedef SkPtrRecorder INHERITED;
-};
+class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {};
class SkFlattenableWriteBuffer : public SkWriter32 {
public:
@@ -171,14 +155,14 @@ public:
void writeFunctionPtr(void*);
void writeFlattenable(SkFlattenable* flattenable);
- SkRefCntRecorder* getTypefaceRecorder() const { return fTFRecorder; }
- SkRefCntRecorder* setTypefaceRecorder(SkRefCntRecorder*);
+ SkRefCntSet* getTypefaceRecorder() const { return fTFSet; }
+ SkRefCntSet* setTypefaceRecorder(SkRefCntSet*);
- SkRefCntRecorder* getRefCntRecorder() const { return fRCRecorder; }
- SkRefCntRecorder* setRefCntRecorder(SkRefCntRecorder*);
+ SkRefCntSet* getRefCntRecorder() const { return fRCSet; }
+ SkRefCntSet* setRefCntRecorder(SkRefCntSet*);
- SkFactoryRecorder* getFactoryRecorder() const { return fFactoryRecorder; }
- SkFactoryRecorder* setFactoryRecorder(SkFactoryRecorder*);
+ SkFactorySet* getFactoryRecorder() const { return fFactorySet; }
+ SkFactorySet* setFactoryRecorder(SkFactorySet*);
enum Flags {
kCrossProcess_Flag = 0x01
@@ -195,10 +179,10 @@ public:
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
private:
- Flags fFlags;
- SkRefCntRecorder* fTFRecorder;
- SkRefCntRecorder* fRCRecorder;
- SkFactoryRecorder* fFactoryRecorder;
+ Flags fFlags;
+ SkRefCntSet* fTFSet;
+ SkRefCntSet* fRCSet;
+ SkFactorySet* fFactorySet;
typedef SkWriter32 INHERITED;
};
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index 72faed7..d0f7c65 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -24,7 +24,6 @@ class SkDescriptor;
class SkStream;
class SkWStream;
-typedef uint32_t SkFontID;
typedef uint32_t SkFontTableTag;
/** \class SkFontHost
@@ -56,7 +55,7 @@ typedef uint32_t SkFontTableTag;
font scaler (e.g. freetype or other) to the font's data.
5) Utilites to manage the font cache (budgeting) and gamma correction
*/
-class SkFontHost {
+class SK_API SkFontHost {
public:
/** Return a new, closest matching typeface given either an existing family
(specified by a typeface in that family) or by a familyName and a
diff --git a/include/core/SkMask.h b/include/core/SkMask.h
index ebb870f..f437622 100644
--- a/include/core/SkMask.h
+++ b/include/core/SkMask.h
@@ -126,10 +126,11 @@ struct SkMask {
*/
unsigned rowWordsLCD() const {
SkASSERT(fFormat == kHorizontalLCD_Format || fFormat == kVerticalLCD_Format);
- if (fFormat == kHorizontalLCD_Format)
+ if (fFormat == kHorizontalLCD_Format) {
return fBounds.width() + 2;
- else
+ } else {
return fBounds.width();
+ }
}
static uint8_t* AllocImage(size_t bytes);
diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h
index 749a73a..641ad83 100644
--- a/include/core/SkMaskFilter.h
+++ b/include/core/SkMaskFilter.h
@@ -44,7 +44,7 @@ public:
/** Returns the format of the resulting mask that this subclass will return
when its filterMask() method is called.
*/
- virtual SkMask::Format getFormat() = 0;
+ virtual SkMask::Format getFormat() = 0;
/** Create a new mask by filter the src mask.
If src.fImage == null, then do not allocate or create the dst image
@@ -59,7 +59,8 @@ public:
applying the filter. If returning false, ignore this parameter.
@return true if the dst mask was correctly created.
*/
- virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin);
+ virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
+ SkIPoint* margin);
/** Helper method that, given a path in device space, will rasterize it into a kA8_Format mask
and then call filterMask(). If this returns true, the specified blitter will be called
@@ -70,6 +71,7 @@ public:
const SkRegion& devClip, SkBounder*, SkBlitter* blitter);
virtual void flatten(SkFlattenableWriteBuffer& ) {}
+
protected:
// empty for now, but lets get our subclass to remember to init us for the future
SkMaskFilter(SkFlattenableReadBuffer&) {}
@@ -82,14 +84,14 @@ protected:
*/
class SkAutoMaskImage {
public:
- SkAutoMaskImage(SkMask* mask, bool alloc)
- {
- if (alloc)
+ SkAutoMaskImage(SkMask* mask, bool alloc) {
+ if (alloc) {
mask->fImage = SkMask::AllocImage(mask->computeImageSize());
+ }
fImage = mask->fImage;
}
- ~SkAutoMaskImage()
- {
+
+ ~SkAutoMaskImage() {
SkMask::FreeImage(fImage);
}
private:
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index 5ba9223..7c77902 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -70,6 +70,15 @@ public:
}
return (fTypeMask & kRectStaysRect_Mask) != 0;
}
+ // alias for rectStaysRect()
+ bool preservesAxisAlignment() const { return this->rectStaysRect(); }
+
+ /**
+ * Returns true if the perspective contains perspective elements.
+ */
+ bool hasPerspective() const {
+ return SkToBool(this->getType() & kPerspective_Mask);
+ }
enum {
kMScaleX,
@@ -123,10 +132,27 @@ public:
void setPerspX(SkScalar v) { this->set(kMPersp0, v); }
void setPerspY(SkScalar v) { this->set(kMPersp1, v); }
+ void setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX,
+ SkScalar skewY, SkScalar scaleY, SkScalar transY,
+ SkScalar persp0, SkScalar persp1, SkScalar persp2) {
+ fMat[kMScaleX] = scaleX;
+ fMat[kMSkewX] = skewX;
+ fMat[kMTransX] = transX;
+ fMat[kMSkewY] = skewY;
+ fMat[kMScaleY] = scaleY;
+ fMat[kMTransY] = transY;
+ fMat[kMPersp0] = persp0;
+ fMat[kMPersp1] = persp1;
+ fMat[kMPersp2] = persp2;
+ this->setTypeMask(kUnknown_Mask);
+ }
+
/** Set the matrix to identity
*/
void reset();
-
+ // alias for reset()
+ void setIdentity() { this->reset(); }
+
/** Set the matrix to translate by (dx, dy).
*/
void setTranslate(SkScalar dx, SkScalar dy);
@@ -369,6 +395,13 @@ public:
return this->mapRect(rect, *rect);
}
+ void mapPointsWithStride(SkPoint pts[], size_t stride, int count) const {
+ for (int i = 0; i < count; ++i) {
+ this->mapPoints(pts, pts, 1);
+ pts = (SkPoint*)((intptr_t)pts + stride);
+ }
+ }
+
/** Return the mean radius of a circle after it has been mapped by
this matrix. NOTE: in perspective this value assumes the circle
has its center at the origin.
@@ -425,6 +458,25 @@ public:
void dump() const;
void toDumpString(SkString*) const;
+ /**
+ * Calculates the maximum stretching factor of the matrix. Only defined if
+ * the matrix does not have perspective.
+ *
+ * @return maximum strecthing factor or negative if matrix has perspective.
+ */
+ SkScalar getMaxStretch() const;
+
+ /**
+ * Return a reference to a const identity matrix
+ */
+ static const SkMatrix& I();
+
+ /**
+ * Return a reference to a const matrix that is "invalid", one that could
+ * never be used.
+ */
+ static const SkMatrix& InvalidMatrix();
+
private:
enum {
/** Set if the matrix will map a rectangle to another rectangle. This
diff --git a/include/core/SkMetaData.h b/include/core/SkMetaData.h
index ee2fa2b..1c34fd5 100644
--- a/include/core/SkMetaData.h
+++ b/include/core/SkMetaData.h
@@ -21,7 +21,7 @@
class SkRefCnt;
-class SkMetaData {
+class SK_API SkMetaData {
public:
/**
* Used to manage the life-cycle of a ptr in the metadata. This is option
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index d9a7093..18dcd11 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -28,8 +28,8 @@
#define GEN_ID_PTR_INC(ptr)
#endif
-class SkFlattenableReadBuffer;
-class SkFlattenableWriteBuffer;
+class SkReader32;
+class SkWriter32;
class SkAutoPathBoundsUpdate;
class SkString;
@@ -96,19 +96,54 @@ public:
GEN_ID_INC;
}
- /** Returns true if the path is flagged as being convex. This is not a
- confirmed by any analysis, it is just the value set earlier.
+ enum Convexity {
+ kUnknown_Convexity,
+ kConvex_Convexity,
+ kConcave_Convexity
+ };
+
+ /**
+ * Return the path's convexity, as stored in the path.
+ */
+ Convexity getConvexity() const { return (Convexity)fConvexity; }
+
+ /**
+ * Store a convexity setting in the path. There is no automatic check to
+ * see if this value actually agress with the return value from
+ * ComputeConvexity().
+ */
+ void setConvexity(Convexity);
+
+ /**
+ * Compute the convexity of the specified path. This does not look at the
+ * value stored in the path, but computes it directly from the path's data.
+ *
+ * If there is more than one contour, this returns kConcave_Convexity.
+ * If the contour is degenerate (i.e. all segements are colinear,
+ * then this returns kUnknown_Convexity.
+ * The contour is treated as if it were closed, even if there is no kClose
+ * verb.
*/
- bool isConvex() const { return fIsConvex != 0; }
+ static Convexity ComputeConvexity(const SkPath&);
- /** Set the isConvex flag to true or false. Convex paths may draw faster if
- this flag is set, though setting this to true on a path that is in fact
- not convex can give undefined results when drawn. Paths default to
- isConvex == false
+ /**
+ * DEPRECATED: use getConvexity()
+ * Returns true if the path is flagged as being convex. This is not a
+ * confirmed by any analysis, it is just the value set earlier.
+ */
+ bool isConvex() const {
+ return kConvex_Convexity == this->getConvexity();
+ }
+
+ /**
+ * DEPRECATED: use setConvexity()
+ * Set the isConvex flag to true or false. Convex paths may draw faster if
+ * this flag is set, though setting this to true on a path that is in fact
+ * not convex can give undefined results when drawn. Paths default to
+ * isConvex == false
*/
void setIsConvex(bool isConvex) {
- fIsConvex = (isConvex != 0);
- GEN_ID_INC;
+ this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
}
/** Clear any lines and curves from the path, making it empty. This frees up
@@ -579,8 +614,8 @@ public:
void dump(bool forceClose, const char title[] = NULL) const;
void dump() const;
- void flatten(SkFlattenableWriteBuffer&) const;
- void unflatten(SkFlattenableReadBuffer&);
+ void flatten(SkWriter32&) const;
+ void unflatten(SkReader32&);
/** Subdivide the path so that no segment is longer that dist.
If bendLines is true, then turn all line segments into curves.
@@ -600,7 +635,7 @@ private:
mutable SkRect fBounds;
mutable uint8_t fBoundsIsDirty;
uint8_t fFillType;
- uint8_t fIsConvex;
+ uint8_t fConvexity;
#ifdef ANDROID
uint32_t fGenerationID;
#endif
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index be7bad5..ac21bc9 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -30,7 +30,7 @@ class SkWStream;
The SkPicture class records the drawing commands made to a canvas, to
be played back at a later time.
*/
-class SkPicture : public SkRefCnt {
+class SK_API SkPicture : public SkRefCnt {
public:
/** The constructor prepares the picture to record.
@param width the width of the virtual device the picture records.
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h
index 52dbd51..d74435e 100644
--- a/include/core/SkPoint.h
+++ b/include/core/SkPoint.h
@@ -171,9 +171,40 @@ struct SK_API SkPoint {
fY = SkIntToScalar(p.fY);
}
+ void setAbs(const SkPoint& pt) {
+ fX = SkScalarAbs(pt.fX);
+ fY = SkScalarAbs(pt.fY);
+ }
+
+ // counter-clockwise fan
+ void setIRectFan(int l, int t, int r, int b) {
+ SkPoint* v = this;
+ v[0].set(SkIntToScalar(l), SkIntToScalar(t));
+ v[1].set(SkIntToScalar(l), SkIntToScalar(b));
+ v[2].set(SkIntToScalar(r), SkIntToScalar(b));
+ v[3].set(SkIntToScalar(r), SkIntToScalar(t));
+ }
+ void setIRectFan(int l, int t, int r, int b, size_t stride);
+
+ // counter-clockwise fan
+ void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b) {
+ SkPoint* v = this;
+ v[0].set(l, t);
+ v[1].set(l, b);
+ v[2].set(r, b);
+ v[3].set(r, t);
+ }
+ void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t stride);
+
+ void offset(SkScalar dx, SkScalar dy) {
+ fX += dx;
+ fY += dy;
+ }
+
/** Return the euclidian distance from (0,0) to the point
*/
SkScalar length() const { return SkPoint::Length(fX, fY); }
+ SkScalar distanceToOrigin() const { return this->length(); }
/** Set the point (vector) to be unit-length in the same direction as it
currently is, and return its old length. If the old length is
@@ -315,6 +346,32 @@ struct SK_API SkPoint {
static SkScalar CrossProduct(const SkPoint& a, const SkPoint& b) {
return SkScalarMul(a.fX, b.fY) - SkScalarMul(a.fY, b.fX);
}
+
+ SkScalar cross(const SkPoint& vec) const {
+ return CrossProduct(*this, vec);
+ }
+
+ SkScalar dot(const SkPoint& vec) const {
+ return DotProduct(*this, vec);
+ }
+
+ SkScalar lengthSqd() const {
+ return DotProduct(*this, *this);
+ }
+
+ SkScalar distanceToSqd(const SkPoint& pt) const {
+ SkScalar dx = fX - pt.fX;
+ SkScalar dy = fY - pt.fY;
+ return SkScalarMul(dx, dx) + SkScalarMul(dy, dy);
+ }
+
+ SkScalar distanceToLineSegmentBetweenSqd(const SkPoint& a,
+ const SkPoint& b) const;
+
+ SkScalar distanceToLineSegmentBetween(const SkPoint& a,
+ const SkPoint& b) const {
+ return SkScalarSqrt(this->distanceToLineSegmentBetweenSqd(a, b));
+ }
};
typedef SkPoint SkVector;
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index daf2041..8d47d46 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -62,7 +62,7 @@
#endif
#ifdef SK_BUILD_FOR_WIN32
- #define SK_RESTRICT
+ #define SK_RESTRICT
#include "sk_stdint.h"
#endif
@@ -101,12 +101,16 @@
#if !defined(SKIA_IMPLEMENTATION)
#define SKIA_IMPLEMENTATION 0
#endif
-
-#if defined(WIN32) && defined(SKIA_DLL)
- #if SKIA_IMPLEMENTATION
- #define SK_API __declspec(dllexport)
+
+#if defined(SKIA_DLL)
+ #if defined(WIN32)
+ #if SKIA_IMPLEMENTATION
+ #define SK_API __declspec(dllexport)
+ #else
+ #define SK_API __declspec(dllimport)
+ #endif
#else
- #define SK_API __declspec(dllimport)
+ #define SK_API __attribute__((visibility("default")))
#endif
#else
#define SK_API
diff --git a/include/core/SkPtrRecorder.h b/include/core/SkPtrRecorder.h
index ff1e14d..db6c64d 100644
--- a/include/core/SkPtrRecorder.h
+++ b/include/core/SkPtrRecorder.h
@@ -14,19 +14,52 @@
* limitations under the License.
*/
-#ifndef SkPtrRecorder_DEFINED
-#define SkPtrRecorder_DEFINED
+#ifndef SkPtrSet_DEFINED
+#define SkPtrSet_DEFINED
#include "SkRefCnt.h"
#include "SkTDArray.h"
-class SkPtrRecorder : public SkRefCnt {
+/**
+ * Maintains a set of ptrs, assigning each a unique ID [1...N]. Duplicate ptrs
+ * return the same ID (since its a set). Subclasses can override inPtr()
+ * and decPtr(). incPtr() is called each time a unique ptr is added ot the
+ * set. decPtr() is called on each ptr when the set is destroyed or reset.
+ */
+class SkPtrSet : public SkRefCnt {
public:
- uint32_t recordPtr(void*);
+ /**
+ * Search for the specified ptr in the set. If it is found, return its
+ * 32bit ID [1..N], or if not found, return 0. Always returns 0 for NULL.
+ */
+ uint32_t find(void*) const;
+
+ /**
+ * Add the specified ptr to the set, returning a unique 32bit ID for it
+ * [1...N]. Duplicate ptrs will return the same ID.
+ *
+ * If the ptr is NULL, it is not added, and 0 is returned.
+ */
+ uint32_t add(void*);
+ /**
+ * Return the number of (non-null) ptrs in the set.
+ */
int count() const { return fList.count(); }
- void getPtrs(void* array[]) const;
+ /**
+ * Copy the ptrs in the set into the specified array (allocated by the
+ * caller). The ptrs are assgined to the array based on their corresponding
+ * ID. e.g. array[ptr.ID - 1] = ptr.
+ *
+ * incPtr() and decPtr() are not called during this operation.
+ */
+ void copyToArray(void* array[]) const;
+
+ /**
+ * Call decPtr() on each ptr in the set, and the reset the size of the set
+ * to 0.
+ */
void reset();
protected:
@@ -35,9 +68,14 @@ protected:
private:
struct Pair {
- void* fPtr;
- uint32_t fIndex;
+ void* fPtr; // never NULL
+ uint32_t fIndex; // 1...N
};
+
+ // we store the ptrs in sorted-order (using Cmp) so that we can efficiently
+ // detect duplicates when add() is called. Hence we need to store the
+ // ptr and its ID/fIndex explicitly, since the ptr's position in the array
+ // is not related to its "index".
SkTDArray<Pair> fList;
static int Cmp(const Pair& a, const Pair& b);
@@ -45,4 +83,22 @@ private:
typedef SkRefCnt INHERITED;
};
+/**
+ * Templated wrapper for SkPtrSet, just meant to automate typecasting
+ * parameters to and from void* (which the base class expects).
+ */
+template <typename T> class SkTPtrSet : public SkPtrSet {
+public:
+ uint32_t add(T ptr) {
+ return this->INHERITED::add((void*)ptr);
+ }
+
+ void copyToArray(T* array) const {
+ this->INHERITED::copyToArray((void**)array);
+ }
+
+private:
+ typedef SkPtrSet INHERITED;
+};
+
#endif
diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h
index 1c72a87..03a34c7 100644
--- a/include/core/SkReader32.h
+++ b/include/core/SkReader32.h
@@ -43,6 +43,10 @@ public:
bool eof() const { return fCurr >= fStop; }
const void* base() const { return fBase; }
const void* peek() const { return fCurr; }
+
+ uint32_t available() const { return fStop - fCurr; }
+ bool isAvailable(uint32_t size) const { return fCurr + size <= fStop; }
+
void rewind() { fCurr = fBase; }
void setOffset(size_t offset) {
@@ -86,7 +90,7 @@ public:
}
void read(void* dst, size_t size) {
- SkASSERT(dst != NULL);
+ SkASSERT(0 == size || dst != NULL);
SkASSERT(ptr_align_4(fCurr));
memcpy(dst, fCurr, size);
fCurr += SkAlign4(size);
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 53c61ea..550c5d1 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -94,6 +94,10 @@ struct SK_API SkIRect {
fRight = right;
fBottom = bottom;
}
+ // alias for set(l, t, r, b)
+ void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom) {
+ this->set(left, top, right, bottom);
+ }
void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) {
fLeft = x;
@@ -101,6 +105,23 @@ struct SK_API SkIRect {
fRight = x + width;
fBottom = y + height;
}
+
+ /**
+ * Make the largest representable rectangle
+ */
+ void setLargest() {
+ fLeft = fTop = SK_MinS32;
+ fRight = fBottom = SK_MaxS32;
+ }
+
+ /**
+ * Make the largest representable rectangle, but inverted (e.g. fLeft will
+ * be max 32bit and right will be min 32bit).
+ */
+ void setLargestInverted() {
+ fLeft = fTop = SK_MaxS32;
+ fRight = fBottom = SK_MinS32;
+ }
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
@@ -127,6 +148,10 @@ struct SK_API SkIRect {
fBottom -= dy;
}
+ bool quickReject(int l, int t, int r, int b) const {
+ return l >= fRight || fLeft >= r || t >= fBottom || fTop >= b;
+ }
+
/** Returns true if (x,y) is inside the rectangle and the rectangle is not
empty. The left and top are considered to be inside, while the right
and bottom are not. Thus for the rectangle (0, 0, 5, 10), the
@@ -263,6 +288,11 @@ struct SK_API SkIRect {
When this returns, left <= right && top <= bottom
*/
void sort();
+
+ static const SkIRect& EmptyIRect() {
+ static const SkIRect gEmpty = {0,0,0,0};
+ return gEmpty;
+ }
};
/** \struct SkRect
@@ -304,6 +334,10 @@ struct SK_API SkRect {
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
bool hasValidCoordinates() const;
+ SkScalar left() const { return fLeft; }
+ SkScalar top() const { return fTop; }
+ SkScalar right() const { return fRight; }
+ SkScalar bottom() const { return fBottom; }
SkScalar width() const { return fRight - fLeft; }
SkScalar height() const { return fBottom - fTop; }
SkScalar centerX() const { return SkScalarHalf(fLeft + fRight); }
@@ -338,7 +372,11 @@ struct SK_API SkRect {
fRight = right;
fBottom = bottom;
}
-
+ // alias for set(l, t, r, b)
+ void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) {
+ this->set(left, top, right, bottom);
+ }
+
/** Initialize the rect with the 4 specified integers. The routine handles
converting them to scalars (by calling SkIntToScalar)
*/
@@ -355,6 +393,11 @@ struct SK_API SkRect {
*/
void set(const SkPoint pts[], int count);
+ // alias for set(pts, count)
+ void setBounds(const SkPoint pts[], int count) {
+ this->set(pts, count);
+ }
+
void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height) {
fLeft = x;
fTop = y;
@@ -362,6 +405,23 @@ struct SK_API SkRect {
fBottom = y + height;
}
+ /**
+ * Make the largest representable rectangle
+ */
+ void setLargest() {
+ fLeft = fTop = SK_ScalarMin;
+ fRight = fBottom = SK_ScalarMax;
+ }
+
+ /**
+ * Make the largest representable rectangle, but inverted (e.g. fLeft will
+ * be max and right will be min).
+ */
+ void setLargestInverted() {
+ fLeft = fTop = SK_ScalarMax;
+ fRight = fBottom = SK_ScalarMin;
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
@@ -400,9 +460,10 @@ struct SK_API SkRect {
*/
bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
- /** Return true if this rectangle is not empty, and the specified sides of
- a rectangle are not empty, and they intersect.
- */
+ /**
+ * Return true if this rectangle is not empty, and the specified sides of
+ * a rectangle are not empty, and they intersect.
+ */
bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const {
return // first check that both are not empty
left < right && top < bottom &&
@@ -412,18 +473,20 @@ struct SK_API SkRect {
fTop < bottom && top < fBottom;
}
- /** Return true if rectangles a and b are not empty and intersect.
- */
+ /**
+ * Return true if rectangles a and b are not empty and intersect.
+ */
static bool Intersects(const SkRect& a, const SkRect& b) {
- return !a.isEmpty() && !b.isEmpty() && // check for empties
- a.fLeft < b.fRight && b.fLeft < a.fRight &&
- a.fTop < b.fBottom && b.fTop < a.fBottom;
+ return !a.isEmpty() && !b.isEmpty() &&
+ a.fLeft < b.fRight && b.fLeft < a.fRight &&
+ a.fTop < b.fBottom && b.fTop < a.fBottom;
}
- /** Update this rectangle to enclose itself and the specified rectangle.
- If this rectangle is empty, just set it to the specified rectangle. If the specified
- rectangle is empty, do nothing.
- */
+ /**
+ * Update this rectangle to enclose itself and the specified rectangle.
+ * If this rectangle is empty, just set it to the specified rectangle.
+ * If the specified rectangle is empty, do nothing.
+ */
void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
/** Update this rectangle to enclose itself and the specified rectangle.
@@ -433,61 +496,89 @@ struct SK_API SkRect {
void join(const SkRect& r) {
this->join(r.fLeft, r.fTop, r.fRight, r.fBottom);
}
+ // alias for join()
+ void growToInclude(const SkRect& r) { this->join(r); }
+
+ /**
+ * Grow the rect to include the specified (x,y). After this call, the
+ * following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom.
+ *
+ * This is close, but not quite the same contract as contains(), since
+ * contains() treats the left and top different from the right and bottom.
+ * contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note
+ * that contains(x,y) always returns false if the rect is empty.
+ */
+ void growToInclude(SkScalar x, SkScalar y) {
+ fLeft = SkMinScalar(x, fLeft);
+ fRight = SkMaxScalar(x, fRight);
+ fTop = SkMinScalar(y, fTop);
+ fBottom = SkMaxScalar(y, fBottom);
+ }
- /** Returns true if (p.fX,p.fY) is inside the rectangle. The left and top coordinates of
- the rectangle are considered to be inside, while the right and bottom coordinates
- are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
- while (-1,0) and (5,9) are not.
- If this rectangle is empty, return false.
- */
+ /**
+ * Returns true if (p.fX,p.fY) is inside the rectangle, and the rectangle
+ * is not empty.
+ *
+ * Contains treats the left and top differently from the right and bottom.
+ * The left and top coordinates of the rectangle are themselves considered
+ * to be inside, while the right and bottom are not. Thus for the rectangle
+ * {0, 0, 5, 10}, (0,0) is contained, but (0,10), (5,0) and (5,10) are not.
+ */
bool contains(const SkPoint& p) const {
- return !this->isEmpty() &&
- fLeft <= p.fX && p.fX < fRight &&
- fTop <= p.fY && p.fY < fBottom;
- }
-
- /** Returns true if (x,y) is inside the rectangle. The left and top coordinates of
- the rectangle are considered to be inside, while the right and bottom coordinates
- are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
- while (-1,0) and (5,9) are not.
- If this rectangle is empty, return false.
- */
+ return !this->isEmpty() &&
+ fLeft <= p.fX && p.fX < fRight && fTop <= p.fY && p.fY < fBottom;
+ }
+
+ /**
+ * Returns true if (x,y) is inside the rectangle, and the rectangle
+ * is not empty.
+ *
+ * Contains treats the left and top differently from the right and bottom.
+ * The left and top coordinates of the rectangle are themselves considered
+ * to be inside, while the right and bottom are not. Thus for the rectangle
+ * {0, 0, 5, 10}, (0,0) is contained, but (0,10), (5,0) and (5,10) are not.
+ */
bool contains(SkScalar x, SkScalar y) const {
return !this->isEmpty() &&
- fLeft <= x && x < fRight &&
- fTop <= y && y < fBottom;
+ fLeft <= x && x < fRight && fTop <= y && y < fBottom;
}
- /** Return true if this rectangle contains r.
- If either rectangle is empty, return false.
- */
+ /**
+ * Return true if this rectangle contains r, and if both rectangles are
+ * not empty.
+ */
bool contains(const SkRect& r) const {
- return !r.isEmpty() && !this->isEmpty() && // check for empties
+ return !r.isEmpty() && !this->isEmpty() &&
fLeft <= r.fLeft && fTop <= r.fTop &&
fRight >= r.fRight && fBottom >= r.fBottom;
}
- /** Set the dst integer rectangle by rounding this rectangle's coordinates
- to their nearest integer values.
- */
+ /**
+ * Set the dst rectangle by rounding this rectangle's coordinates to their
+ * nearest integer values using SkScalarRound.
+ */
void round(SkIRect* dst) const {
SkASSERT(dst);
- dst->set(SkScalarRound(fLeft), SkScalarRound(fTop), SkScalarRound(fRight), SkScalarRound(fBottom));
+ dst->set(SkScalarRound(fLeft), SkScalarRound(fTop),
+ SkScalarRound(fRight), SkScalarRound(fBottom));
}
- /** Set the dst integer rectangle by rounding "out" this rectangle, choosing the floor of top and left,
- and the ceiling of right and bototm.
- */
+ /**
+ * Set the dst rectangle by rounding "out" this rectangle, choosing the
+ * SkScalarFloor of top and left, and the SkScalarCeil of right and bottom.
+ */
void roundOut(SkIRect* dst) const {
SkASSERT(dst);
- dst->set(SkScalarFloor(fLeft), SkScalarFloor(fTop), SkScalarCeil(fRight), SkScalarCeil(fBottom));
+ dst->set(SkScalarFloor(fLeft), SkScalarFloor(fTop),
+ SkScalarCeil(fRight), SkScalarCeil(fBottom));
}
- /** Swap top/bottom or left/right if there are flipped.
- This can be called if the edges are computed separately,
- and may have crossed over each other.
- When this returns, left <= right && top <= bottom
- */
+ /**
+ * Swap top/bottom or left/right if there are flipped (i.e. if width()
+ * or height() would have returned a negative value.) This should be called
+ * if the edges are computed separately, and may have crossed over each
+ * other. When this returns, left <= right && top <= bottom
+ */
void sort();
};
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 4fca656..ebe621b 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -53,7 +53,7 @@
#define SK_ScalarMax (3.402823466e+38f)
/** SK_ScalarMin is defined to be the smallest value representable as an SkScalar
*/
- #define SK_ScalarMin (1.175494351e-38f)
+ #define SK_ScalarMin (-SK_ScalarMax)
/** SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
*/
#define SK_ScalarNaN (*(const float*)(const void*)&gIEEENotANumber)
@@ -173,6 +173,9 @@
inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
+ static inline bool SkScalarIsInt(SkScalar x) {
+ return x == (float)(int)x;
+ }
#else
typedef SkFixed SkScalar;
@@ -237,6 +240,10 @@
#define SkMaxScalar(a, b) SkMax32(a, b)
#define SkMinScalar(a, b) SkMin32(a, b)
+
+ static inline bool SkScalarIsInt(SkFixed x) {
+ return 0 == (x & 0xffff);
+ }
#endif
#define SK_ScalarNearlyZero (SK_Scalar1 / (1 << 12))
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 3886b09..c3d8185 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -20,7 +20,7 @@
#include "SkRefCnt.h"
#include "SkScalar.h"
-class SkStream : public SkRefCnt {
+class SK_API SkStream : public SkRefCnt {
public:
virtual ~SkStream();
/** Called to rewind to the beginning of the stream. If this cannot be
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 38604dd..0295b75 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -99,6 +99,7 @@ public:
// these methods edit the string
SkString& operator=(const SkString&);
+ SkString& operator=(const char text[]);
char* writable_str();
char& operator[](size_t n) { return this->writable_str()[n]; }
@@ -144,6 +145,10 @@ public:
void remove(size_t offset, size_t length);
+ SkString& operator+=(const SkString& s) { this->append(s); return *this; }
+ SkString& operator+=(const char text[]) { this->append(text); return *this; }
+ SkString& operator+=(const char c) { this->append(&c, 1); return *this; }
+
/**
* Swap contents between this and other. This function is guaranteed
* to never fail or throw.
diff --git a/include/core/SkThread_platform.h b/include/core/SkThread_platform.h
index c6fd058..f33f5dc 100644
--- a/include/core/SkThread_platform.h
+++ b/include/core/SkThread_platform.h
@@ -41,12 +41,12 @@ public:
/** Implemented by the porting layer, this function adds 1 to the int specified
by the address (in a thread-safe manner), and returns the previous value.
*/
-int32_t sk_atomic_inc(int32_t* addr);
+SK_API int32_t sk_atomic_inc(int32_t* addr);
/** Implemented by the porting layer, this function subtracts 1 to the int
specified by the address (in a thread-safe manner), and returns the previous
value.
*/
-int32_t sk_atomic_dec(int32_t* addr);
+SK_API int32_t sk_atomic_dec(int32_t* addr);
class SkMutex {
public:
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index c415329..e13a21d 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -24,6 +24,8 @@ class SkStream;
class SkAdvancedTypefaceMetrics;
class SkWStream;
+typedef uint32_t SkFontID;
+
/** \class SkTypeface
The SkTypeface class specifies the typeface and intrinsic style of a font.
@@ -65,13 +67,13 @@ public:
/** Return a 32bit value for this typeface, unique for the underlying font
data. Will never return 0.
*/
- uint32_t uniqueID() const { return fUniqueID; }
+ SkFontID uniqueID() const { return fUniqueID; }
/** Return the uniqueID for the specified typeface. If the face is null,
resolve it to the default font and return its uniqueID. Will never
return 0.
*/
- static uint32_t UniqueID(const SkTypeface* face);
+ static SkFontID UniqueID(const SkTypeface* face);
/** Returns true if the two typefaces reference the same underlying font,
handling either being null (treating null as the default font)
@@ -147,11 +149,11 @@ public:
protected:
/** uniqueID must be unique (please!) and non-zero
*/
- SkTypeface(Style style, uint32_t uniqueID, bool isFixedWidth = false)
- : fUniqueID(uniqueID), fStyle(style), fIsFixedWidth(isFixedWidth) {}
+ SkTypeface(Style style, SkFontID uniqueID, bool isFixedWidth = false);
+ virtual ~SkTypeface();
private:
- uint32_t fUniqueID;
+ SkFontID fUniqueID;
Style fStyle;
bool fIsFixedWidth;
diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h
index aeeb37d..8e133c2 100644
--- a/include/core/SkWriter32.h
+++ b/include/core/SkWriter32.h
@@ -32,9 +32,23 @@ public:
fMinSize = minSize;
fSize = 0;
fHead = fTail = NULL;
+ fSingleBlock = NULL;
}
~SkWriter32();
+ /**
+ * Returns the single block backing the writer, or NULL if the memory is
+ * to be dynamically allocated.
+ */
+ void* getSingleBlock() const { return fSingleBlock; }
+
+ /**
+ * Specify the single block to back the writer, rathern than dynamically
+ * allocating the memory. If block == NULL, then the writer reverts to
+ * dynamic allocation (and resets).
+ */
+ void reset(void* block, size_t size);
+
bool writeBool(bool value) {
this->writeInt(value);
return value;
@@ -70,6 +84,14 @@ public:
// write count bytes (must be a multiple of 4)
void writeMul4(const void* values, size_t size) {
+ this->write(values, size);
+ }
+
+ /**
+ * Write size bytes from values. size must be a multiple of 4, though
+ * values need not be 4-byte aligned.
+ */
+ void write(const void* values, size_t size) {
SkASSERT(SkAlign4(size) == size);
// if we could query how much is avail in the current block, we might
// copy that much, and then alloc the rest. That would reduce the waste
@@ -83,7 +105,7 @@ public:
uint32_t size() const { return fSize; }
void reset();
uint32_t* reserve(size_t size); // size MUST be multiple of 4
-
+
// return the address of the 4byte int at the specified offset (which must
// be a multiple of 4. This does not allocate any new space, so the returned
// address is only valid for 1 int.
@@ -101,11 +123,14 @@ public:
private:
size_t fMinSize;
uint32_t fSize;
+
+ char* fSingleBlock;
+ uint32_t fSingleBlockSize;
struct Block;
Block* fHead;
Block* fTail;
-
+
Block* newBlock(size_t bytes);
};
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index e954633..4d46bb9 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -40,7 +40,7 @@ public:
const SkAlpha aa[]);
virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
const SkAlpha aa[]);
-
+
/** Enum of possible coefficients to describe some xfermodes
*/
enum Coeff {
@@ -54,18 +54,18 @@ public:
kISA_Coeff, /** inverse src alpha (i.e. 1 - sa) */
kDA_Coeff, /** dst alpha */
kIDA_Coeff, /** inverse dst alpha (i.e. 1 - da) */
-
+
kCoeffCount
};
-
+
/** If the xfermode can be expressed as an equation using the coefficients
in Coeff, then asCoeff() returns true, and sets (if not null) src and
dst accordingly.
-
+
result = src_coeff * src_color + dst_coeff * dst_color;
-
+
As examples, here are some of the porterduff coefficients
-
+
MODE SRC_COEFF DST_COEFF
clear zero zero
src one zero
@@ -75,6 +75,12 @@ public:
*/
virtual bool asCoeff(Coeff* src, Coeff* dst);
+ /**
+ * The same as calling xfermode->asCoeff(..), except that this also checks
+ * if the xfermode is NULL, and if so, treats its as kSrcOver_Mode.
+ */
+ static bool AsCoeff(SkXfermode*, Coeff* src, Coeff* dst);
+
/** List of predefined xfermodes.
The algebra for the modes uses the following symbols:
Sa, Sc - source alpha and color
@@ -115,13 +121,19 @@ public:
kLastMode = kExclusion_Mode
};
- /** If the xfermode is one of the modes in the Mode enum, then asMode()
- returns true and sets (if not null) mode accordingly.
- This is a better version of IsMode(), which is only able to report
- about modes that are expressible as coefficients.
+ /**
+ * If the xfermode is one of the modes in the Mode enum, then asMode()
+ * returns true and sets (if not null) mode accordingly. Otherwise it
+ * returns false and ignores the mode parameter.
*/
virtual bool asMode(Mode* mode);
+ /**
+ * The same as calling xfermode->asMode(mode), except that this also checks
+ * if the xfermode is NULL, and if so, treats its as kSrcOver_Mode.
+ */
+ static bool AsMode(SkXfermode*, Mode* mode);
+
/** Return an SkXfermode object for the specified mode.
*/
static SkXfermode* Create(Mode mode);
@@ -138,23 +150,27 @@ public:
*/
static SkXfermodeProc16 GetProc16(Mode mode, SkColor srcColor);
- /** If the specified xfermode advertises itself as one of the porterduff
- modes (via SkXfermode::Coeff), return true and if not null, set mode
- to the corresponding porterduff mode. If it is not recognized as a one,
- return false and ignore the mode parameter.
+ /**
+ * If the specified mode can be represented by a pair of Coeff, then return
+ * true and set (if not NULL) the corresponding coeffs. If the mode is
+ * not representable as a pair of Coeffs, return false and ignore the
+ * src and dst parameters.
*/
- static bool IsMode(SkXfermode*, Mode* mode);
+ static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst);
- Mode fMode;
+ // DEPRECATED: call AsMode(...)
+ static bool IsMode(SkXfermode* xfer, Mode* mode) {
+ return AsMode(xfer, mode);
+ }
protected:
SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {}
-
+
/** The default implementation of xfer32/xfer16/xferA8 in turn call this
method, 1 color at a time (upscaled to a SkPMColor). The default
implmentation of this method just returns dst. If performance is
important, your subclass should override xfer32/xfer16/xferA8 directly.
-
+
This method will not be called directly by the client, so it need not
be implemented if your subclass has overridden xfer32/xfer16/xferA8
*/
@@ -191,14 +207,13 @@ public:
// overrides from SkFlattenable
virtual Factory getFactory() { return CreateProc; }
virtual void flatten(SkFlattenableWriteBuffer&);
- virtual bool asMode(SkXfermode::Mode* mode);
protected:
SkProcXfermode(SkFlattenableReadBuffer&);
private:
SkXfermodeProc fProc;
-
+
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkProcXfermode, (buffer)); }
@@ -206,4 +221,3 @@ private:
};
#endif
-
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 6e54d0a..02ec760 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -27,14 +27,14 @@ public:
// overrides
// This method is not exported to java.
- virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+ virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
// overrides from SkFlattenable
// This method is not exported to java.
- virtual void flatten(SkFlattenableWriteBuffer&);
+ virtual void flatten(SkFlattenableWriteBuffer&);
// This method is not exported to java.
- virtual Factory getFactory();
+ virtual Factory getFactory();
protected:
/** New virtual, to be overridden by subclasses.
diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h
index 9af4a4b..b52e6f5 100644
--- a/include/effects/SkAvoidXfermode.h
+++ b/include/effects/SkAvoidXfermode.h
@@ -33,14 +33,14 @@ public:
/** This xfermode draws, or doesn't draw, based on the destination's
distance from an op-color.
-
+
There are two modes, and each mode interprets a tolerance value.
-
+
Avoid: In this mode, drawing is allowed only on destination pixels that
are different from the op-color.
Tolerance near 0: avoid any colors even remotely similar to the op-color
Tolerance near 255: avoid only colors nearly identical to the op-color
-
+
Target: In this mode, drawing only occurs on destination pixels that
are similar to the op-color
Tolerance near 0: draw only on colors that are nearly identical to the op-color
@@ -62,6 +62,10 @@ public:
virtual Factory getFactory();
virtual void flatten(SkFlattenableWriteBuffer&);
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
+ return SkNEW_ARGS(SkAvoidXfermode, (buffer));
+ }
+
protected:
SkAvoidXfermode(SkFlattenableReadBuffer&);
@@ -69,9 +73,9 @@ private:
SkColor fOpColor;
uint32_t fDistMul; // x.14
Mode fMode;
-
+
static SkFlattenable* Create(SkFlattenableReadBuffer&);
-
+
typedef SkXfermode INHERITED;
};
diff --git a/include/effects/SkBlurMaskFilter.h b/include/effects/SkBlurMaskFilter.h
index 0a0e8d2..daca68d 100644
--- a/include/effects/SkBlurMaskFilter.h
+++ b/include/effects/SkBlurMaskFilter.h
@@ -21,7 +21,7 @@
#include "SkMaskFilter.h"
#include "SkScalar.h"
-class SkBlurMaskFilter {
+class SK_API SkBlurMaskFilter {
public:
enum BlurStyle {
kNormal_BlurStyle, //!< fuzzy inside and outside
diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h
index f9194df..d8ef81c 100644
--- a/include/effects/SkColorMatrixFilter.h
+++ b/include/effects/SkColorMatrixFilter.h
@@ -25,15 +25,15 @@ public:
SkColorMatrixFilter();
explicit SkColorMatrixFilter(const SkColorMatrix&);
SkColorMatrixFilter(const SkScalar array[20]);
-
+
void setMatrix(const SkColorMatrix&);
void setArray(const SkScalar array[20]);
-
+
// overrides from SkColorFilter
virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]);
virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]);
virtual uint32_t getFlags();
-
+
// overrides for SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer& buffer);
@@ -43,14 +43,15 @@ public:
int32_t fResult[4];
};
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer);
+
protected:
// overrides for SkFlattenable
virtual Factory getFactory();
-
+
SkColorMatrixFilter(SkFlattenableReadBuffer& buffer);
-
+
private:
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer);
typedef void (*Proc)(State*, unsigned r, unsigned g, unsigned b,
unsigned a);
@@ -58,9 +59,9 @@ private:
Proc fProc;
State fState;
uint32_t fFlags;
-
+
void setup(const SkScalar array[20]);
-
+
typedef SkColorFilter INHERITED;
};
diff --git a/include/effects/SkEmbossMaskFilter.h b/include/effects/SkEmbossMaskFilter.h
index 042a2a6..b0c12c5 100644
--- a/include/effects/SkEmbossMaskFilter.h
+++ b/include/effects/SkEmbossMaskFilter.h
@@ -38,7 +38,8 @@ public:
// This method is not exported to java.
virtual SkMask::Format getFormat();
// This method is not exported to java.
- virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin);
+ virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
+ SkIPoint* margin);
// overrides from SkFlattenable
diff --git a/include/effects/SkKernel33MaskFilter.h b/include/effects/SkKernel33MaskFilter.h
index 84136e2..45aaef8 100644
--- a/include/effects/SkKernel33MaskFilter.h
+++ b/include/effects/SkKernel33MaskFilter.h
@@ -47,8 +47,7 @@ private:
class SkKernel33MaskFilter : public SkKernel33ProcMaskFilter {
public:
SkKernel33MaskFilter(const int coeff[3][3], int shift, int percent256 = 256)
- : SkKernel33ProcMaskFilter(percent256)
- {
+ : SkKernel33ProcMaskFilter(percent256) {
memcpy(fKernel, coeff, 9 * sizeof(int));
fShift = shift;
}
diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h
index b487a88..8627ae4 100644
--- a/include/effects/SkLayerDrawLooper.h
+++ b/include/effects/SkLayerDrawLooper.h
@@ -6,7 +6,7 @@
struct SkPoint;
-class SkLayerDrawLooper : public SkDrawLooper {
+class SK_API SkLayerDrawLooper : public SkDrawLooper {
public:
SkLayerDrawLooper();
virtual ~SkLayerDrawLooper();
@@ -33,6 +33,12 @@ public:
/**
* Info for how to apply the layer's paint and offset.
*
+ * fFlagsMask selects which flags in the layer's paint should be applied.
+ * result = (draw-flags & ~fFlagsMask) | (layer-flags & fFlagsMask)
+ * In the extreme:
+ * If fFlagsMask is 0, we ignore all of the layer's flags
+ * If fFlagsMask is -1, we use all of the layer's flags
+ *
* fColorMode controls how we compute the final color for the layer:
* The layer's paint's color is treated as the SRC
* The draw's paint's color is treated as the DST
@@ -41,7 +47,8 @@ public:
* kSrc_Mode: to use the layer's color, ignoring the draw's
* kDst_Mode: to just keep the draw's color, ignoring the layer's
*/
- struct LayerInfo {
+ struct SK_API LayerInfo {
+ uint32_t fFlagsMask; // SkPaint::Flags
BitFlags fPaintBits;
SkXfermode::Mode fColorMode;
SkVector fOffset;
@@ -60,29 +67,19 @@ public:
/**
* Call for each layer you want to add (from top to bottom).
* This returns a paint you can modify, but that ptr is only valid until
- * the next call made to this object.
+ * the next call made to addLayer().
*/
SkPaint* addLayer(const LayerInfo&);
/**
- * Call for each layer you want to add (from top to bottom).
- * This returns a paint you can modify, but that ptr is only valid until
- * the next call made to this object.
- * The returned paint will be ignored, and only the offset will be applied
- *
- * DEPRECATED: call addLayer(const LayerInfo&)
+ * This layer will draw with the original paint, ad the specified offset
*/
- SkPaint* addLayer(SkScalar dx, SkScalar dy);
+ void addLayer(SkScalar dx, SkScalar dy);
/**
- * Helper for addLayer() which passes (0, 0) for the offset parameters.
- * This layer will not affect the drawing in any way.
- *
- * DEPRECATED: call addLayer(const LayerInfo&)
+ * This layer will with the original paint and no offset.
*/
- SkPaint* addLayer() {
- return this->addLayer(0, 0);
- }
+ void addLayer() { this->addLayer(0, 0); }
// overrides from SkDrawLooper
virtual void init(SkCanvas*);
@@ -114,8 +111,7 @@ private:
// state-machine during the init/next cycle
Rec* fCurrRec;
- static void ApplyBits(SkPaint* dst, const SkPaint& src, BitFlags,
- SkXfermode::Mode);
+ static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&);
class MyRegistrar : public SkFlattenable::Registrar {
public:
diff --git a/include/effects/SkLayerRasterizer.h b/include/effects/SkLayerRasterizer.h
index 820f6fc..0373b05 100644
--- a/include/effects/SkLayerRasterizer.h
+++ b/include/effects/SkLayerRasterizer.h
@@ -28,8 +28,7 @@ public:
SkLayerRasterizer();
virtual ~SkLayerRasterizer();
- void addLayer(const SkPaint& paint)
- {
+ void addLayer(const SkPaint& paint) {
this->addLayer(paint, 0, 0);
}
diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h
index 369e0e5..1957c9e 100644
--- a/include/effects/SkPixelXorXfermode.h
+++ b/include/effects/SkPixelXorXfermode.h
@@ -32,6 +32,10 @@ public:
virtual Factory getFactory();
virtual void flatten(SkFlattenableWriteBuffer&);
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
+ return SkNEW_ARGS(SkPixelXorXfermode, (buffer));
+ }
+
protected:
// override from SkXfermode
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst);
@@ -47,4 +51,3 @@ private:
};
#endif
-
diff --git a/include/effects/SkTransparentShader.h b/include/effects/SkTransparentShader.h
index 8bc60ff..5e87609 100644
--- a/include/effects/SkTransparentShader.h
+++ b/include/effects/SkTransparentShader.h
@@ -31,8 +31,7 @@ public:
// overrides for SkFlattenable
virtual Factory getFactory() { return Create; }
- virtual void flatten(SkFlattenableWriteBuffer& buffer)
- {
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
}
@@ -43,8 +42,7 @@ private:
SkTransparentShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
- static SkFlattenable* Create(SkFlattenableReadBuffer& buffer)
- {
+ static SkFlattenable* Create(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkTransparentShader, (buffer));
}
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index fbe5929..15def87 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -75,6 +75,7 @@ public:
// overrides from SkDevice
+ virtual void clear(SkColor color);
virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
virtual void writePixels(const SkBitmap& bitmap, int x, int y);
@@ -120,6 +121,9 @@ public:
virtual void makeRenderTargetCurrent();
protected:
+ // override
+ virtual SkDeviceFactory* onNewDeviceFactory();
+
class TexCache;
TexCache* lockCachedTexture(const SkBitmap& bitmap,
const GrSamplerState& sampler,
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index 10f1bd0..75099b2 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -104,27 +104,8 @@ GR_STATIC_ASSERT((int)SkPath::kDone_Verb == (int)kEnd_PathCmd);
#include "SkColorPriv.h"
-static inline GrRect Sk2Gr(const SkRect& src) {
- return GrRect(SkScalarToGrScalar(src.fLeft),
- SkScalarToGrScalar(src.fTop),
- SkScalarToGrScalar(src.fRight),
- SkScalarToGrScalar(src.fBottom));
-}
-
class SkGr {
public:
- static inline SkIRect& SetIRect(SkIRect* dst, const GrIRect& src) {
- GR_STATIC_ASSERT(sizeof(*dst) == sizeof(src));
- memcpy(dst, &src, sizeof(*dst));
- return *dst;
- }
-
- static inline GrIRect& SetIRect(GrIRect* dst, const SkIRect& src) {
- GR_STATIC_ASSERT(sizeof(*dst) == sizeof(src));
- memcpy(dst, &src, sizeof(*dst));
- return *dst;
- }
-
/**
* Convert the SkBitmap::Config to the corresponding PixelConfig, or
* kUnknown_PixelConfig if the conversion cannot be done.
@@ -136,18 +117,6 @@ public:
return BitmapConfig2PixelConfig(bm.config(), bm.isOpaque());
}
- static void SkMatrix2GrMatrix(const SkMatrix& m, GrMatrix* g) {
- g->setAll(SkScalarToGrScalar(m[0]),
- SkScalarToGrScalar(m[1]),
- SkScalarToGrScalar(m[2]),
- SkScalarToGrScalar(m[3]),
- SkScalarToGrScalar(m[4]),
- SkScalarToGrScalar(m[5]),
- SkScalarToGrScalar(m[6]),
- SkScalarToGrScalar(m[7]),
- SkScalarToGrScalar(m[8]));
- }
-
static GrColor SkColor2GrColor(SkColor c) {
SkPMColor pm = SkPreMultiplyColor(c);
unsigned r = SkGetPackedR32(pm);
@@ -169,6 +138,7 @@ public:
virtual GrPathCmd next();
virtual void rewind();
virtual GrConvexHint convexHint() const;
+ virtual bool getConservativeBounds(GrRect* rect) const;
void reset(const SkPath& path) {
fPath = &path;
@@ -202,7 +172,7 @@ public:
if (!fCurr->fRect) {
rect->setEmpty();
} else {
- *rect = Sk2Gr(*fCurr->fRect);
+ *rect = *fCurr->fRect;
}
}
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index 98ef778..6e55aa6 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -21,8 +21,6 @@ public:
// overrides from SkCanvas
- virtual bool getViewport(SkIPoint* size) const;
-
virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags = kARGB_ClipLayer_SaveFlag);
diff --git a/include/utils/unix/XkeysToSkKeys.h b/include/utils/unix/XkeysToSkKeys.h
new file mode 100644
index 0000000..3d41a22
--- /dev/null
+++ b/include/utils/unix/XkeysToSkKeys.h
@@ -0,0 +1,23 @@
+#include "X11/Xlib.h"
+#include "X11/keysym.h"
+
+#include "SkKey.h"
+
+#ifndef XKEYS_TOSKKEYS_H
+#define XKEYS_TOSKKEYS_H
+
+SkKey XKeyToSkKey(KeySym keysym) {
+ switch (keysym) {
+ case XK_Right:
+ return kRight_SkKey;
+ case XK_Left:
+ return kLeft_SkKey;
+ case XK_Down:
+ return kDown_SkKey;
+ case XK_Up:
+ return kUp_SkKey;
+ default:
+ return kNONE_SkKey;
+ }
+}
+#endif
diff --git a/include/utils/unix/keysym2ucs.h b/include/utils/unix/keysym2ucs.h
new file mode 100644
index 0000000..1ae6fe4
--- /dev/null
+++ b/include/utils/unix/keysym2ucs.h
@@ -0,0 +1,8 @@
+/*
+ * This module converts keysym values into the corresponding ISO 10646-1
+ * (UCS, Unicode) values.
+ */
+
+#include <X11/X.h>
+
+long keysym2ucs(KeySym keysym);