aboutsummaryrefslogtreecommitdiffstats
path: root/include/core
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-02-24 11:04:57 -0500
committerDerek Sollenberger <djsollen@google.com>2011-02-24 13:10:51 -0500
commit71531ca1f484da5837be8017a0c83e5bff701587 (patch)
tree36512f8dbc615cd9e80b20eff47c0400eb1aa52b /include/core
parent7157c81e3a5c916ab44a02273b140e1cd8a6d1bb (diff)
downloadexternal_skia-71531ca1f484da5837be8017a0c83e5bff701587.zip
external_skia-71531ca1f484da5837be8017a0c83e5bff701587.tar.gz
external_skia-71531ca1f484da5837be8017a0c83e5bff701587.tar.bz2
Skia Merge (revision 842)
This merge picks up the fixed width font updates and improved blur code from the Skia repository. Change-Id: Iad2301a353c31da27ca214527cf4ed8f24641749
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkCanvas.h19
-rw-r--r--include/core/SkClipStack.h65
-rw-r--r--include/core/SkDeque.h8
-rw-r--r--include/core/SkDevice.h18
-rw-r--r--include/core/SkScalerContext.h4
-rw-r--r--include/core/SkTypeface.h23
6 files changed, 116 insertions, 21 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index b2a9fa9..103507c 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -20,6 +20,7 @@
#include "SkTypes.h"
#include "SkBitmap.h"
#include "SkDeque.h"
+#include "SkClipStack.h"
#include "SkPaint.h"
#include "SkRefCnt.h"
#include "SkPath.h"
@@ -789,6 +790,7 @@ protected:
private:
class MCRec;
+ SkClipStack fClipStack;
SkDeque fMCStack;
// points to top of stack
MCRec* fMCRec;
@@ -848,6 +850,23 @@ private:
SkMatrix fExternalMatrix, fExternalInverse;
bool fUseExternalMatrix;
+
+ class AutoValidateClip : ::SkNoncopyable {
+ public:
+ explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) {
+ fCanvas->validateClip();
+ }
+ ~AutoValidateClip() { fCanvas->validateClip(); }
+
+ private:
+ const SkCanvas* fCanvas;
+ };
+
+#ifdef SK_DEBUG
+ void validateClip() const;
+#else
+ void validateClip() const {}
+#endif
};
/** Stack helper class to automatically call restoreToCount() on the canvas
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
new file mode 100644
index 0000000..fb94155
--- /dev/null
+++ b/include/core/SkClipStack.h
@@ -0,0 +1,65 @@
+#ifndef SkClipStack_DEFINED
+#define SkClipStack_DEFINED
+
+#include "SkDeque.h"
+#include "SkRegion.h"
+
+struct SkRect;
+class SkPath;
+
+class SkClipStack {
+public:
+ SkClipStack();
+ ~SkClipStack() {}
+
+ void reset();
+
+ int getSaveCount() const { return fSaveCount; }
+ void save();
+ void restore();
+
+ void clipDevRect(const SkIRect& ir,
+ SkRegion::Op op = SkRegion::kIntersect_Op) {
+ SkRect r;
+ r.set(ir);
+ this->clipDevRect(r, op);
+ }
+ void clipDevRect(const SkRect&, SkRegion::Op = SkRegion::kIntersect_Op);
+ void clipDevPath(const SkPath&, SkRegion::Op = SkRegion::kIntersect_Op);
+
+ class B2FIter {
+ public:
+ B2FIter(const SkClipStack& stack);
+
+ struct Clip {
+ 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;
+ };
+
+ /**
+ * Return the clip for this element in the iterator. If next() returns
+ * NULL, then the iterator is done. The type of clip is determined by
+ * the pointers fRect and fPath:
+ *
+ * fRect==NULL fPath!=NULL path clip
+ * fRect!=NULL fPath==NULL rect clip
+ * fRect==NULL fPath==NULL empty clip
+ */
+ const Clip* next();
+
+ private:
+ Clip fClip;
+ SkDeque::F2BIter fIter;
+ };
+
+private:
+ friend class B2FIter;
+ struct Rec;
+
+ SkDeque fDeque;
+ int fSaveCount;
+};
+
+#endif
+
diff --git a/include/core/SkDeque.h b/include/core/SkDeque.h
index cbed930..99c8dd4 100644
--- a/include/core/SkDeque.h
+++ b/include/core/SkDeque.h
@@ -42,7 +42,7 @@ public:
void* push_front();
void* push_back();
-
+
void pop_front();
void pop_back();
@@ -50,9 +50,9 @@ private:
struct Head;
public:
- class Iter {
+ class F2BIter {
public:
- Iter(const SkDeque& d);
+ F2BIter(const SkDeque& d);
void* next();
private:
@@ -67,7 +67,7 @@ private:
size_t fElemSize;
void* fInitialStorage;
int fCount;
-
+
friend class Iter;
};
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 1b4630d..7791f34 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -23,6 +23,7 @@
#include "SkColor.h"
#include "SkRefDict.h"
+class SkClipStack;
class SkDevice;
class SkDraw;
struct SkIRect;
@@ -122,11 +123,20 @@ public:
*/
virtual SkGpuTexture* accessTexture() { return NULL; }
- /** Called with the correct matrix and clip before this device is drawn
- to using those settings. If your subclass overrides this, be sure to
- call through to the base class as well.
+ /**
+ * Called with the correct matrix and clip before this device is drawn
+ * to using those settings. If your subclass overrides this, be sure to
+ * call through to the base class as well.
+ *
+ * The clipstack is another view of the clip. It records the actual
+ * geometry that went into building the region. It is present for devices
+ * that want to parse it, but is not required: the region is a complete
+ * picture of the current clip. (i.e. if you regionize all of the geometry
+ * in the clipstack, you will arrive at an equivalent region to the one
+ * passed in).
*/
- virtual void setMatrixClip(const SkMatrix&, const SkRegion&);
+ virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
+ const SkClipStack&);
/** Called when this device gains focus (i.e becomes the current device
for drawing).
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index 0c93e2e..5937819 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -51,10 +51,6 @@ struct SkGlyph {
fImage = NULL;
fPath = NULL;
fMaskFormat = MASK_FORMAT_UNKNOWN;
-#ifdef SK_GPU_AWARE_GLYPHCACHE
- fGLCacheOffset = SKGLYPH_GLCACHEOFFSET_INVALID;
- fGLStrikePtr = NULL;
-#endif
}
unsigned rowBytes() const {
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index cea6ab1..728ba31 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -56,7 +56,11 @@ public:
/** Returns true if getStyle() has the kItalic bit set.
*/
bool isItalic() const { return (fStyle & kItalic) != 0; }
-
+
+ /** Returns true if the typeface is fixed-width
+ */
+ bool isFixedWidth() const { return fIsFixedWidth; }
+
/** Return a 32bit value for this typeface, unique for the underlying font
data. Will never return 0.
*/
@@ -72,11 +76,11 @@ public:
handling either being null (treating null as the default font)
*/
static bool Equal(const SkTypeface* facea, const SkTypeface* faceb);
-
+
/** Return a new reference to the typeface that most closely matches the
requested familyName and style. Pass null as the familyName to return
the default font for the requested style. Will never return null
-
+
@param familyName May be NULL. The name of the font family.
@param style The style (normal, bold, italic) of the typeface.
@return reference to the closest-matching typeface. Call must call
@@ -100,7 +104,7 @@ public:
requested typeface and specified Style. Use this call if you want to
pick a new style from the same family of the existing typeface.
If family is NULL, this selects from the default font's family.
-
+
@param family May be NULL. The name of the existing type face.
@param s The style (normal, bold, italic) of the type face.
@return reference to the closest-matching typeface. Call must call
@@ -112,7 +116,7 @@ public:
not a valid font file, returns null.
*/
static SkTypeface* CreateFromFile(const char path[]);
-
+
/** Return a new typeface given a stream. If the stream is
not a valid font file, returns null. Ownership of the stream is
transferred, so the caller must not reference it again.
@@ -123,7 +127,7 @@ public:
typeface referencing the same font when Deserialize is called.
*/
void serialize(SkWStream*) const;
-
+
/** Given the data previously written by serialize(), return a new instance
to a typeface referring to the same font. If that font is not available,
return null. If an instance is returned, the caller is responsible for
@@ -142,13 +146,14 @@ public:
protected:
/** uniqueID must be unique (please!) and non-zero
*/
- SkTypeface(Style style, uint32_t uniqueID)
- : fUniqueID(uniqueID), fStyle(style) {}
+ SkTypeface(Style style, uint32_t uniqueID, bool isFixedWidth = false)
+ : fUniqueID(uniqueID), fStyle(style), fIsFixedWidth(isFixedWidth) {}
private:
uint32_t fUniqueID;
Style fStyle;
-
+ bool fIsFixedWidth;
+
typedef SkRefCnt INHERITED;
};