aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-03-14 11:20:24 -0400
committerDerek Sollenberger <djsollen@google.com>2011-03-14 16:33:36 -0400
commit05b6b4d746867a9fb02e14edfe1bf3685abeb813 (patch)
tree34b121f598d1693c014df48ee70bffa382b0cc23 /include
parent6210a7c68844602ee390bcce61dbb637910a3c6b (diff)
downloadexternal_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.zip
external_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.tar.gz
external_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.tar.bz2
Skia Merge (revision 922)
Change-Id: I7ed57d10905d8bad6486a4d7410165eec1cc2b4f
Diffstat (limited to 'include')
-rw-r--r--include/config/SkUserConfig.h140
-rw-r--r--include/core/SkBitmap.h19
-rw-r--r--include/core/SkBlitRow.h35
-rw-r--r--include/core/SkCanvas.h11
-rw-r--r--include/core/SkClipStack.h10
-rw-r--r--include/core/SkColorShader.h15
-rw-r--r--include/core/SkDeque.h7
-rw-r--r--include/core/SkDevice.h17
-rw-r--r--include/core/SkDraw.h6
-rw-r--r--include/core/SkFontHost.h2
-rw-r--r--include/core/SkMask.h19
-rw-r--r--include/core/SkPixelRef.h38
-rw-r--r--include/core/SkPoint.h55
-rw-r--r--include/core/SkRect.h14
-rw-r--r--include/core/SkRefCnt.h69
-rw-r--r--include/core/SkRegion.h4
-rw-r--r--include/core/SkScalerContext.h21
-rw-r--r--include/core/SkShader.h92
-rw-r--r--include/core/SkString.h31
-rw-r--r--include/core/SkTypeface.h2
-rw-r--r--include/core/SkTypes.h67
-rw-r--r--include/core/SkUserConfig.h30
-rw-r--r--include/effects/SkPorterDuff.h2
-rw-r--r--include/gpu/SkGpuCanvas.h68
-rw-r--r--include/gpu/SkGpuDevice.h184
-rw-r--r--include/gpu/SkGpuDeviceFactory.h49
-rw-r--r--include/gpu/SkGr.h298
-rw-r--r--include/gpu/SkGrTexturePixelRef.h50
-rw-r--r--include/graphics/DoxygenMain.dox3
-rw-r--r--include/ports/SkTypeface_win.h31
-rw-r--r--include/svg/SkSVGAttribute.h49
-rw-r--r--include/svg/SkSVGBase.h33
-rw-r--r--include/svg/SkSVGPaintState.h96
-rw-r--r--include/svg/SkSVGParser.h81
-rw-r--r--include/svg/SkSVGTypes.h47
-rw-r--r--include/utils/SkCamera.h2
-rw-r--r--include/views/SkApplication.h26
-rw-r--r--include/views/SkBGViewArtist.h41
-rw-r--r--include/views/SkBorderView.h48
-rw-r--r--include/views/SkEvent.h257
-rw-r--r--include/views/SkEventSink.h103
-rw-r--r--include/views/SkImageView.h75
-rw-r--r--include/views/SkKey.h63
-rw-r--r--include/views/SkMetaData.h164
-rw-r--r--include/views/SkOSMenu.h55
-rw-r--r--include/views/SkOSWindow_Mac.h62
-rw-r--r--include/views/SkOSWindow_SDL.h52
-rw-r--r--include/views/SkOSWindow_Unix.h60
-rw-r--r--include/views/SkOSWindow_Win.h79
-rw-r--r--include/views/SkOSWindow_wxwidgets.h52
-rw-r--r--include/views/SkProgressBarView.h57
-rw-r--r--include/views/SkScrollBarView.h52
-rw-r--r--include/views/SkStackViewLayout.h96
-rw-r--r--include/views/SkSystemEventTypes.h32
-rw-r--r--include/views/SkView.h370
-rw-r--r--include/views/SkViewInflate.h79
-rw-r--r--include/views/SkWidget.h476
-rw-r--r--include/views/SkWidgetViews.h310
-rw-r--r--include/views/SkWindow.h123
59 files changed, 1103 insertions, 3326 deletions
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
deleted file mode 100644
index c0bbb4b..0000000
--- a/include/config/SkUserConfig.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkUserConfig_DEFINED
-#define SkUserConfig_DEFINED
-
-/* SkTypes.h, the root of the public header files, does the following trick:
-
- #include "SkPreConfig.h"
- #include "SkUserConfig.h"
- #include "SkPostConfig.h"
-
- SkPreConfig.h runs first, and it is responsible for initializing certain
- skia defines.
-
- SkPostConfig.h runs last, and its job is to just check that the final
- defines are consistent (i.e. that we don't have mutually conflicting
- defines).
-
- SkUserConfig.h (this file) runs in the middle. It gets to change or augment
- the list of flags initially set in preconfig, and then postconfig checks
- that everything still makes sense.
-
- Below are optional defines that add, subtract, or change default behavior
- in Skia. Your port can locally edit this file to enable/disable flags as
- you choose, or these can be delared on your command line (i.e. -Dfoo).
-
- By default, this include file will always default to having all of the flags
- commented out, so including it will have no effect.
-*/
-
-///////////////////////////////////////////////////////////////////////////////
-
-/* Scalars (the fractional value type in skia) can be implemented either as
- floats or 16.16 integers (fixed). Exactly one of these two symbols must be
- defined.
-*/
-//#define SK_SCALAR_IS_FLOAT
-//#define SK_SCALAR_IS_FIXED
-
-
-/* Somewhat independent of how SkScalar is implemented, Skia also wants to know
- if it can use floats at all. Naturally, if SK_SCALAR_IS_FLOAT is defined,
- then so muse SK_CAN_USE_FLOAT, but if scalars are fixed, SK_CAN_USE_FLOAT
- can go either way.
- */
-//#define SK_CAN_USE_FLOAT
-
-/* For some performance-critical scalar operations, skia will optionally work
- around the standard float operators if it knows that the CPU does not have
- native support for floats. If your environment uses software floating point,
- define this flag.
- */
-//#define SK_SOFTWARE_FLOAT
-
-
-/* Skia has lots of debug-only code. Often this is just null checks or other
- parameter checking, but sometimes it can be quite intrusive (e.g. check that
- each 32bit pixel is in premultiplied form). This code can be very useful
- during development, but will slow things down in a shipping product.
-
- By default, these mutually exclusive flags are defined in SkPreConfig.h,
- based on the presence or absence of NDEBUG, but that decision can be changed
- here.
- */
-//#define SK_DEBUG
-//#define SK_RELEASE
-
-
-/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
- it will call SK_CRASH(). If this is not defined it, it is defined in
- SkPostConfig.h to write to an illegal address
- */
-//#define SK_CRASH() *(int *)(uintptr_t)0 = 0
-
-
-/* preconfig will have attempted to determine the endianness of the system,
- but you can change these mutually exclusive flags here.
- */
-//#define SK_CPU_BENDIAN
-//#define SK_CPU_LENDIAN
-
-
-/* Some compilers don't support long long for 64bit integers. If yours does
- not, define this to the appropriate type.
- */
-//#define SkLONGLONG int64_t
-
-
-/* Some envorinments do not suport writable globals (eek!). If yours does not,
- define this flag.
- */
-//#define SK_USE_RUNTIME_GLOBALS
-
-
-/* To write debug messages to a console, skia will call SkDebugf(...) following
- printf conventions (e.g. const char* format, ...). If you want to redirect
- this to something other than printf, define yours here
- */
-//#define SkDebugf(...) MyFunction(__VA_ARGS__)
-
-/* To enable additional blitters (and fontscaler code) to support separate
- alpha channels for R G B channels, define SK_SUPPORT_LCDTEXT
- */
-//#define SK_SUPPORT_LCDTEXT
-
-/* If zlib is available and you want to support the flate compression
- algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
- include path.
- */
-//#define SK_ZLIB_INCLUDE <zlib.h>
-
-/* Define this to remove dimension checks on bitmaps. Not all blits will be
- correct yet, so this is mostly for debugging the implementation.
- */
-//#define SK_ALLOW_OVER_32K_BITMAPS
-
-/* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
- which will run additional self-tests at startup. These can take a long time,
- so this flag is optional.
- */
-#ifdef SK_DEBUG
-//#define SK_SUPPORT_UNITTEST
-#endif
-
-#endif
-
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 64a2a5b..1d21a2f 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -401,6 +401,13 @@ 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.
*/
inline uint32_t* getAddr32(int x, int y) const;
@@ -461,18 +468,18 @@ public:
*/
int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy);
- void extractAlpha(SkBitmap* dst) const {
- this->extractAlpha(dst, NULL, NULL, NULL);
+ bool extractAlpha(SkBitmap* dst) const {
+ return this->extractAlpha(dst, NULL, NULL, NULL);
}
- void extractAlpha(SkBitmap* dst, const SkPaint* paint,
+ bool extractAlpha(SkBitmap* dst, const SkPaint* paint,
SkIPoint* offset) const {
- this->extractAlpha(dst, paint, NULL, offset);
+ return this->extractAlpha(dst, paint, NULL, offset);
}
/** Set dst to contain alpha layer of this bitmap. If destination bitmap
fails to be initialized, e.g. because allocator can't allocate pixels
- for it, dst will be resetted (zero width and height, no pixels).
+ for it, dst will not be modified and false will be returned.
@param dst The bitmap to be filled with alpha layer
@param paint The paint to draw with
@@ -483,7 +490,7 @@ public:
the returned bitmap so that it visually lines up with the
original
*/
- void extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
+ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
SkIPoint* offset) const;
void flatten(SkFlattenableWriteBuffer&) const;
diff --git a/include/core/SkBlitRow.h b/include/core/SkBlitRow.h
index 2b652c2..bb8cbc2 100644
--- a/include/core/SkBlitRow.h
+++ b/include/core/SkBlitRow.h
@@ -18,9 +18,9 @@ public:
/** Function pointer that reads a scanline of src SkPMColors, and writes
a corresponding scanline of 16bit colors (specific format based on the
config passed to the Factory.
-
+
The x,y params are useful just for dithering
-
+
@param alpha A global alpha to be applied to all of the src colors
@param x The x coordinate of the beginning of the scanline
@param y THe y coordinate of the scanline
@@ -29,7 +29,7 @@ public:
const SkPMColor* SK_RESTRICT src,
int count, U8CPU alpha, int x, int y);
- /** Function pointer that blends a single color with a row of 32-bit colors
+ /** Function pointer that blends a single color with a row of 32-bit colors
onto a 32-bit destination
*/
typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count,
@@ -56,12 +56,12 @@ public:
int count, U8CPU alpha);
static Proc32 Factory32(unsigned flags32);
-
+
/** Blend a single color onto a row of S32 pixels, writing the result
into a row of D32 pixels. src and dst may be the same memory, but
if they are not, they may not overlap.
*/
- static void Color32(SkPMColor dst[], const SkPMColor src[],
+ static void Color32(SkPMColor dst[], const SkPMColor src[],
int count, SkPMColor color);
static ColorProc ColorProcFactory();
@@ -84,4 +84,29 @@ private:
};
};
+/**
+ * Factory for blitmask procs
+ */
+class SkBlitMask {
+public:
+ /**
+ * Function pointer that blits the mask into a device (dst) colorized
+ * by color. The number of pixels to blit is specified by width and height,
+ * but each scanline is offset by dstRB (rowbytes) and srcRB respectively.
+ */
+ typedef void (*Proc)(void* dst, size_t dstRB, SkBitmap::Config dstConfig,
+ const uint8_t* mask, size_t maskRB, SkColor color,
+ int width, int height);
+
+ /* Public entry-point to return a blitmask function ptr
+ */
+ static Proc Factory(SkBitmap::Config dstConfig, SkColor color);
+
+ /* return either platform specific optimized blitmask function-ptr,
+ * or NULL if no optimized
+ */
+ static Proc PlatformProcs(SkBitmap::Config dstConfig, SkColor color);
+};
+
+
#endif
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 103507c..5aecacb 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -626,6 +626,7 @@ public:
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint);
+#ifdef ANDROID
/** Draw the text on path, with each character/glyph origin specified by the pos[]
array. The origin is interpreted by the Align setting in the paint.
@param text The text to be drawn
@@ -638,6 +639,7 @@ public:
void drawPosTextOnPath(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix);
+#endif
/** Draw the picture into this canvas. This method effective brackets the
playback of the picture's draw calls with save/restore, so the state
@@ -740,6 +742,12 @@ public:
*/
const SkRegion& getTotalClip() const;
+ /**
+ * Return the current clipstack. This mirrors the result in getTotalClip()
+ * but is represented as a stack of geometric clips + region-ops.
+ */
+ const SkClipStack& getTotalClipStack() const;
+
void setExternalMatrix(const SkMatrix* = NULL);
///////////////////////////////////////////////////////////////////////////
@@ -801,7 +809,8 @@ private:
SkDevice* fLastDeviceToGainFocus;
SkDeviceFactory* fDeviceFactory;
- void prepareForDeviceDraw(SkDevice*, const SkMatrix&, const SkRegion&);
+ void prepareForDeviceDraw(SkDevice*, const SkMatrix&, const SkRegion&,
+ const SkClipStack& clipStack);
bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
void updateDeviceCMCache();
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index fb94155..db42e4d 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -29,6 +29,11 @@ public:
class B2FIter {
public:
+ /**
+ * Creates an uninitialized iterator. Must be reset()
+ */
+ B2FIter();
+
B2FIter(const SkClipStack& stack);
struct Clip {
@@ -48,6 +53,11 @@ public:
*/
const Clip* next();
+ /**
+ * Restarts the iterator on a clip stack.
+ */
+ void reset(const SkClipStack& stack);
+
private:
Clip fClip;
SkDeque::F2BIter fIter;
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index 44a6148..f7251ff 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -47,17 +47,20 @@ public:
virtual void shadeSpan16(int x, int y, uint16_t span[], int count);
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
- virtual BitmapType asABitmap(SkBitmap* outTexture,
+ virtual BitmapType asABitmap(SkBitmap* outTexture,
SkMatrix* outMatrix,
- TileMode xy[2],
- SkScalar* twoPointRadialParams);
+ TileMode xy[2],
+ SkScalar* twoPointRadialParams) const;
+
+ virtual GradientType asAGradient(GradientInfo* info) const;
+
protected:
SkColorShader(SkFlattenableReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer& );
virtual Factory getFactory() { return CreateProc; }
private:
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkColorShader, (buffer));
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
+ return SkNEW_ARGS(SkColorShader, (buffer));
}
SkColor fColor; // ignored if fInheritColor is true
SkPMColor fPMColor; // cached after setContext()
@@ -66,7 +69,7 @@ private:
SkBool8 fInheritColor;
// deferred allocation, used for asABitmap()
- SkPixelRef* fAsABitmapPixelRef;
+ mutable SkPixelRef* fAsABitmapPixelRef;
typedef SkShader INHERITED;
};
diff --git a/include/core/SkDeque.h b/include/core/SkDeque.h
index 99c8dd4..92d5153 100644
--- a/include/core/SkDeque.h
+++ b/include/core/SkDeque.h
@@ -52,9 +52,16 @@ private:
public:
class F2BIter {
public:
+ /**
+ * Creates an uninitialized iterator. Must be reset()
+ */
+ F2BIter();
+
F2BIter(const SkDeque& d);
void* next();
+ void reset(const SkDeque& d);
+
private:
SkDeque::Head* fHead;
char* fPos;
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 7791f34..55d823b 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -81,6 +81,13 @@ public:
/** Return the height of the device (in pixels).
*/
virtual int height() const { return fBitmap.height(); }
+
+ /**
+ * Return the device's origin: its offset in device coordinates from
+ * the default origin in its canvas' matrix/clip
+ */
+ const SkIPoint& getOrigin() const { return fOrigin; }
+
/** Return the bitmap config of the device's pixels
*/
SkBitmap::Config config() const { return fBitmap.getConfig(); }
@@ -141,7 +148,8 @@ public:
/** Called when this device gains focus (i.e becomes the current device
for drawing).
*/
- virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&) {}
+ virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
+ const SkClipStack&) {}
/** Causes any deferred drawing to the device to be completed.
*/
@@ -189,9 +197,11 @@ public:
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint);
+#ifdef ANDROID
virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix);
+#endif
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
@@ -219,9 +229,14 @@ protected:
}
private:
+ friend class SkCanvas;
+ // just called by SkCanvas when built as a layer
+ void setOrigin(int x, int y) { fOrigin.set(x, y); }
+
SkCanvas* fCanvas;
SkBitmap fBitmap;
SkRefDict fRefDict;
+ SkIPoint fOrigin;
};
#endif
diff --git a/include/core/SkDraw.h b/include/core/SkDraw.h
index fb2f292..99ab342 100644
--- a/include/core/SkDraw.h
+++ b/include/core/SkDraw.h
@@ -26,6 +26,7 @@
#include "SkAutoKern.h"
class SkBounder;
+class SkClipStack;
class SkDevice;
class SkPath;
class SkRegion;
@@ -54,15 +55,17 @@ public:
int scalarsPerPosition, const SkPaint& paint) const;
void drawTextOnPath(const char text[], size_t byteLength,
const SkPath&, const SkMatrix*, const SkPaint&) const;
+#ifdef ANDROID
void drawPosTextOnPath(const char text[], size_t byteLength,
const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix) const;
+#endif
void drawVertices(SkCanvas::VertexMode mode, int count,
const SkPoint vertices[], const SkPoint textures[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int ptCount,
const SkPaint& paint) const;
-
+
void drawPath(const SkPath& src, const SkPaint& paint) const {
this->drawPath(src, paint, NULL, false);
}
@@ -87,6 +90,7 @@ public:
const SkMatrix* fMatrix; // required
const SkRegion* fClip; // required
+ const SkClipStack* fClipStack; // optional
SkDevice* fDevice; // optional
SkBounder* fBounder; // optional
SkDrawProcs* fProcs; // optional
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index d70ba65..3c69251 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -279,6 +279,7 @@ public:
static void SetSubpixelOrder(LCDOrder order);
static LCDOrder GetSubpixelOrder();
+#ifdef ANDROID
///////////////////////////////////////////////////////////////////////////
/**
@@ -288,6 +289,7 @@ public:
* @return the number of font units per em or 0 on error.
*/
static uint32_t GetUnitsPerEm(SkFontID fontID);
+#endif
};
#endif
diff --git a/include/core/SkMask.h b/include/core/SkMask.h
index 58a2493..4d48376 100644
--- a/include/core/SkMask.h
+++ b/include/core/SkMask.h
@@ -47,6 +47,7 @@ struct SkMask {
kHorizontalLCD_Format, //!< 4 bytes/pixel: a/r/g/b
kVerticalLCD_Format, //!< 4 bytes/pixel: a/r/g/b
kARGB32_Format, //!< SkPMColor
+ kLCD16_Format //!< 565 alpha for r/g/b
};
enum {
@@ -96,6 +97,19 @@ struct SkMask {
return fImage + x - fBounds.fLeft + (y - fBounds.fTop) * fRowBytes;
}
+ /**
+ * Return the address of the specified 16bit mask. In the debug build,
+ * this asserts that the mask's format is kLCD16_Format, and that (x,y)
+ * are contained in the mask's fBounds.
+ */
+ uint16_t* getAddrLCD16(int x, int y) const {
+ SkASSERT(kLCD16_Format == fFormat);
+ SkASSERT(fBounds.contains(x, y));
+ SkASSERT(fImage != NULL);
+ uint16_t* row = (uint16_t*)(fImage + (y - fBounds.fTop) * fRowBytes);
+ return row + (x - fBounds.fLeft);
+ }
+
/** Return an address into the 32-bit plane of an LCD or VerticalLCD mask
for the given position.
*/
@@ -120,7 +134,7 @@ struct SkMask {
static uint8_t* AllocImage(size_t bytes);
static void FreeImage(void* image);
-
+
enum CreateMode {
kJustComputeBounds_CreateMode, //!< compute bounds and return
kJustRenderImage_CreateMode, //!< render into preallocate mask
@@ -128,7 +142,8 @@ struct SkMask {
};
static bool FormatIsLCD(Format fm) {
- return kHorizontalLCD_Format == fm || kVerticalLCD_Format == fm;
+ return kHorizontalLCD_Format == fm || kVerticalLCD_Format == fm ||
+ kLCD16_Format == fm;
}
};
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index c0259af..177ecec 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -39,7 +39,7 @@ class SkGpuTexture;
class SkPixelRef : public SkRefCnt {
public:
explicit SkPixelRef(SkMutex* mutex = NULL);
-
+
/** Return the pixel memory returned from lockPixels, or null if the
lockCount is 0.
*/
@@ -63,13 +63,13 @@ public:
memory (if the subclass implements caching/deferred-decoding.)
*/
void unlockPixels();
-
+
/** Returns a non-zero, unique value corresponding to the pixels in this
pixelref. Each time the pixels are changed (and notifyPixelsChanged is
called), a different generation ID will be returned.
*/
uint32_t getGenerationID() const;
-
+
/** Call this if you have changed the contents of the pixels. This will in-
turn cause a different generation ID value to be returned from
getGenerationID().
@@ -80,7 +80,7 @@ public:
contents of its pixels will not change for the lifetime of the pixelref.
*/
bool isImmutable() const { return fIsImmutable; }
-
+
/** Marks this pixelref is immutable, meaning that the contents of its
pixels will not change for the lifetime of the pixelref. This state can
be set on a pixelref, but it cannot be cleared once it is set.
@@ -97,13 +97,13 @@ public:
void setURI(const char uri[]) {
fURI.set(uri);
}
-
+
/** Copy a URI string to this pixelref
*/
void setURI(const char uri[], size_t len) {
fURI.set(uri, len);
}
-
+
/** Assign a URI string to this pixelref.
*/
void setURI(const SkString& uri) { fURI = uri; }
@@ -119,22 +119,26 @@ public:
virtual Factory getFactory() const { return NULL; }
virtual void flatten(SkFlattenableWriteBuffer&) const;
- /** Acquire a "global" ref on this object.
- * The default implementation just calls ref(), but subclasses can override
- * this method to implement additional behavior.
- */
+#ifdef ANDROID
+ /**
+ * Acquire a "global" ref on this object.
+ * The default implementation just calls ref(), but subclasses can override
+ * this method to implement additional behavior.
+ */
virtual void globalRef(void* data=NULL);
- /** Release a "global" ref on this object.
- * The default implementation just calls unref(), but subclasses can override
- * this method to implement additional behavior.
- */
+ /**
+ * Release a "global" ref on this object.
+ * The default implementation just calls unref(), but subclasses can override
+ * this method to implement additional behavior.
+ */
virtual void globalUnref();
+#endif
static Factory NameToFactory(const char name[]);
static const char* FactoryToName(Factory);
static void Register(const char name[], Factory);
-
+
class Registrar {
public:
Registrar(const char name[], Factory factory) {
@@ -165,9 +169,9 @@ private:
void* fPixels;
SkColorTable* fColorTable; // we do not track ownership, subclass does
int fLockCount;
-
+
mutable uint32_t fGenerationID;
-
+
SkString fURI;
// can go from false to true, but never from true to false
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h
index bdb30d9..79ca58c 100644
--- a/include/core/SkPoint.h
+++ b/include/core/SkPoint.h
@@ -26,13 +26,28 @@
*/
struct SkIPoint {
int32_t fX, fY;
-
+
static SkIPoint Make(int32_t x, int32_t y) {
SkIPoint pt;
pt.set(x, y);
return pt;
}
+ int32_t x() const { return fX; }
+ int32_t y() const { return fY; }
+ void setX(int32_t x) { fX = x; }
+ void setY(int32_t y) { fY = y; }
+
+ /**
+ * Returns true iff fX and fY are both zero.
+ */
+ bool isZero() const { return (fX | fY) == 0; }
+
+ /**
+ * Set both fX and fY to zero. Same as set(0, 0)
+ */
+ void setZero() { fX = fY = 0; }
+
/** Set the x and y values of the point. */
void set(int32_t x, int32_t y) { fX = x; fY = y; }
@@ -55,11 +70,11 @@ struct SkIPoint {
the point
*/
void rotateCCW() { this->rotateCCW(this); }
-
+
/** Negate the X and Y coordinates of the point.
*/
void negate() { fX = -fX; fY = -fY; }
-
+
/** Return a new point whose X and Y coordinates are the negative of the
original point's
*/
@@ -75,7 +90,7 @@ struct SkIPoint {
fX += v.fX;
fY += v.fY;
}
-
+
/** Subtract v's coordinates from this point's */
void operator-=(const SkIPoint& v) {
fX -= v.fX;
@@ -90,7 +105,7 @@ struct SkIPoint {
friend bool operator==(const SkIPoint& a, const SkIPoint& b) {
return a.fX == b.fX && a.fY == b.fY;
}
-
+
friend bool operator!=(const SkIPoint& a, const SkIPoint& b) {
return a.fX != b.fX || a.fY != b.fY;
}
@@ -111,7 +126,7 @@ struct SkIPoint {
v.set(a.fX + b.fX, a.fY + b.fY);
return v;
}
-
+
/** Returns the dot product of a and b, treating them as 2D vectors
*/
static int32_t DotProduct(const SkIPoint& a, const SkIPoint& b) {
@@ -133,10 +148,10 @@ struct SkPoint {
pt.set(x, y);
return pt;
}
-
+
/** Set the point's X and Y coordinates */
void set(SkScalar x, SkScalar y) { fX = x; fY = y; }
-
+
/** Set the point's X and Y coordinates by automatically promoting (x,y) to
SkScalar values.
*/
@@ -144,7 +159,7 @@ struct SkPoint {
fX = SkIntToScalar(x);
fY = SkIntToScalar(y);
}
-
+
/** Set the point's X and Y coordinates by automatically promoting p's
coordinates to SkScalar values.
*/
@@ -163,19 +178,19 @@ struct SkPoint {
return true.
*/
bool normalize();
-
+
/** Set the point (vector) to be unit-length in the same direction as the
x,y params. If the vector (x,y) has a degenerate length (i.e. nearly 0)
then return false and do nothing, otherwise return true.
*/
bool setNormalize(SkScalar x, SkScalar y);
-
+
/** Scale the point (vector) to have the specified length, and return that
length. If the original length is degenerately small (nearly zero),
do nothing and return false, otherwise return true.
*/
bool setLength(SkScalar length);
-
+
/** Set the point (vector) to have the specified length in the same
direction as (x,y). If the vector (x,y) has a degenerate length
(i.e. nearly 0) then return false and do nothing, otherwise return true.
@@ -186,7 +201,7 @@ struct SkPoint {
It is legal for dst == this.
*/
void scale(SkScalar scale, SkPoint* dst) const;
-
+
/** Scale the point's coordinates by scale, writing the answer back into
the point.
*/
@@ -196,29 +211,29 @@ struct SkPoint {
It is legal for dst == this.
*/
void rotateCW(SkPoint* dst) const;
-
+
/** Rotate the point clockwise by 90 degrees, writing the answer back into
the point.
*/
void rotateCW() { this->rotateCW(this); }
-
+
/** Rotate the point counter-clockwise by 90 degrees, writing the answer
into dst. It is legal for dst == this.
*/
void rotateCCW(SkPoint* dst) const;
-
+
/** Rotate the point counter-clockwise by 90 degrees, writing the answer
back into the point.
*/
void rotateCCW() { this->rotateCCW(this); }
-
+
/** Negate the point's coordinates
*/
void negate() {
fX = -fX;
fY = -fY;
}
-
+
/** Returns a new point whose coordinates are the negative of the point's
*/
SkPoint operator-() const {
@@ -234,7 +249,7 @@ struct SkPoint {
fX += v.fX;
fY += v.fY;
}
-
+
/** Subtract v's coordinates from the point's
*/
void operator-=(const SkPoint& v) {
@@ -249,7 +264,7 @@ struct SkPoint {
friend bool operator==(const SkPoint& a, const SkPoint& b) {
return a.fX == b.fX && a.fY == b.fY;
}
-
+
friend bool operator!=(const SkPoint& a, const SkPoint& b) {
return a.fX != b.fX || a.fY != b.fY;
}
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index b6caad5..114d1f9 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -95,6 +95,13 @@ struct SkIRect {
fBottom = bottom;
}
+ void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height) {
+ fLeft = x;
+ fTop = y;
+ fRight = x + width;
+ fBottom = y + height;
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
@@ -348,6 +355,13 @@ struct SkRect {
*/
void set(const SkPoint pts[], int count);
+ void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height) {
+ fLeft = x;
+ fTop = y;
+ fRight = x + width;
+ fBottom = y + height;
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index f109ead..b9b2c98 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -67,36 +67,35 @@ private:
mutable int32_t fRefCnt;
};
-/** \class SkAutoUnref
-
- SkAutoUnref is a stack-helper class that will automatically call unref() on
- the object it points to when the SkAutoUnref object goes out of scope.
- If obj is null, do nothing.
-*/
-class SkAutoUnref : SkNoncopyable {
+/**
+ * Utility class that simply unref's its argument in the destructor.
+ */
+template <typename T> class SkAutoTUnref : SkNoncopyable {
public:
- SkAutoUnref(SkRefCnt* obj) : fObj(obj) {}
- ~SkAutoUnref();
-
- SkRefCnt* get() const { return fObj; }
-
- /** If the hosted object is null, do nothing and return false, else call
- ref() on it and return true
- */
- bool ref();
+ SkAutoTUnref(T* obj) : fObj(obj) {}
+ ~SkAutoTUnref() { SkSafeUnref(fObj); }
- /** If the hosted object is null, do nothing and return false, else call
- unref() on it, set its reference to null, and return true
- */
- bool unref();
+ T* get() const { return fObj; }
- /** If the hosted object is null, do nothing and return NULL, else call
- unref() on it, set its reference to null, and return the object
- */
- SkRefCnt* detach();
+ /**
+ * Return the hosted object (which may be null), transferring ownership.
+ * The reference count is not modified, and the internal ptr is set to NULL
+ * so unref() will not be called in our destructor. A subsequent call to
+ * detach() will do nothing and return null.
+ */
+ T* detach() {
+ T* obj = fObj;
+ fObj = NULL;
+ return obj;
+ }
private:
- SkRefCnt* fObj;
+ T* fObj;
+};
+
+class SkAutoUnref : public SkAutoTUnref<SkRefCnt> {
+public:
+ SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {}
};
///////////////////////////////////////////////////////////////////////////////
@@ -148,32 +147,18 @@ public:
return *this;
}
- bool operator==(const SkRefPtr& rp) const { return fObj == rp.fObj; }
- bool operator==(const T* obj) const { return fObj == obj; }
- bool operator!=(const SkRefPtr& rp) const { return fObj != rp.fObj; }
- bool operator!=(const T* obj) const { return fObj != obj; }
-
T* get() const { return fObj; }
T& operator*() const { return *fObj; }
T* operator->() const { return fObj; }
- bool operator!() const { return !fObj; }
typedef T* SkRefPtr::*unspecified_bool_type;
- operator unspecified_bool_type() const { return fObj ? &SkRefPtr::fObj : NULL; }
+ operator unspecified_bool_type() const {
+ return fObj ? &SkRefPtr::fObj : NULL;
+ }
private:
T* fObj;
};
-template <typename T>
-inline bool operator==(T* obj, const SkRefPtr<T>& rp) {
- return obj == rp.get();
-}
-
-template <typename T>
-inline bool operator!=(T* obj, const SkRefPtr<T>& rp) {
- return obj != rp.get();
-}
-
#endif
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index d8c4e00..7ddf087 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -249,9 +249,11 @@ public:
*/
bool op(const SkRegion& rgna, const SkRegion& rgnb, Op op);
+#ifdef ANDROID
/** Returns a new char* containing the list of rectangles in this region
*/
char* toString();
+#endif
/** Returns the sequence of rectangles, sorted in Y and X, that make up
this region.
@@ -264,7 +266,7 @@ public:
bool rewind();
// reset the iterator, using the new region
void reset(const SkRegion&);
- bool done() { return fDone; }
+ bool done() const { return fDone; }
void next();
const SkIRect& rect() const { return fRect; }
// may return null
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index 5937819..584b86b 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -53,18 +53,27 @@ struct SkGlyph {
fMaskFormat = MASK_FORMAT_UNKNOWN;
}
- unsigned rowBytes() const {
- unsigned rb = fWidth;
- if (SkMask::kBW_Format == fMaskFormat) {
+ /**
+ * Compute the rowbytes for the specified width and mask-format.
+ */
+ static unsigned ComputeRowBytes(unsigned width, SkMask::Format format) {
+ unsigned rb = width;
+ if (SkMask::kBW_Format == format) {
rb = (rb + 7) >> 3;
- } else if (SkMask::kARGB32_Format == fMaskFormat) {
+ } else if (SkMask::kARGB32_Format == format) {
rb <<= 2;
+ } else if (SkMask::kLCD16_Format == format) {
+ rb = SkAlign4(rb << 1);
} else {
rb = SkAlign4(rb);
}
return rb;
}
+ unsigned rowBytes() const {
+ return ComputeRowBytes(fWidth, (SkMask::Format)fMaskFormat);
+ }
+
bool isJustAdvance() const {
return MASK_FORMAT_JUST_ADVANCE == fMaskFormat;
}
@@ -230,7 +239,7 @@ public:
*/
SkUnichar glyphIDToChar(uint16_t glyphID);
- unsigned getGlyphCount() const { return this->generateGlyphCount(); }
+ unsigned getGlyphCount() { return this->generateGlyphCount(); }
void getAdvance(SkGlyph*);
void getMetrics(SkGlyph*);
void getImage(const SkGlyph&);
@@ -245,7 +254,7 @@ protected:
Rec fRec;
unsigned fBaseGlyphCount;
- virtual unsigned generateGlyphCount() const = 0;
+ virtual unsigned generateGlyphCount() = 0;
virtual uint16_t generateCharToGlyph(SkUnichar) = 0;
virtual void generateAdvance(SkGlyph*) = 0;
virtual void generateMetrics(SkGlyph*) = 0;
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 1cdbf17..c59cc59 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -80,7 +80,7 @@ public:
shadeSpan().
*/
kConstInY32_Flag = 0x08,
-
+
/** same as kConstInY32_Flag, but is set if this is true for shadeSpan16
which may not always be the case, since shadeSpan16 may be
predithered, which would mean it was not const in Y, even though
@@ -101,7 +101,7 @@ public:
kHasSpan16_Flag is not set, this value is meaningless.
*/
virtual uint8_t getSpan16Alpha() const { return fPaintAlpha; }
-
+
/** 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
@@ -144,7 +144,7 @@ public:
*/
virtual void beginSession();
virtual void endSession();
-
+
/**
Gives method bitmap should be read to implement a shader.
Also determines number and interpretation of "extra" parameters returned
@@ -152,34 +152,35 @@ public:
*/
enum BitmapType {
kNone_BitmapType, //<! Shader is not represented as a bitmap
- kDefault_BitmapType,//<! Access bitmap using local coords transformed
+ kDefault_BitmapType,//<! Access bitmap using local coords transformed
// by matrix. No extras
- kRadial_BitmapType, //<! Access bitmap by transforming local coordinates
- // by the matrix and taking the distance of result
- // from (0,0) as bitmap column. Bitmap is 1 pixel
+ kRadial_BitmapType, //<! Access bitmap by transforming local coordinates
+ // by the matrix and taking the distance of result
+ // from (0,0) as bitmap column. Bitmap is 1 pixel
// tall. No extras
- kSweep_BitmapType, //<! Access bitmap by transforming local coordinates
+ kSweep_BitmapType, //<! Access bitmap by transforming local coordinates
// by the matrix and taking the angle of result
// to (0,0) as bitmap x coord, where angle = 0 is
- // bitmap left edge of bitmap = 2pi is the
+ // bitmap left edge of bitmap = 2pi is the
// right edge. Bitmap is 1 pixel tall. No extras
- kTwoPointRadial_BitmapType
- //<! Matrix transforms to space where (0,0) is
+ kTwoPointRadial_BitmapType,
+ //<! Matrix transforms to space where (0,0) is
// the center of the starting circle. The second
- // circle will be centered (x, 0) where x may be
- // 0. The post-matrix space is normalized such
+ // circle will be centered (x, 0) where x may be
+ // 0. The post-matrix space is normalized such
// that 1 is the second radius - first radius.
// Three extra parameters are returned:
- // 0: x-offset of second circle center
+ // 0: x-offset of second circle center
// to first.
- // 1: radius of first circle in post-matrix
+ // 1: radius of first circle in post-matrix
// space
// 2: the second radius minus the first radius
- // in pre-transformed space.
-
+ // in pre-transformed space.
+
+ kLast_BitmapType = kTwoPointRadial_BitmapType
};
/** Optional methods for shaders that can pretend to be a bitmap/texture
- to play along with opengl. Default just returns kNone_BitmapType and
+ to play along with opengl. Default just returns kNone_BitmapType and
ignores the out parameters.
@param outTexture if non-NULL will be the bitmap representing the shader
@@ -194,7 +195,60 @@ public:
about the first point.
*/
virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix,
- TileMode xy[2], SkScalar* twoPointRadialParams);
+ TileMode xy[2], SkScalar* twoPointRadialParams) const;
+
+ /**
+ * If the shader subclass can be represented as a gradient, asAGradient
+ * returns the matching GradientType enum (or kNone_GradientType if it
+ * cannot). Also, if info is not null, asAGradient populates info with
+ * the relevant (see below) parameters for the gradient. fColorCount
+ * is both an input and output parameter. On input, it indicates how
+ * many entries in fColors and fColorOffsets can be used, if they are
+ * non-NULL. After asAGradient has run, fColorCount indicates how
+ * many color-offset pairs there are in the gradient. If there is
+ * insufficient space to store all of the color-offset pairs, fColors
+ * and fColorOffsets will not be altered. fColorOffsets specifies
+ * where on the range of 0 to 1 to transition to the given color.
+ * The meaning of fPoint and fRadius is dependant on the type of gradient.
+ *
+ * None:
+ * info is ignored.
+ * Color:
+ * fColorOffsets[0] is meaningless.
+ * Linear:
+ * fPoint[0] and fPoint[1] are the end-points of the gradient
+ * Radial:
+ * fPoint[0] and fRadius[0] are the center and radius
+ * Radial2:
+ * fPoint[0] and fRadius[0] are the center and radius of the 1st circle
+ * fPoint[1] and fRadius[1] are the center and radius of the 2nd circle
+ * Sweep:
+ * fPoint[0] is the center of the sweep.
+ */
+
+ enum GradientType {
+ kNone_GradientType,
+ kColor_GradientType,
+ kLinear_GradientType,
+ kRadial_GradientType,
+ kRadial2_GradientType,
+ kSweep_GradientType,
+ kLast_GradientType = kSweep_GradientType
+ };
+
+ struct GradientInfo {
+ int fColorCount; //!< In-out parameter, specifies passed size
+ // of fColors/fColorOffsets on input, and
+ // actual number of colors/offsets on
+ // output.
+ SkColor* fColors; //!< The colors in the gradient.
+ SkScalar* fColorOffsets; //!< The unit offset for color transitions.
+ SkPoint fPoint[2]; //!< Type specific, see above.
+ SkScalar fRadius[2]; //!< Type specific, see above.
+ TileMode fTileMode; //!< The tile mode used.
+ };
+
+ virtual GradientType asAGradient(GradientInfo* info) const;
//////////////////////////////////////////////////////////////////////////
// Factory methods for stock shaders
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 4498bba..eb25e15 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -30,8 +30,33 @@ int SkStrStartsWithOneOf(const char string[], const char prefixes[]);
char* SkStrAppendS32(char buffer[], int32_t);
#define SkStrAppendS64_MaxSize 20
char* SkStrAppendS64(char buffer[], int64_t, int minDigits);
-#define SkStrAppendScalar_MaxSize 11
-char* SkStrAppendScalar(char buffer[], SkScalar);
+
+/**
+ * Floats have at most 8 significant digits, so we limit our %g to that.
+ * However, the total string could be 15 characters: -1.2345678e-005
+ *
+ * In theory we should only expect up to 2 digits for the exponent, but on
+ * some platforms we have seen 3 (as in the example above).
+ */
+#define SkStrAppendScalar_MaxSize 15
+
+/**
+ * Write the scaler in decimal format into buffer, and return a pointer to
+ * the next char after the last one written. Note: a terminating 0 is not
+ * written into buffer, which must be at least SkStrAppendScalar_MaxSize.
+ * Thus if the caller wants to add a 0 at the end, buffer must be at least
+ * SkStrAppendScalar_MaxSize + 1 bytes large.
+ */
+#ifdef SK_SCALAR_IS_FLOAT
+ #define SkStrAppendScalar SkStrAppendFloat
+#else
+ #define SkStrAppendScalar SkStrAppendFixed
+#endif
+
+#ifdef SK_CAN_USE_FLOAT
+char* SkStrAppendFloat(char buffer[], float);
+#endif
+char* SkStrAppendFixed(char buffer[], SkFixed);
/** \class SkString
@@ -127,7 +152,7 @@ public:
to never fail or throw.
*/
void swap(SkString& other);
-
+
private:
struct Rec {
public:
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 728ba31..f4b9507 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -58,7 +58,7 @@ public:
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
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 8dbd51b..93f054e 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -403,21 +403,70 @@ public:
}
};
+/**
+ * Manage an allocated block of memory. If the requested size is <= kSize, then
+ * the allocation will come from the stack rather than the heap. This object
+ * is the sole manager of the lifetime of the block, so the caller must not
+ * call sk_free() or delete on the block.
+ */
template <size_t kSize> class SkAutoSMalloc : SkNoncopyable {
public:
- explicit SkAutoSMalloc(size_t size)
- {
- if (size <= kSize)
- fPtr = fStorage;
- else
- fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ /**
+ * Creates initially empty storage. get() returns a ptr, but it is to
+ * a zero-byte allocation. Must call realloc(size) to return an allocated
+ * block.
+ */
+ SkAutoSMalloc() {
+ fPtr = fStorage;
}
- ~SkAutoSMalloc()
- {
- if (fPtr != (void*)fStorage)
+
+ /**
+ * Allocate a block of the specified size. If size <= kSize, then the
+ * allocation will come from the stack, otherwise it will be dynamically
+ * allocated.
+ */
+ explicit SkAutoSMalloc(size_t size) {
+ fPtr = fStorage;
+ this->realloc(size);
+ }
+
+ /**
+ * Free the allocated block (if any). If the block was small enought to
+ * have been allocated on the stack (size <= kSize) then this does nothing.
+ */
+ ~SkAutoSMalloc() {
+ if (fPtr != (void*)fStorage) {
sk_free(fPtr);
+ }
}
+
+ /**
+ * Return the allocated block. May return non-null even if the block is
+ * of zero size. Since this may be on the stack or dynamically allocated,
+ * the caller must not call sk_free() on it, but must rely on SkAutoSMalloc
+ * to manage it.
+ */
void* get() const { return fPtr; }
+
+ /**
+ * Return a new block of the requested size, freeing (as necessary) any
+ * previously allocated block. As with the constructor, if size <= kSize
+ * then the return block may be allocated locally, rather than from the
+ * heap.
+ */
+ void* realloc(size_t size) {
+ if (fPtr != (void*)fStorage) {
+ sk_free(fPtr);
+ }
+
+ if (size <= kSize) {
+ fPtr = fStorage;
+ } else {
+ fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ }
+ return fPtr;
+ }
+
private:
void* fPtr;
uint32_t fStorage[(kSize + 3) >> 2];
diff --git a/include/core/SkUserConfig.h b/include/core/SkUserConfig.h
index a72aa1a..2140a15 100644
--- a/include/core/SkUserConfig.h
+++ b/include/core/SkUserConfig.h
@@ -18,18 +18,18 @@
#define SkUserConfig_DEFINED
/* SkTypes.h, the root of the public header files, does the following trick:
-
+
#include "SkPreConfig.h"
#include "SkUserConfig.h"
#include "SkPostConfig.h"
-
+
SkPreConfig.h runs first, and it is responsible for initializing certain
skia defines.
-
+
SkPostConfig.h runs last, and its job is to just check that the final
defines are consistent (i.e. that we don't have mutually conflicting
defines).
-
+
SkUserConfig.h (this file) runs in the middle. It gets to change or augment
the list of flags initially set in preconfig, and then postconfig checks
that everything still makes sense.
@@ -85,7 +85,7 @@
parameter checking, but sometimes it can be quite intrusive (e.g. check that
each 32bit pixel is in premultiplied form). This code can be very useful
during development, but will slow things down in a shipping product.
-
+
By default, these mutually exclusive flags are defined in SkPreConfig.h,
based on the presence or absence of NDEBUG, but that decision can be changed
here.
@@ -134,6 +134,26 @@
void Android_SkDebugf(const char* file, int line,
const char* function, const char* format, ...);
+/* To enable additional blitters (and fontscaler code) to support separate
+ alpha channels for R G B channels, define SK_SUPPORT_LCDTEXT
+ */
+//#define SK_SUPPORT_LCDTEXT
+
+/* If zlib is available and you want to support the flate compression
+ algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
+ include path.
+ */
+//#define SK_ZLIB_INCLUDE <zlib.h>
+
+/* Define this to allow PDF scalars above 32k. The PDF/A spec doesn't allow
+ them, but modern PDF interpreters should handle them just fine.
+ */
+//#define SK_ALLOW_LARGE_PDF_SCALARS
+
+/* Define this to remove dimension checks on bitmaps. Not all blits will be
+ correct yet, so this is mostly for debugging the implementation.
+ */
+//#define SK_ALLOW_OVER_32K_BITMAPS
/* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
which will run additional self-tests at startup. These can take a long time,
diff --git a/include/effects/SkPorterDuff.h b/include/effects/SkPorterDuff.h
index 4d7fb31..54f81ea 100644
--- a/include/effects/SkPorterDuff.h
+++ b/include/effects/SkPorterDuff.h
@@ -52,7 +52,9 @@ public:
kMultiply_Mode, //!< [Sa * Da, Sc * Dc]
kScreen_Mode, //!< [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
kAdd_Mode, //!< Saturate(S + D)
+#ifdef ANDROID
kOverlay_Mode,
+#endif
kModeCount
};
diff --git a/include/gpu/SkGpuCanvas.h b/include/gpu/SkGpuCanvas.h
new file mode 100644
index 0000000..57a4b1b
--- /dev/null
+++ b/include/gpu/SkGpuCanvas.h
@@ -0,0 +1,68 @@
+/*
+ Copyright 2010 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 SkGpuCanvas_DEFINED
+#define SkGpuCanvas_DEFINED
+
+#include "SkCanvas.h"
+
+class GrContext;
+class GrRenderTarget;
+
+/**
+ * Subclass of canvas that creates devices compatible with the GrContext pass
+ * to the canvas' constructor.
+ */
+class SkGpuCanvas : public SkCanvas {
+public:
+ /**
+ * The GrContext object is reference counted. When passed to our
+ * constructor, its reference count is incremented. In our destructor, the
+ * GrGpu's reference count will be decremented.
+ * GrRenderTarget represents the rendering destination in the underlying
+ * 3D API. Its reference count is incremented in the constructor and
+ * decremented in the destructor.
+ * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
+ * value that will cause the factory to create a render target object
+ * that reflects the state of the underlying 3D API at the time of
+ * construction.
+ */
+ explicit SkGpuCanvas(GrContext*, GrRenderTarget*);
+ virtual ~SkGpuCanvas();
+
+ /**
+ * Override from SkCanvas. Returns true, and if not-null, sets size to
+ * be the width/height of our viewport.
+ */
+ virtual bool getViewport(SkIPoint* size) const;
+
+#if 0
+ virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag) {
+ return this->save(flags);
+ }
+#endif
+
+private:
+ GrContext* fContext;
+
+ typedef SkCanvas INHERITED;
+};
+
+#endif
+
+
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
new file mode 100644
index 0000000..3fed99a
--- /dev/null
+++ b/include/gpu/SkGpuDevice.h
@@ -0,0 +1,184 @@
+/*
+ Copyright 2010 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 SkGpuDevice_DEFINED
+#define SkGpuDevice_DEFINED
+
+#include "SkGr.h"
+#include "SkDevice.h"
+#include "SkRegion.h"
+
+struct SkDrawProcs;
+struct GrSkDrawProcs;
+class GrTextContext;
+
+/**
+ * Subclass of SkDevice, which directs all drawing to the GrGpu owned by the
+ * canvas.
+ */
+class SkGpuDevice : public SkDevice {
+public:
+ /**
+ * The SkGpuDevice will render to the GrRenderTarget, or if the paremeter is
+ * null it will create its own render target and manage that target's
+ * lifetime.
+ */
+ SkGpuDevice(GrContext*,
+ const SkBitmap& bitmap,
+ GrRenderTarget* renderTargetOrNull);
+
+ /**
+ * Magic value that can be passed to constructor. Causes
+ * the device to infer rendertarget from underlying 3D API (e.g. GL or D3D).
+ * This isn't a valid pointer, don't attempt to dereference.
+ */
+ static GrRenderTarget* Current3DApiRenderTarget();
+
+ virtual ~SkGpuDevice();
+
+ GrContext* context() const { return fContext; }
+
+ /**
+ * If this device was built for rendering as a layer (i.e. offscreen),
+ * then this will return the platform-specific handle to that GPU resource.
+ * For example, in OpenGL, this will return the FBO's texture ID.
+ * If this device was not built for rendering as a layer, then 0
+ * is returned.
+ */
+ intptr_t getLayerTextureHandle() const;
+
+ // call to set the clip to the specified rect
+ void scissor(const SkIRect&);
+
+ /**
+ * Override from SkGpuDevice, so we can set our FBO to be the render target
+ * The canvas parameter must be a SkGpuCanvas
+ */
+ virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
+ const SkClipStack& clipStack);
+
+ virtual SkGpuTexture* accessTexture() { return (SkGpuTexture*)fTexture; }
+
+ // overrides from SkDevice
+
+ virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
+ virtual void writePixels(const SkBitmap& bitmap, int x, int y);
+
+ virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& clip,
+ const SkClipStack&);
+
+ virtual void drawPaint(const SkDraw&, const SkPaint& paint);
+ virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
+ const SkPoint[], const SkPaint& paint);
+ virtual void drawRect(const SkDraw&, const SkRect& r,
+ const SkPaint& paint);
+ virtual void drawPath(const SkDraw&, const SkPath& path,
+ const SkPaint& paint, const SkMatrix* prePathMatrix,
+ bool pathIsMutable);
+ virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
+ const SkIRect* srcRectOrNull,
+ const SkMatrix& matrix, const SkPaint& paint);
+ virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
+ int x, int y, const SkPaint& paint);
+ virtual void drawText(const SkDraw&, const void* text, size_t len,
+ SkScalar x, SkScalar y, const SkPaint& paint);
+ virtual void drawPosText(const SkDraw&, const void* text, size_t len,
+ const SkScalar pos[], SkScalar constY,
+ int scalarsPerPos, const SkPaint& paint);
+ virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
+ const SkPath& path, const SkMatrix* matrix,
+ const SkPaint& paint);
+ virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
+ const SkPoint verts[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xmode,
+ const uint16_t indices[], int indexCount,
+ const SkPaint& paint);
+ virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
+ const SkPaint&);
+
+ virtual void flush() { fContext->flush(false); }
+
+ /**
+ * Make's this device's rendertarget current in the underlying 3D API.
+ * Also implicitly flushes.
+ */
+ virtual void makeRenderTargetCurrent();
+
+protected:
+ class TexCache;
+ TexCache* lockCachedTexture(const SkBitmap& bitmap,
+ const GrSamplerState& sampler,
+ GrTexture** texture,
+ bool forDeviceRenderTarget = false);
+ void unlockCachedTexture(TexCache*);
+
+ class SkAutoCachedTexture {
+ public:
+ SkAutoCachedTexture();
+ SkAutoCachedTexture(SkGpuDevice* device,
+ const SkBitmap& bitmap,
+ const GrSamplerState& sampler,
+ GrTexture** texture);
+ ~SkAutoCachedTexture();
+
+ GrTexture* set(SkGpuDevice*, const SkBitmap&, const GrSamplerState&);
+
+ private:
+ SkGpuDevice* fDevice;
+ TexCache* fTex;
+ };
+ friend class SkAutoTexCache;
+
+private:
+ GrContext* fContext;
+
+ GrSkDrawProcs* fDrawProcs;
+
+ // state for our offscreen render-target
+ TexCache* fCache;
+ GrTexture* fTexture;
+ GrRenderTarget* fRenderTarget;
+ bool fNeedClear;
+ bool fNeedPrepareRenderTarget;
+
+ // doesn't set the texture/sampler/matrix state
+ // caller needs to null out GrPaint's texture if
+ // non-textured drawing is desired.
+ bool skPaint2GrPaintNoShader(const SkPaint& skPaint,
+ bool justAlpha,
+ GrPaint* grPaint);
+
+ // uses the SkShader to setup paint, act used to
+ // hold lock on cached texture and free it when
+ // destroyed.
+ bool skPaint2GrPaintShader(const SkPaint& skPaint,
+ SkAutoCachedTexture* act,
+ const SkMatrix& ctm,
+ GrPaint* grPaint);
+
+ SkDrawProcs* initDrawForText(GrTextContext*);
+ bool bindDeviceAsTexture(GrPaint* paint);
+
+ void prepareRenderTarget(const SkDraw&);
+ void internalDrawBitmap(const SkDraw&, const SkBitmap&,
+ const SkIRect&, const SkMatrix&, GrPaint* grPaint);
+
+ typedef SkDevice INHERITED;
+};
+
+#endif
+
diff --git a/include/gpu/SkGpuDeviceFactory.h b/include/gpu/SkGpuDeviceFactory.h
new file mode 100644
index 0000000..5dcba6a
--- /dev/null
+++ b/include/gpu/SkGpuDeviceFactory.h
@@ -0,0 +1,49 @@
+/*
+ Copyright 2010 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 SkGpuDeviceFactory_DEFINED
+#define SkGpuDeviceFactory_DEFINED
+
+#include "SkDevice.h"
+
+class GrContext;
+
+class SkGpuDeviceFactory : public SkDeviceFactory {
+public:
+ /**
+ * The constructor will ref() the context, passing it to each device
+ * that it creates. It will be unref()'d in the destructor
+ * Non-layered devices created by the factory will draw to the
+ * rootRenderTarget. rootRenderTarget is ref-counted by the factory.
+ * SkGpuDevice::Current3DApiRenderTarget() can be passed as a special
+ * value that will cause the factory to create a render target object
+ * that reflects the state of the underlying 3D API at the time of
+ * construction.
+ */
+ SkGpuDeviceFactory(GrContext*, GrRenderTarget* rootRenderTarget);
+
+ virtual ~SkGpuDeviceFactory();
+
+ virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width,
+ int height, bool isOpaque, bool isLayer);
+
+private:
+ GrContext* fContext;
+ GrRenderTarget* fRootRenderTarget;
+};
+
+#endif
+
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
new file mode 100644
index 0000000..6f5ebfe
--- /dev/null
+++ b/include/gpu/SkGr.h
@@ -0,0 +1,298 @@
+/*
+ Copyright 2010 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 SkGr_DEFINED
+#define SkGr_DEFINED
+
+#include <stddef.h>
+
+// Gr headers
+#include "GrConfig.h"
+#include "GrContext.h"
+#include "GrFontScaler.h"
+#include "GrPathIter.h"
+#include "GrClipIterator.h"
+
+// skia headers
+#include "SkBitmap.h"
+#include "SkPath.h"
+#include "SkPoint.h"
+#include "SkRegion.h"
+#include "SkShader.h"
+#include "SkClipStack.h"
+
+#if (GR_DEBUG && defined(SK_RELEASE)) || (GR_RELEASE && defined(SK_DEBUG))
+// #error "inconsistent GR_DEBUG and SK_DEBUG"
+#endif
+
+#if GR_SCALAR_IS_FIXED
+ #ifdef SK_SCALAR_IS_FIXED
+ #define SK_SCALAR_IS_GR_SCALAR 1
+ #else
+ #define SK_SCALAR_IS_GR_SCALAR 0
+ #endif
+ #define SkScalarToGrScalar(x) SkScalarToFixed(x)
+
+#elif GR_SCALAR_IS_FLOAT
+
+ #ifdef SK_SCALAR_IS_FLOAT
+ #define SK_SCALAR_IS_GR_SCALAR 1
+ #else
+ #define SK_SCALAR_IS_GR_SCALAR 0
+ #endif
+ #define SkScalarToGrScalar(x) SkScalarToFloat(x)
+
+#else
+ #error "Ganesh scalar type not defined"
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Sk to Gr Type conversions
+
+// Verify that SkPoint and GrPoint are compatible if using the same scalar type
+#if 0/*SK_SCALAR_IS_GR_SCALAR*/
+ GR_STATIC_ASSERT(sizeof(SkPoint) == sizeof(GrPoint));
+ GR_STATIC_ASSERT(offsetof(SkPoint,fX) == offsetof(GrPoint,fX)));
+ GR_STATIC_ASSERT(offsetof(SkPoint,fY) == offsetof(GrPoint,fY)));
+#endif
+
+GR_STATIC_ASSERT((int)GrSamplerState::kClamp_WrapMode == (int)SkShader::kClamp_TileMode);
+GR_STATIC_ASSERT((int)GrSamplerState::kRepeat_WrapMode ==(
+ int)SkShader::kRepeat_TileMode);
+GR_STATIC_ASSERT((int)GrSamplerState::kMirror_WrapMode ==
+ (int)SkShader::kMirror_TileMode);
+
+#define sk_tile_mode_to_grwrap(X) ((GrSamplerState::WrapMode)(X))
+
+GR_STATIC_ASSERT((int)kZero_BlendCoeff == (int)SkXfermode::kZero_Coeff);
+GR_STATIC_ASSERT((int)kOne_BlendCoeff == (int)SkXfermode::kOne_Coeff);
+GR_STATIC_ASSERT((int)kSC_BlendCoeff == (int)SkXfermode::kSC_Coeff);
+GR_STATIC_ASSERT((int)kISC_BlendCoeff == (int)SkXfermode::kISC_Coeff);
+GR_STATIC_ASSERT((int)kDC_BlendCoeff == (int)SkXfermode::kDC_Coeff);
+GR_STATIC_ASSERT((int)kIDC_BlendCoeff == (int)SkXfermode::kIDC_Coeff);
+GR_STATIC_ASSERT((int)kSA_BlendCoeff == (int)SkXfermode::kSA_Coeff);
+GR_STATIC_ASSERT((int)kISA_BlendCoeff == (int)SkXfermode::kISA_Coeff);
+GR_STATIC_ASSERT((int)kDA_BlendCoeff == (int)SkXfermode::kDA_Coeff);
+GR_STATIC_ASSERT((int)kIDA_BlendCoeff == (int)SkXfermode::kIDA_Coeff);
+
+#define sk_blend_to_grblend(X) ((GrBlendCoeff)(X))
+
+GR_STATIC_ASSERT((int)SkPath::kMove_Verb == (int)kMove_PathCmd);
+GR_STATIC_ASSERT((int)SkPath::kLine_Verb == (int)kLine_PathCmd);
+GR_STATIC_ASSERT((int)SkPath::kQuad_Verb == (int)kQuadratic_PathCmd);
+GR_STATIC_ASSERT((int)SkPath::kCubic_Verb == (int)kCubic_PathCmd);
+GR_STATIC_ASSERT((int)SkPath::kClose_Verb == (int)kClose_PathCmd);
+GR_STATIC_ASSERT((int)SkPath::kDone_Verb == (int)kEnd_PathCmd);
+
+#define sk_path_verb_to_gr_path_command(X) ((GrPathCmd)(X))
+
+///////////////////////////////////////////////////////////////////////////////
+
+#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.
+ */
+ static GrTexture::PixelConfig BitmapConfig2PixelConfig(SkBitmap::Config,
+ bool isOpaque);
+
+ static GrTexture::PixelConfig Bitmap2PixelConfig(const SkBitmap& bm) {
+ 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);
+ unsigned g = SkGetPackedG32(pm);
+ unsigned b = SkGetPackedB32(pm);
+ unsigned a = SkGetPackedA32(pm);
+ return GrColorPackRGBA(r, g, b, a);
+ }
+
+ /**
+ * This abandons all texture caches (for bitmaps and text) associated with
+ * the gpu, and frees any associated skia caches. It differs from
+ * deleteAllTextures in that it assumes that the gpu has lots its context,
+ * and thus the associated HW textures are no longer valid
+ */
+ static void AbandonAllTextures(GrContext*);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Classes
+
+class SkGrPathIter : public GrPathIter {
+public:
+ SkGrPathIter() { fPath = NULL; }
+ SkGrPathIter(const SkPath& path) { reset(path); }
+ virtual GrPathCmd next(GrPoint pts[]);
+ virtual GrPathCmd next();
+ virtual void rewind();
+ virtual GrConvexHint convexHint() const;
+
+ void reset(const SkPath& path) {
+ fPath = &path;
+ fIter.setPath(path, false);
+ }
+private:
+
+#if !SK_SCALAR_IS_GR_SCALAR
+ SkPoint fPoints[4];
+#endif
+ SkPath::Iter fIter;
+ const SkPath* fPath;
+};
+
+class SkGrClipIterator : public GrClipIterator {
+public:
+ SkGrClipIterator() { fClipStack = NULL; fCurr = NULL; }
+ SkGrClipIterator(const SkClipStack& clipStack) { this->reset(clipStack); }
+
+ void reset(const SkClipStack& clipStack);
+
+ // overrides
+ virtual bool isDone() const { return NULL == fCurr; }
+ virtual void next() { fCurr = fIter.next(); }
+ virtual void rewind() { this->reset(*fClipStack); }
+ virtual GrClipType getType() const;
+
+ virtual GrSetOp getOp() const;
+
+ virtual void getRect(GrRect* rect) const {
+ *rect = Sk2Gr(*fCurr->fRect);
+ }
+
+ virtual GrPathIter* getPathIter() {
+ fPathIter.reset(*fCurr->fPath);
+ return &fPathIter;
+ }
+
+ virtual GrPathFill getPathFill() const;
+
+private:
+ const SkClipStack* fClipStack;
+ SkClipStack::B2FIter fIter;
+ SkGrPathIter fPathIter;
+ // SkClipStack's auto advances on each get
+ // so we store the current pos here.
+ const SkClipStack::B2FIter::Clip* fCurr;
+};
+
+class SkGrRegionIterator : public GrClipIterator {
+public:
+ SkGrRegionIterator() {}
+ SkGrRegionIterator(const SkRegion& region) { this->reset(region); }
+
+ void reset(const SkRegion& region) {
+ fRegion = &region;
+ fIter.reset(region);
+ }
+
+ // overrides
+ virtual bool isDone() const { return fIter.done(); }
+ virtual void next() { fIter.next(); }
+ virtual void rewind() { this->reset(*fRegion); }
+ virtual GrClipType getType() const { return kRect_ClipType; }
+
+ virtual GrSetOp getOp() const { return kUnion_SetOp; }
+
+ virtual void getRect(GrRect* rect) const {
+ const SkIRect& r = fIter.rect();
+ rect->fLeft = GrIntToScalar(r.fLeft);
+ rect->fTop = GrIntToScalar(r.fTop);
+ rect->fRight = GrIntToScalar(r.fRight);
+ rect->fBottom = GrIntToScalar(r.fBottom);
+ }
+
+ virtual GrPathIter* getPathIter() {
+ SkASSERT(0);
+ return NULL;
+ }
+
+ virtual GrPathFill getPathFill() const {
+ SkASSERT(0);
+ return kWinding_PathFill;
+ }
+private:
+ const SkRegion* fRegion;
+ SkRegion::Iterator fIter;
+};
+
+class SkGlyphCache;
+
+class SkGrFontScaler : public GrFontScaler {
+public:
+ explicit SkGrFontScaler(SkGlyphCache* strike);
+ virtual ~SkGrFontScaler();
+
+ // overrides
+ virtual const GrKey* getKey();
+ virtual bool getPackedGlyphBounds(GrGlyph::PackedID, GrIRect* bounds);
+ virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
+ int rowBytes, void* image);
+ virtual bool getGlyphPath(uint16_t glyphID, GrPath*);
+
+private:
+ SkGlyphCache* fStrike;
+ GrKey* fKey;
+// DECLARE_INSTANCE_COUNTER(SkGrFontScaler);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper functions
+
+GrTextureEntry* sk_gr_create_bitmap_texture(GrContext* ctx,
+ GrTextureKey* key,
+ const GrSamplerState& sampler,
+ const SkBitmap& bitmap);
+
+
+#endif
diff --git a/include/gpu/SkGrTexturePixelRef.h b/include/gpu/SkGrTexturePixelRef.h
new file mode 100644
index 0000000..1f5133f
--- /dev/null
+++ b/include/gpu/SkGrTexturePixelRef.h
@@ -0,0 +1,50 @@
+/*
+ Copyright 2010 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 SkGrTexturePixelRef_DEFINED
+#define SkGrTexturePixelRef_DEFINED
+
+#include "SkPixelRef.h"
+#include "GrGpu.h"
+
+class SkGrTexturePixelRef : public SkPixelRef {
+public:
+ SkGrTexturePixelRef(GrTexture*);
+ virtual ~SkGrTexturePixelRef();
+
+ // override from SkPixelRef
+ virtual SkGpuTexture* getTexture() { return (SkGpuTexture*)fTexture; }
+
+protected:
+ // override from SkPixelRef
+ virtual void* onLockPixels(SkColorTable** ptr) {
+ if (ptr) {
+ *ptr = NULL;
+ }
+ return NULL;
+ }
+
+ // override from SkPixelRef
+ virtual void onUnlockPixels() {}
+
+private:
+ GrTexture* fTexture;
+ typedef SkPixelRef INHERITED;
+};
+
+#endif
+
diff --git a/include/graphics/DoxygenMain.dox b/include/graphics/DoxygenMain.dox
deleted file mode 100644
index 9751862..0000000
--- a/include/graphics/DoxygenMain.dox
+++ /dev/null
@@ -1,3 +0,0 @@
-/** \mainpage notitle
-* \htmlinclude "SGL Spec. rev 9.htm"
-*/ \ No newline at end of file
diff --git a/include/ports/SkTypeface_win.h b/include/ports/SkTypeface_win.h
new file mode 100644
index 0000000..95a7b8c
--- /dev/null
+++ b/include/ports/SkTypeface_win.h
@@ -0,0 +1,31 @@
+/*
+ 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 SkTypeface_win_DEFINED
+#define SkTypeface_win_DEFINED
+
+#include "SkTypeface.h"
+
+/**
+ * Like the other Typeface create methods, this returns a new reference to the
+ * corresponding typeface for the specified logfont. The caller is responsible
+ * for calling unref() when it is finished.
+ */
+extern SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT&);
+
+#endif
+
diff --git a/include/svg/SkSVGAttribute.h b/include/svg/SkSVGAttribute.h
deleted file mode 100644
index 810d11c..0000000
--- a/include/svg/SkSVGAttribute.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSVGAttribute_DEFINED
-#define SkSVGAttribute_DEFINED
-
-#include "SkTypes.h"
-
-struct SkSVGAttribute {
- const char* fName;
-#ifdef SK_DEBUG
- size_t fOffset;
-#endif
-};
-
-#ifndef SK_OFFSETOF
-#define SK_OFFSETOF(a, b) (((size_t) (&(((a*) 1)->b)))-1)
-#endif
-
-#ifdef SK_DEBUG
-#define SVG_ATTRIBUTE(attr) { #attr, SK_OFFSETOF(BASE_CLASS, f_##attr) }
-#define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr, SK_OFFSETOF(BASE_CLASS, cAttr) }
-#else
-#define SVG_ATTRIBUTE(attr) { #attr }
-#define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr }
-#endif
-
-#define SVG_ADD_ATTRIBUTE(attr) \
- if (f_##attr.size() > 0) \
- parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size())
-
-#define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \
- if (f_##alias.size() > 0) \
- parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size())
-
-#endif // SkSVGAttribute_DEFINED
diff --git a/include/svg/SkSVGBase.h b/include/svg/SkSVGBase.h
deleted file mode 100644
index 4d24aed..0000000
--- a/include/svg/SkSVGBase.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSVGBase_DEFINED
-#define SkSVGBase_DEFINED
-
-#include "SkSVGAttribute.h"
-
-class SkSVGParser;
-
-class SkSVGBase {
-public:
- virtual ~SkSVGBase();
- virtual void addAttribute(SkSVGParser& parser, int attrIndex,
- const char* attrValue, size_t attrLength);
- virtual int getAttributes(const SkSVGAttribute** attrPtr) = 0;
-};
-
-#endif // SkSVGBase_DEFINEDes(const SkSVGAttribute** attrPtr) = 0;
-
diff --git a/include/svg/SkSVGPaintState.h b/include/svg/SkSVGPaintState.h
deleted file mode 100644
index f3f74e1..0000000
--- a/include/svg/SkSVGPaintState.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSVGPaintState_DEFINED
-#define SkSVGPaintState_DEFINED
-
-#include "SkSVGBase.h"
-#include "SkString.h"
-
-class SkSVGPaint : public SkSVGBase {
-public:
- enum Field {
- kInitial = -1,
- kClipPath,
- kClipRule,
- kEnableBackground,
- kFill,
- kFillRule,
- kFilter,
- kFontFamily,
- kFontSize,
- kLetterSpacing,
- kMask,
- kOpacity,
- kStopColor,
- kStopOpacity,
- kStroke,
- kStroke_Dasharray,
- kStroke_Linecap,
- kStroke_Linejoin,
- kStroke_Miterlimit,
- kStroke_Width,
- kStyle,
- kTransform,
- kTerminal
- };
-
- SkSVGPaint();
- virtual void addAttribute(SkSVGParser& parser, int attrIndex,
- const char* attrValue, size_t attrLength);
- bool flush(SkSVGParser& , bool isFlushable, bool isDef);
- virtual int getAttributes(const SkSVGAttribute** attrPtr);
- static void Push(SkSVGPaint** head, SkSVGPaint* add);
- static void Pop(SkSVGPaint** head);
- SkString* operator[](int index);
- SkString fInitial;
- SkString f_clipPath;
- SkString f_clipRule;
- SkString f_enableBackground;
- SkString f_fill;
- SkString f_fillRule;
- SkString f_filter;
- SkString f_fontFamily;
- SkString f_fontSize;
- SkString f_letterSpacing;
- SkString f_mask;
- SkString f_opacity;
- SkString f_stopColor;
- SkString f_stopOpacity;
- SkString f_stroke;
- SkString f_strokeDasharray;
- SkString f_strokeLinecap;
- SkString f_strokeLinejoin;
- SkString f_strokeMiterlimit;
- SkString f_strokeWidth;
- SkString f_style; // unused, but allows array access to the rest
- SkString f_transform;
-#ifdef SK_DEBUG
- SkString fTerminal;
-#endif
- SkString fTransformID;
- static SkSVGAttribute gAttributes[];
- static const int kAttributesSize;
-private:
- void setSave(SkSVGParser& );
- bool writeChangedAttributes(SkSVGParser& , SkSVGPaint& , bool* changed);
- bool writeChangedElements(SkSVGParser& , SkSVGPaint& , bool* changed);
- SkSVGPaint* fNext;
- friend class SkSVGParser;
- typedef SkSVGPaint BASE_CLASS;
-};
-
-#endif // SkSVGPaintState_DEFINED
diff --git a/include/svg/SkSVGParser.h b/include/svg/SkSVGParser.h
deleted file mode 100644
index 83b120d..0000000
--- a/include/svg/SkSVGParser.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSVGParser_DEFINED
-#define SkSVGParser_DEFINED
-
-#include "SkMatrix.h"
-#include "SkTDict.h"
-#include "SkTDStack.h"
-#include "SkSVGPaintState.h"
-#include "SkSVGTypes.h"
-#include "SkStream.h"
-#include "SkString.h"
-#include "SkXMLParser.h"
-#include "SkXMLWriter.h"
-
-class SkSVGBase;
-class SkSVGElement;
-
-class SkSVGParser : public SkXMLParser {
-public:
- SkSVGParser(SkXMLParserError* err = NULL);
- virtual ~SkSVGParser();
- void _addAttribute(const char* attrName, const char* attrValue) {
- fXMLWriter.addAttribute(attrName, attrValue); }
- void _addAttribute(const char* attrName, SkString& attrValue) {
- fXMLWriter.addAttribute(attrName, attrValue.c_str()); }
- void _addAttributeLen(const char* attrName, const char* attrValue, size_t len) {
- fXMLWriter.addAttributeLen(attrName, attrValue, len); }
- void _endElement() { fXMLWriter.endElement(); }
- int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPaint);
- const char* getFinal();
- SkTDict<SkSVGElement*>& getIDs() { return fIDs; }
- SkString& getPaintLast(SkSVGPaint::Field field);
- void _startElement(const char name[]) { fXMLWriter.startElement(name); }
- void translate(SkSVGElement*, bool isDef);
- void translateMatrix(SkString& , SkString* id);
- static void ConvertToArray(SkString& vals);
-protected:
- virtual bool onAddAttribute(const char name[], const char value[]);
- bool onAddAttributeLen(const char name[], const char value[], size_t len);
- virtual bool onEndElement(const char elem[]);
- virtual bool onStartElement(const char elem[]);
- bool onStartElementLen(const char elem[], size_t len);
- virtual bool onText(const char text[], int len);
-private:
- bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill);
- static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent);
- static void Delete(SkTDArray<SkSVGElement*>& fChildren);
- static SkSVGTypes GetType(const char name[], size_t len);
- SkSVGPaint* fHead;
- SkSVGPaint fEmptyPaint;
- SkSVGPaint fLastFlush;
- SkString fLastColor;
- SkMatrix fLastTransform;
- SkTDArray<SkSVGElement*> fChildren;
- SkTDict<SkSVGElement*> fIDs;
- SkTDArray<SkSVGElement*> fParents;
- SkDynamicMemoryWStream fStream;
- SkXMLStreamWriter fXMLWriter;
- SkSVGElement* fCurrElement;
- SkBool8 fInSVG;
- SkBool8 fSuppressPaint;
- friend class SkSVGPaint;
- friend class SkSVGGradient;
-};
-
-#endif // SkSVGParser_DEFINED
diff --git a/include/svg/SkSVGTypes.h b/include/svg/SkSVGTypes.h
deleted file mode 100644
index 99d8ca1..0000000
--- a/include/svg/SkSVGTypes.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSVGTypes_DEFINED
-#define SkSVGTypes_DEFINED
-
-enum SkSVGTypes {
- SkSVGType_Circle,
- SkSVGType_ClipPath,
- SkSVGType_Defs,
- SkSVGType_Ellipse,
- SkSVGType_FeColorMatrix,
- SkSVGType_Filter,
- SkSVGType_G,
- SkSVGType_Image,
- SkSVGType_Line,
- SkSVGType_LinearGradient,
- SkSVGType_Mask,
- SkSVGType_Metadata,
- SkSVGType_Path,
- SkSVGType_Polygon,
- SkSVGType_Polyline,
- SkSVGType_RadialGradient,
- SkSVGType_Rect,
- SkSVGType_SVG,
- SkSVGType_Stop,
- SkSVGType_Symbol,
- SkSVGType_Text,
- SkSVGType_Tspan,
- SkSVGType_Unknown,
- SkSVGType_Use
-};
-
-#endif // SkSVGTypes_DEFINED
diff --git a/include/utils/SkCamera.h b/include/utils/SkCamera.h
index 96eacb3..6d76018 100644
--- a/include/utils/SkCamera.h
+++ b/include/utils/SkCamera.h
@@ -157,7 +157,9 @@ public:
void rotateY(SkScalar deg);
void rotateZ(SkScalar deg);
+#ifdef ANDROID
void setCameraLocation(SkScalar x, SkScalar y, SkScalar z);
+#endif
void getMatrix(SkMatrix*) const;
void applyToCanvas(SkCanvas*) const;
diff --git a/include/views/SkApplication.h b/include/views/SkApplication.h
deleted file mode 100644
index 4c4a4fb..0000000
--- a/include/views/SkApplication.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkApplication_DEFINED
-#define SkApplication_DEFINED
-
-class SkOSWindow;
-
-extern SkOSWindow* create_sk_window(void* hwnd);
-extern void application_init();
-extern void application_term();
-
-#endif // SkApplication_DEFINED
diff --git a/include/views/SkBGViewArtist.h b/include/views/SkBGViewArtist.h
deleted file mode 100644
index 1bca42f..0000000
--- a/include/views/SkBGViewArtist.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkBGViewArtist_DEFINED
-#define SkBGViewArtist_DEFINED
-
-#include "SkView.h"
-#include "SkPaint.h"
-
-class SkBGViewArtist : public SkView::Artist {
-public:
- SkBGViewArtist(SkColor c = SK_ColorWHITE);
- virtual ~SkBGViewArtist();
-
- const SkPaint& paint() const { return fPaint; }
- SkPaint& paint() { return fPaint; }
-
-protected:
- // overrides
- virtual void onDraw(SkView*, SkCanvas*);
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-
-private:
- SkPaint fPaint;
-};
-
-#endif
-
diff --git a/include/views/SkBorderView.h b/include/views/SkBorderView.h
deleted file mode 100644
index 94ccc1f..0000000
--- a/include/views/SkBorderView.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkBorderView_DEFINED
-#define SkBorderView_DEFINED
-
-#include "SkView.h"
-#include "SkWidgetViews.h"
-#include "SkAnimator.h"
-
-class SkBorderView : public SkWidgetView {
-public:
- SkBorderView();
- ~SkBorderView();
- void setSkin(const char skin[]);
- SkScalar getLeft() const { return fLeft; }
- SkScalar getRight() const { return fRight; }
- SkScalar getTop() const { return fTop; }
- SkScalar getBottom() const { return fBottom; }
-protected:
- //overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
- virtual void onSizeChange();
- virtual void onDraw(SkCanvas* canvas);
- virtual bool onEvent(const SkEvent& evt);
-private:
- SkAnimator fAnim;
- SkScalar fLeft, fRight, fTop, fBottom; //margin on each side
- SkRect fMargin;
-
- typedef SkWidgetView INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkEvent.h b/include/views/SkEvent.h
deleted file mode 100644
index f6719d6..0000000
--- a/include/views/SkEvent.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkEvent_DEFINED
-#define SkEvent_DEFINED
-
-#include "SkDOM.h"
-#include "SkMetaData.h"
-#include "SkString.h"
-
-/** Unique 32bit id used to identify an instance of SkEventSink. When events are
- posted, they are posted to a specific sinkID. When it is time to dispatch the
- event, the sinkID is used to find the specific SkEventSink object. If it is found,
- its doEvent() method is called with the event.
-*/
-typedef uint32_t SkEventSinkID;
-
-/** \class SkEvent
-
- SkEvents are used to communicate type-safe information to SkEventSinks.
- SkEventSinks (including SkViews) each have a unique ID, which is stored
- in an event. This ID is used to target the event once it has been "posted".
-*/
-class SkEvent {
-public:
- /** Default construct, creating an empty event.
- */
- SkEvent();
- /** Construct a new event with the specified type.
- */
- explicit SkEvent(const SkString& type);
- /** Construct a new event with the specified type.
- */
- explicit SkEvent(const char type[]);
- /** Construct a new event by copying the fields from the src event.
- */
- SkEvent(const SkEvent& src);
- ~SkEvent();
-
-// /** Return the event's type (will never be null) */
-// const char* getType() const;
- /** Copy the event's type into the specified SkString parameter */
- void getType(SkString* str) const;
- /** Returns true if the event's type matches exactly the specified type (case sensitive) */
- bool isType(const SkString& str) const;
- /** Returns true if the event's type matches exactly the specified type (case sensitive) */
- bool isType(const char type[], size_t len = 0) const;
- /** Set the event's type to the specified string.
- In XML, use the "type" attribute.
- */
- void setType(const SkString&);
- /** Set the event's type to the specified string.
- In XML, use the "type" attribute.
- */
- void setType(const char type[], size_t len = 0);
-
- /** Return the event's unnamed 32bit field. Default value is 0 */
- uint32_t getFast32() const { return f32; }
- /** Set the event's unnamed 32bit field. In XML, use
- the subelement <data fast32=... />
- */
- void setFast32(uint32_t x) { f32 = x; }
-
- /** Return true if the event contains the named 32bit field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findS32(const char name[], int32_t* value = NULL) const { return fMeta.findS32(name, value); }
- /** Return true if the event contains the named SkScalar field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findScalar(const char name[], SkScalar* value = NULL) const { return fMeta.findScalar(name, value); }
- /** Return true if the event contains the named SkScalar field, and return the fields
- in value[] (if value is non-null), and return the number of SkScalars in count (if count is non-null).
- If there is no matching named field, return false and ignore the value and count parameters.
- */
- const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = NULL) const { return fMeta.findScalars(name, count, values); }
- /** Return the value of the named string field, or if no matching named field exists, return null.
- */
- const char* findString(const char name[]) const { return fMeta.findString(name); }
- /** Return true if the event contains the named pointer field, and return the field
- in value (if value is non-null). If there is no matching named field, return false
- and ignore the value parameter.
- */
- bool findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
- bool findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
- const void* findData(const char name[], size_t* byteCount = NULL) const {
- return fMeta.findData(name, byteCount);
- }
-
- /** Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
- bool hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
- /** Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
- bool hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
- /** Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
- bool hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
- /** Returns true if ethe event contains the named pointer field, and if it equals the specified value */
- bool hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
- bool hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
- bool hasData(const char name[], const void* data, size_t byteCount) const {
- return fMeta.hasData(name, data, byteCount);
- }
-
- /** Add/replace the named 32bit field to the event. In XML use the subelement <data name=... s32=... /> */
- void setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
- /** Add/replace the named SkScalar field to the event. In XML use the subelement <data name=... scalar=... /> */
- void setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
- /** Add/replace the named SkScalar[] field to the event. */
- SkScalar* setScalars(const char name[], int count, const SkScalar values[] = NULL) { return fMeta.setScalars(name, count, values); }
- /** Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
- void setString(const char name[], const SkString& value) { fMeta.setString(name, value.c_str()); }
- /** Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
- void setString(const char name[], const char value[]) { fMeta.setString(name, value); }
- /** Add/replace the named pointer field to the event. There is no XML equivalent for this call */
- void setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
- void setBool(const char name[], bool value) { fMeta.setBool(name, value); }
- void setData(const char name[], const void* data, size_t byteCount) {
- fMeta.setData(name, data, byteCount);
- }
-
- /** Return the underlying metadata object */
- SkMetaData& getMetaData() { return fMeta; }
- /** Return the underlying metadata object */
- const SkMetaData& getMetaData() const { return fMeta; }
-
- void tron() { SkDEBUGCODE(fDebugTrace = true;) }
- void troff() { SkDEBUGCODE(fDebugTrace = false;) }
- bool isDebugTrace() const
- {
-#ifdef SK_DEBUG
- return fDebugTrace;
-#else
- return false;
-#endif
- }
-
- /** Call this to initialize the event from the specified XML node */
- void inflate(const SkDOM&, const SkDOM::Node*);
-
- SkDEBUGCODE(void dump(const char title[] = NULL);)
-
- /** Post the specified event to the event queue, targeting the specified eventsink, with an optional
- delay. The event must be dynamically allocated for this. It cannot be a global or on the stack.
- After this call, ownership is transfered to the system, so the caller must not retain
- the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
- */
- static bool Post(SkEvent* evt, SkEventSinkID targetID, SkMSec delay = 0);
- /** Post the specified event to the event queue, targeting the specified eventsink, to be delivered on/after the
- specified millisecond time. The event must be dynamically allocated for this. It cannot be a global or on the stack.
- After this call, ownership is transfered to the system, so the caller must not retain
- the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
- */
- static bool PostTime(SkEvent* evt, SkEventSinkID targetID, SkMSec time);
-
- /** Helper method for calling SkEvent::PostTime(this, ...), where the caller specifies a delay.
- The real "time" will be computed automatically by sampling the clock and adding its value
- to delay.
- */
- bool post(SkEventSinkID sinkID, SkMSec delay = 0)
- {
- return SkEvent::Post(this, sinkID, delay);
- }
-
- void postTime(SkEventSinkID sinkID, SkMSec time)
- {
- SkEvent::PostTime(this, sinkID, time);
- }
-
- ///////////////////////////////////////////////
- /** Porting layer must call these functions **/
- ///////////////////////////////////////////////
-
- /** Global initialization function for the SkEvent system. Should be called exactly
- once before any other event method is called, and should be called after the
- call to SkGraphics::Init().
- */
- static void Init();
- /** Global cleanup function for the SkEvent system. Should be called exactly once after
- all event methods have been called, and should be called before calling SkGraphics::Term().
- */
- static void Term();
-
- /** Call this to process one event from the queue. If it returns true, there are more events
- to process.
- */
- static bool ProcessEvent();
- /** Call this whenever the requested timer has expired (requested by a call to SetQueueTimer).
- It will post any delayed events whose time as "expired" onto the event queue.
- It may also call SignalQueueTimer() and SignalNonEmptyQueue().
- */
- static void ServiceQueueTimer();
-
- /** Return the number of queued events. note that this value may be obsolete
- upon return, since another thread may have called ProcessEvent() or
- Post() after the count was made.
- */
- static int CountEventsOnQueue();
-
- ////////////////////////////////////////////////////
- /** Porting layer must implement these functions **/
- ////////////////////////////////////////////////////
-
- /** Called whenever an SkEvent is posted to an empty queue, so that the OS
- can be told to later call Dequeue().
- */
- static void SignalNonEmptyQueue();
- /** Called whenever the delay until the next delayed event changes. If zero is
- passed, then there are no more queued delay events.
- */
- static void SignalQueueTimer(SkMSec delay);
-
-#ifndef SK_USE_WXWIDGETS
-#ifdef SK_BUILD_FOR_WIN
- static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-#elif defined(SK_BUILD_FOR_UNIXx)
- static uint32_t HandleTimer(uint32_t, void*);
- static bool WndProc(Display*, Window, XEvent&);
-#endif
-#else
- // Don't know yet what this will be
- //static bool CustomEvent();
-#endif
-
-private:
- SkMetaData fMeta;
- mutable char* fType; // may be characters with low bit set to know that it is not a pointer
- uint32_t f32;
- SkDEBUGCODE(bool fDebugTrace;)
-
- // these are for our implementation of the event queue
- SkEventSinkID fTargetID;
- SkMSec fTime;
- SkEvent* fNextEvent; // either in the delay or normal event queue
- void initialize(const char* type, size_t typeLen);
-
- static bool Enqueue(SkEvent* evt);
- static SkMSec EnqueueTime(SkEvent* evt, SkMSec time);
- static SkEvent* Dequeue(SkEventSinkID* targetID);
- static bool QHasEvents();
-};
-
-#endif
-
diff --git a/include/views/SkEventSink.h b/include/views/SkEventSink.h
deleted file mode 100644
index 27a6743..0000000
--- a/include/views/SkEventSink.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkEventSink_DEFINED
-#define SkEventSink_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkEvent.h"
-
-struct SkTagList;
-
-/** \class SkEventSink
-
- SkEventSink is the base class for all objects that receive SkEvents.
-*/
-class SkEventSink : public SkRefCnt {
-public:
- SkEventSink();
- virtual ~SkEventSink();
-
- /** Returns this eventsink's unique ID. Use this to post SkEvents to
- this eventsink.
- */
- SkEventSinkID getSinkID() const { return fID; }
-
- /** Call this to pass an event to this object for processing. Returns true if the
- event was handled.
- */
- bool doEvent(const SkEvent&);
- /** Returns true if the sink (or one of its subclasses) understands the event as a query.
- If so, the sink may modify the event to communicate its "answer".
- */
- bool doQuery(SkEvent* query);
-
- /** Add sinkID to the list of listeners, to receive events from calls to sendToListeners()
- and postToListeners(). If sinkID already exists in the listener list, no change is made.
- */
- void addListenerID(SkEventSinkID sinkID);
- /** Copy listeners from one event sink to another, typically from parent to child.
- @param from the event sink to copy the listeners from
- */
- void copyListeners(const SkEventSink& from);
- /** Remove sinkID from the list of listeners. If sinkID does not appear in the list,
- no change is made.
- */
- void removeListenerID(SkEventSinkID);
- /** Returns true if there are 1 or more listeners attached to this eventsink
- */
- bool hasListeners() const;
- /** Posts a copy of evt to each of the eventsinks in the lisener list.
- */
- void postToListeners(const SkEvent& evt, SkMSec delay = 0);
-
- enum EventResult {
- kHandled_EventResult, //!< the eventsink returned true from its doEvent method
- kNotHandled_EventResult, //!< the eventsink returned false from its doEvent method
- kSinkNotFound_EventResult //!< no matching eventsink was found for the event's getSink().
- };
- /** DoEvent handles searching for an eventsink object that matches the targetID.
- If one is found, it calls the sink's doEvent method, returning
- either kHandled_EventResult or kNotHandled_EventResult. If no matching
- eventsink is found, kSinkNotFound_EventResult is returned.
- */
- static EventResult DoEvent(const SkEvent&, SkEventSinkID targetID);
-
- /** Returns the matching eventsink, or null if not found
- */
- static SkEventSink* FindSink(SkEventSinkID);
-
-protected:
- /** Override this to handle events in your subclass. Be sure to call the inherited version
- for events that you don't handle.
- */
- virtual bool onEvent(const SkEvent&);
- virtual bool onQuery(SkEvent*);
-
- SkTagList* findTagList(U8CPU tag) const;
- void addTagList(SkTagList*);
- void removeTagList(U8CPU tag);
-
-private:
- SkEventSinkID fID;
- SkTagList* fTagHead;
-
- // for our private link-list
- SkEventSink* fNextSink;
-};
-
-#endif
-
diff --git a/include/views/SkImageView.h b/include/views/SkImageView.h
deleted file mode 100644
index 57215c9..0000000
--- a/include/views/SkImageView.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkImageView_DEFINED
-#define SkImageView_DEFINED
-
-#include "SkView.h"
-#include "SkString.h"
-
-class SkAnimator;
-class SkBitmap;
-class SkMatrix;
-
-class SkImageView : public SkView {
-public:
- SkImageView();
- virtual ~SkImageView();
-
- void getUri(SkString*) const;
- void setUri(const char []);
- void setUri(const SkString&);
-
-
- enum ScaleType {
- kMatrix_ScaleType,
- kFitXY_ScaleType,
- kFitStart_ScaleType,
- kFitCenter_ScaleType,
- kFitEnd_ScaleType
- };
- ScaleType getScaleType() const { return (ScaleType)fScaleType; }
- void setScaleType(ScaleType);
-
- bool getImageMatrix(SkMatrix*) const;
- void setImageMatrix(const SkMatrix*);
-
-protected:
- // overrides
- virtual bool onEvent(const SkEvent&);
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM&, const SkDOMNode*);
-
-private:
- SkString fUri;
- SkMatrix* fMatrix; // null or copy of caller's matrix ,,,,,
- union {
- SkAnimator* fAnim;
- SkBitmap* fBitmap;
- } fData;
- uint8_t fScaleType;
- SkBool8 fDataIsAnim; // as opposed to bitmap
- SkBool8 fUriIsValid;
-
- void onUriChange();
- bool getDataBounds(SkRect* bounds);
- bool freeData();
- bool ensureUriIsLoaded();
-
- typedef SkView INHERITED;
-};
-
-#endif
diff --git a/include/views/SkKey.h b/include/views/SkKey.h
deleted file mode 100644
index 3fd5114..0000000
--- a/include/views/SkKey.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkKey_DEFINED
-#define SkKey_DEFINED
-
-#include "SkTypes.h"
-
-enum SkKey {
- //reordering these to match android.app.KeyEvent
- kNONE_SkKey, //corresponds to android's UNKNOWN
-
- kLeftSoftKey_SkKey,
- kRightSoftKey_SkKey,
-
- kHome_SkKey, //!< the home key - added to match android
- kBack_SkKey, //!< (CLR)
- kSend_SkKey, //!< the green (talk) key
- kEnd_SkKey, //!< the red key
-
- k0_SkKey,
- k1_SkKey,
- k2_SkKey,
- k3_SkKey,
- k4_SkKey,
- k5_SkKey,
- k6_SkKey,
- k7_SkKey,
- k8_SkKey,
- k9_SkKey,
- kStar_SkKey, //!< the * key
- kHash_SkKey, //!< the # key
-
- kUp_SkKey,
- kDown_SkKey,
- kLeft_SkKey,
- kRight_SkKey,
-
- kOK_SkKey, //!< the center key
-
- kVolUp_SkKey, //!< volume up - match android
- kVolDown_SkKey, //!< volume down - same
- kPower_SkKey, //!< power button - same
- kCamera_SkKey, //!< camera - same
-
- kSkKeyCount
-};
-
-#endif
-
diff --git a/include/views/SkMetaData.h b/include/views/SkMetaData.h
deleted file mode 100644
index 9509710..0000000
--- a/include/views/SkMetaData.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkMetaData_DEFINED
-#define SkMetaData_DEFINED
-
-#include "SkScalar.h"
-
-class SkMetaData {
-public:
- SkMetaData();
- SkMetaData(const SkMetaData& src);
- ~SkMetaData();
-
- SkMetaData& operator=(const SkMetaData& src);
-
- void reset();
-
- bool findS32(const char name[], int32_t* value = NULL) const;
- bool findScalar(const char name[], SkScalar* value = NULL) const;
- const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = NULL) const;
- const char* findString(const char name[]) const;
- bool findPtr(const char name[], void** value = NULL) const;
- bool findBool(const char name[], bool* value = NULL) const;
- const void* findData(const char name[], size_t* byteCount = NULL) const;
-
- bool hasS32(const char name[], int32_t value) const
- {
- int32_t v;
- return this->findS32(name, &v) && v == value;
- }
- bool hasScalar(const char name[], SkScalar value) const
- {
- SkScalar v;
- return this->findScalar(name, &v) && v == value;
- }
- bool hasString(const char name[], const char value[]) const
- {
- const char* v = this->findString(name);
- return v == NULL && value == NULL ||
- v != NULL && value != NULL && !strcmp(v, value);
- }
- bool hasPtr(const char name[], void* value) const
- {
- void* v;
- return this->findPtr(name, &v) && v == value;
- }
- bool hasBool(const char name[], bool value) const
- {
- bool v;
- return this->findBool(name, &v) && v == value;
- }
- bool hasData(const char name[], const void* data, size_t byteCount) const {
- size_t len;
- const void* ptr = this->findData(name, &len);
- return NULL != ptr && len == byteCount && !memcmp(ptr, data, len);
- }
-
- void setS32(const char name[], int32_t value);
- void setScalar(const char name[], SkScalar value);
- SkScalar* setScalars(const char name[], int count, const SkScalar values[] = NULL);
- void setString(const char name[], const char value[]);
- void setPtr(const char name[], void* value);
- void setBool(const char name[], bool value);
- // the data is copied from the input pointer.
- void setData(const char name[], const void* data, size_t byteCount);
-
- bool removeS32(const char name[]);
- bool removeScalar(const char name[]);
- bool removeString(const char name[]);
- bool removePtr(const char name[]);
- bool removeBool(const char name[]);
- bool removeData(const char name[]);
-
- SkDEBUGCODE(static void UnitTest();)
-
- enum Type {
- kS32_Type,
- kScalar_Type,
- kString_Type,
- kPtr_Type,
- kBool_Type,
- kData_Type,
-
- kTypeCount
- };
-
- struct Rec;
- class Iter;
- friend class Iter;
-
- class Iter {
- public:
- Iter() : fRec(NULL) {}
- Iter(const SkMetaData&);
-
- /** Reset the iterator, so that calling next() will return the first
- data element. This is done implicitly in the constructor.
- */
- void reset(const SkMetaData&);
-
- /** Each time next is called, it returns the name of the next data element,
- or null when there are no more elements. If non-null is returned, then the
- element's type is returned (if not null), and the number of data values
- is returned in count (if not null).
- */
- const char* next(Type*, int* count);
-
- private:
- Rec* fRec;
- };
-
-public:
- struct Rec {
- Rec* fNext;
- uint16_t fDataCount; // number of elements
- uint8_t fDataLen; // sizeof a single element
-#ifdef SK_DEBUG
- Type fType;
-#else
- uint8_t fType;
-#endif
-
-#ifdef SK_DEBUG
- const char* fName;
- union {
- int32_t fS32;
- SkScalar fScalar;
- const char* fString;
- void* fPtr;
- bool fBool;
- } fData;
-#endif
-
- const void* data() const { return (this + 1); }
- void* data() { return (this + 1); }
- const char* name() const { return (const char*)this->data() + fDataLen * fDataCount; }
- char* name() { return (char*)this->data() + fDataLen * fDataCount; }
-
- static Rec* Alloc(size_t);
- static void Free(Rec*);
- };
- Rec* fRec;
-
- const Rec* find(const char name[], Type) const;
- void* set(const char name[], const void* data, size_t len, Type, int count);
- bool remove(const char name[], Type);
-};
-
-#endif
-
diff --git a/include/views/SkOSMenu.h b/include/views/SkOSMenu.h
deleted file mode 100644
index 433a601..0000000
--- a/include/views/SkOSMenu.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkOSMenu_DEFINED
-#define SkOSMenu_DEFINED
-
-#include "SkEvent.h"
-#include "SkTDArray.h"
-
-class SkOSMenu {
-public:
- explicit SkOSMenu(const char title[]);
- ~SkOSMenu();
-
- const char* getTitle() const { return fTitle; }
-
- void appendItem(const char title[], const char eventType[], int32_t eventData);
-
- // called by SkOSWindow when it receives an OS menu event
- int countItems() const;
- const char* getItem(int index, uint32_t* cmdID) const;
-
- SkEvent* createEvent(uint32_t os_cmd);
-
-private:
- const char* fTitle;
-
- struct Item {
- const char* fTitle;
- const char* fEventType;
- uint32_t fEventData;
- uint32_t fOSCmd; // internal
- };
- SkTDArray<Item> fItems;
-
- // illegal
- SkOSMenu(const SkOSMenu&);
- SkOSMenu& operator=(const SkOSMenu&);
-};
-
-#endif
-
diff --git a/include/views/SkOSWindow_Mac.h b/include/views/SkOSWindow_Mac.h
deleted file mode 100644
index 3a26d5a..0000000
--- a/include/views/SkOSWindow_Mac.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkOSWindow_Mac_DEFINED
-#define SkOSWindow_Mac_DEFINED
-
-#include <Carbon/Carbon.h>
-#include "SkWindow.h"
-
-class SkOSWindow : public SkWindow {
-public:
- SkOSWindow(void* hwnd);
-
- void* getHWND() const { return fHWND; }
- void* getHVIEW() const { return fHVIEW; }
- void updateSize();
-
- static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
-
- static OSStatus EventHandler(EventHandlerCallRef inHandler,
- EventRef inEvent, void* userData);
-
- void doPaint(void* ctx);
-
-
- bool attachGL(const SkBitmap* offscreen);
- void detachGL();
- void presentGL();
-
-protected:
- // overrides from SkEventSink
- virtual bool onEvent(const SkEvent& evt);
- // overrides from SkWindow
- virtual void onHandleInval(const SkIRect&);
- // overrides from SkView
- virtual void onAddMenu(const SkOSMenu*);
- virtual void onSetTitle(const char[]);
-
-
-private:
- void* fHWND;
- void* fHVIEW;
- void* fAGLCtx;
-
- typedef SkWindow INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkOSWindow_SDL.h b/include/views/SkOSWindow_SDL.h
deleted file mode 100644
index 0ff24f3..0000000
--- a/include/views/SkOSWindow_SDL.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkOSWindow_SDL_DEFINED
-#define SkOSWindow_SDL_DEFINED
-
-#include "SDL.h"
-#include "SkWindow.h"
-
-class SkGLCanvas;
-
-class SkOSWindow : public SkWindow {
-public:
- SkOSWindow(void* screen);
- virtual ~SkOSWindow();
-
- static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
-
- void handleSDLEvent(const SDL_Event& event);
-
-protected:
- // overrides from SkWindow
- virtual void onHandleInval(const SkIRect&);
- // overrides from SkView
- virtual void onAddMenu(const SkOSMenu*);
- virtual void onSetTitle(const char[]);
-
-private:
- SDL_Surface* fScreen;
- SDL_Surface* fSurface;
- SkGLCanvas* fGLCanvas;
-
- void doDraw();
-
- typedef SkWindow INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkOSWindow_Unix.h b/include/views/SkOSWindow_Unix.h
deleted file mode 100644
index 26f51be..0000000
--- a/include/views/SkOSWindow_Unix.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkOSWindow_Unix_DEFINED
-#define SkOSWindow_Unix_DEFINED
-
-#include "SkWindow.h"
-#include <X11/Xlib.h>
-
-struct SkUnixWindow {
- Display* fDisplay;
- Window fWin;
- size_t fOSWin;
-};
-
-class SkOSWindow : public SkWindow {
-public:
- SkOSWindow(Display* display, Window win);
-
- void* getHWND() const { return (void*)fUnixWindow.fWin; }
- void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
- void* getUnixWindow() const { return (void*)&fUnixWindow; }
- void setSize(int width, int height);
- void updateSize();
-
- static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
-
- static bool WndProc(SkUnixWindow* w, XEvent &e);
-
-protected:
- // overrides from SkWindow
- virtual void onHandleInval(const SkIRect&);
- // overrides from SkView
- virtual void onAddMenu(const SkOSMenu*);
-
-private:
- SkUnixWindow fUnixWindow;
-
- void doPaint();
-
- void* fMBar;
-
- typedef SkWindow INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkOSWindow_Win.h b/include/views/SkOSWindow_Win.h
deleted file mode 100644
index 09f0c5c..0000000
--- a/include/views/SkOSWindow_Win.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkOSWindow_Win_DEFINED
-#define SkOSWindow_Win_DEFINED
-
-#include "SkWindow.h"
-
-class SkOSWindow : public SkWindow {
-public:
- SkOSWindow(void* hwnd);
- virtual ~SkOSWindow();
-
- void* getHWND() const { return fHWND; }
- void setSize(int width, int height);
- void updateSize();
-
- static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
-
- bool attachGL(const SkBitmap* offscreen);
- void detachGL();
- void presentGL();
-
- bool attachD3D9();
- void detachD3D9();
- void presentD3D9();
-
- void* d3d9Device() { return fD3D9Device; }
-
- bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- static bool QuitOnDeactivate(HWND hWnd);
-
- enum {
- SK_WM_SkEvent = WM_APP + 1000,
- SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
- };
-
-protected:
- virtual bool quitOnDeactivate() { return true; }
-
- // overrides from SkWindow
- virtual void onHandleInval(const SkIRect&);
- // overrides from SkView
- virtual void onAddMenu(const SkOSMenu*);
-
- virtual void onSetTitle(const char title[]);
-
-private:
- void* fHWND;
-
- void doPaint(void* ctx);
-
- void* fHGLRC;
-
- bool fGLAttached;
-
- void* fD3D9Device;
- bool fD3D9Attached;
-
- HMENU fMBar;
-
- typedef SkWindow INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkOSWindow_wxwidgets.h b/include/views/SkOSWindow_wxwidgets.h
deleted file mode 100644
index c5dfc7c..0000000
--- a/include/views/SkOSWindow_wxwidgets.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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.
- */
-
-/*
- * SkOSWindow_wxwidgets.h
- * wxwidgets
- *
- * Copyright 2005 __MyCompanyName__. All rights reserved.
- *
- */
-
-#ifndef SkOSWindow_wxwidgets_DEFINED
-#define SkOSWindow_wxwidgets_DEFINED
-
-#include "SkWindow.h"
-#include "wx/frame.h"
-
-class SkOSWindow: public SkWindow
-{
-public:
- SkOSWindow();
- SkOSWindow(const wxString& title, int x, int y, int width, int height);
- ~SkOSWindow();
-
- wxFrame* getWXFrame() const { return fFrame; }
-
- void updateSize();
-
-protected:
- virtual void onHandleInval(const SkIRect&);
- virtual void onAddMenu(const SkOSMenu*);
-
-private:
- wxFrame* fFrame;
- typedef SkWindow INHERITED;
-
-};
-
-#endifpedef SkWindow INHERITED;
diff --git a/include/views/SkProgressBarView.h b/include/views/SkProgressBarView.h
deleted file mode 100644
index 6341fcb..0000000
--- a/include/views/SkProgressBarView.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkProgressBarView_DEFINED
-#define SkProgressBarView_DEFINED
-
-#include "SkView.h"
-#include "SkWidgetViews.h"
-#include "SkAnimator.h"
-
-class SkProgressBarView : public SkWidgetView {
- public:
- SkProgressBarView();
- //SkProgressBarView(int max);
-
- //inflate: "sk-progress"
-
- void reset(); //reset progress to zero
- void setProgress(int progress);
- void changeProgress(int diff);
- void setMax(int max);
-
- int getProgress() const { return fProgress; }
- int getMax() const { return fMax; }
-
- protected:
- //overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
- virtual void onSizeChange();
- virtual void onDraw(SkCanvas* canvas);
- virtual bool onEvent(const SkEvent& evt);
-
- private:
- SkAnimator fAnim;
- int fProgress;
- int fMax;
-
- typedef SkWidgetView INHERITED;
-};
-
-
-
-
-#endif
diff --git a/include/views/SkScrollBarView.h b/include/views/SkScrollBarView.h
deleted file mode 100644
index b8a5209..0000000
--- a/include/views/SkScrollBarView.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkScrollBarView_DEFINED
-#define SkScrollBarView_DEFINED
-
-#include "SkView.h"
-#include "SkWidgetViews.h"
-#include "SkAnimator.h"
-
-class SkScrollBarView : public SkWidgetView {
-public:
- SkScrollBarView();
-
- unsigned getStart() const { return fStartPoint; }
- unsigned getShown() const { return fShownLength; }
- unsigned getTotal() const { return fTotalLength; }
-
- void setStart(unsigned start);
- void setShown(unsigned shown);
- void setTotal(unsigned total);
-
-protected:
- //overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
- virtual void onSizeChange();
- virtual void onDraw(SkCanvas* canvas);
- virtual bool onEvent(const SkEvent& evt);
-
-private:
- SkAnimator fAnim;
- unsigned fTotalLength, fStartPoint, fShownLength;
-
- void adjust();
-
- typedef SkWidgetView INHERITED;
-};
-#endif
-
diff --git a/include/views/SkStackViewLayout.h b/include/views/SkStackViewLayout.h
deleted file mode 100644
index 8000319..0000000
--- a/include/views/SkStackViewLayout.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkStackViewLayout_DEFINED
-#define SkStackViewLayout_DEFINED
-
-#include "SkView.h"
-
-class SkStackViewLayout : public SkView::Layout {
-public:
- SkStackViewLayout();
-
- enum Orient {
- kHorizontal_Orient,
- kVertical_Orient,
-
- kOrientCount
- };
- Orient getOrient() const { return (Orient)fOrient; }
- void setOrient(Orient);
-
- void getMargin(SkRect*) const;
- void setMargin(const SkRect&);
-
- SkScalar getSpacer() const { return fSpacer; }
- void setSpacer(SkScalar);
-
- /** Controls the posititioning in the same direction as the orientation
- */
- enum Pack {
- kStart_Pack,
- kCenter_Pack,
- kEnd_Pack,
-
- kPackCount
- };
- Pack getPack() const { return (Pack)fPack; }
- void setPack(Pack);
-
- /** Controls the posititioning at right angles to the orientation
- */
- enum Align {
- kStart_Align,
- kCenter_Align,
- kEnd_Align,
- kStretch_Align,
-
- kAlignCount
- };
- Align getAlign() const { return (Align)fAlign; }
- void setAlign(Align);
-
- bool getRound() const { return SkToBool(fRound); }
- void setRound(bool);
-
-protected:
- virtual void onLayoutChildren(SkView* parent);
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-
-private:
- SkRect fMargin;
- SkScalar fSpacer;
- uint8_t fOrient, fPack, fAlign, fRound;
-};
-
-class SkFillViewLayout : public SkView::Layout {
-public:
- SkFillViewLayout();
- void getMargin(SkRect*) const;
- void setMargin(const SkRect&);
-
-protected:
- // overrides;
- virtual void onLayoutChildren(SkView* parent);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkRect fMargin;
- typedef SkView::Layout INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkSystemEventTypes.h b/include/views/SkSystemEventTypes.h
deleted file mode 100644
index 8dfe8be..0000000
--- a/include/views/SkSystemEventTypes.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkSystemEventTypes_DEFINED
-#define SkSystemEventTypes_DEFINED
-
-/*
- The goal of these strings is two-fold:
- 1) make funny strings (containing at least one char < 32) to avoid colliding with "user" strings
- 2) keep them <= 4 bytes, so we can avoid an allocation in SkEvent::setType()
-*/
-#define SK_EventType_Delay "\xd" "lay"
-#define SK_EventType_Inval "nv" "\xa" "l"
-#define SK_EventType_Key "key" "\x1"
-#define SK_EventType_OnEnd "on" "\xe" "n"
-#define SK_EventType_Unichar "\xc" "har"
-#define SK_EventType_KeyUp "key" "\xf"
-
-#endif
diff --git a/include/views/SkView.h b/include/views/SkView.h
deleted file mode 100644
index d3633db..0000000
--- a/include/views/SkView.h
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkView_DEFINED
-#define SkView_DEFINED
-
-#include "SkEventSink.h"
-#include "SkRect.h"
-#include "SkDOM.h"
-#include "SkTDict.h"
-
-class SkCanvas;
-class SkLayerView;
-
-/** \class SkView
-
- SkView is the base class for screen management. All widgets and controls inherit
- from SkView.
-*/
-class SkView : public SkEventSink {
-public:
- enum Flag_Shift {
- kVisible_Shift,
- kEnabled_Shift,
- kFocusable_Shift,
- kFlexH_Shift,
- kFlexV_Shift,
- kNoClip_Shift,
-
- kFlagShiftCount
- };
- enum Flag_Mask {
- kVisible_Mask = 1 << kVisible_Shift, //!< set if the view is visible
- kEnabled_Mask = 1 << kEnabled_Shift, //!< set if the view is enabled
- kFocusable_Mask = 1 << kFocusable_Shift, //!< set if the view can receive focus
- kFlexH_Mask = 1 << kFlexH_Shift, //!< set if the view's width is stretchable
- kFlexV_Mask = 1 << kFlexV_Shift, //!< set if the view's height is stretchable
- kNoClip_Mask = 1 << kNoClip_Shift, //!< set if the view is not clipped to its bounds
-
- kAllFlagMasks = (uint32_t)(0 - 1) >> (32 - kFlagShiftCount)
- };
-
- SkView(uint32_t flags = 0);
- virtual ~SkView();
-
- /** Return the flags associated with the view
- */
- uint32_t getFlags() const { return fFlags; }
- /** Set the flags associated with the view
- */
- void setFlags(uint32_t flags);
-
- /** Helper that returns non-zero if the kVisible_Mask bit is set in the view's flags
- */
- int isVisible() const { return fFlags & kVisible_Mask; }
- int isEnabled() const { return fFlags & kEnabled_Mask; }
- int isFocusable() const { return fFlags & kFocusable_Mask; }
- int isClipToBounds() const { return !(fFlags & kNoClip_Mask); }
- /** Helper to set/clear the view's kVisible_Mask flag */
- void setVisibleP(bool);
- void setEnabledP(bool);
- void setFocusableP(bool);
- void setClipToBounds(bool);
-
- /** Return the view's width */
- SkScalar width() const { return fWidth; }
- /** Return the view's height */
- SkScalar height() const { return fHeight; }
- /** Set the view's width and height. These must both be >= 0. This does not affect the view's loc */
- void setSize(SkScalar width, SkScalar height);
- void setSize(const SkPoint& size) { this->setSize(size.fX, size.fY); }
- void setWidth(SkScalar width) { this->setSize(width, fHeight); }
- void setHeight(SkScalar height) { this->setSize(fWidth, height); }
- /** Return a rectangle set to [0, 0, width, height] */
- void getLocalBounds(SkRect* bounds) const;
-
- /** Return the view's left edge */
- SkScalar locX() const { return fLoc.fX; }
- /** Return the view's top edge */
- SkScalar locY() const { return fLoc.fY; }
- /** Set the view's left and top edge. This does not affect the view's size */
- void setLoc(SkScalar x, SkScalar y);
- void setLoc(const SkPoint& loc) { this->setLoc(loc.fX, loc.fY); }
- void setLocX(SkScalar x) { this->setLoc(x, fLoc.fY); }
- void setLocY(SkScalar y) { this->setLoc(fLoc.fX, y); }
- /** Offset (move) the view by the specified dx and dy. This does not affect the view's size */
- void offset(SkScalar dx, SkScalar dy);
-
- /** Call this to have the view draw into the specified canvas. */
- virtual void draw(SkCanvas* canvas);
-
- /** Call this to invalidate part of all of a view, requesting that the view's
- draw method be called. The rectangle parameter specifies the part of the view
- that should be redrawn. If it is null, it specifies the entire view bounds.
- */
- void inval(SkRect* rectOrNull);
-
- // Focus management
-
- SkView* getFocusView() const;
- bool hasFocus() const;
-
- enum FocusDirection {
- kNext_FocusDirection,
- kPrev_FocusDirection,
-
- kFocusDirectionCount
- };
- bool acceptFocus();
- SkView* moveFocus(FocusDirection);
-
- // Click handling
-
- class Click {
- public:
- Click(SkView* target);
- virtual ~Click();
-
- const char* getType() const { return fType; }
- bool isType(const char type[]) const;
- void setType(const char type[]); // does NOT make a copy of the string
- void copyType(const char type[]); // makes a copy of the string
-
- enum State {
- kDown_State,
- kMoved_State,
- kUp_State
- };
- SkPoint fOrig, fPrev, fCurr;
- SkIPoint fIOrig, fIPrev, fICurr;
- State fState;
- private:
- SkEventSinkID fTargetID;
- char* fType;
- bool fWeOwnTheType;
-
- void resetType();
-
- friend class SkView;
- };
- Click* findClickHandler(SkScalar x, SkScalar y);
-
- static void DoClickDown(Click*, int x, int y);
- static void DoClickMoved(Click*, int x, int y);
- static void DoClickUp(Click*, int x, int y);
-
- /** Send the event to the view's parent, and its parent etc. until one of them
- returns true from its onEvent call. This view is returned. If no parent handles
- the event, null is returned.
- */
- SkView* sendEventToParents(const SkEvent&);
- /** Send the query to the view's parent, and its parent etc. until one of them
- returns true from its onQuery call. This view is returned. If no parent handles
- the query, null is returned.
- */
- SkView* sendQueryToParents(SkEvent*);
-
- /** Depricated helper function. Just call event->post(sinkID, delay);
- */
- bool postEvent(SkEvent* evt, SkEventSinkID sinkID, SkMSec delay) { return evt->post(sinkID, delay); }
-
- // View hierarchy management
-
- /** Return the view's parent, or null if it has none. This does not affect the parent's reference count. */
- SkView* getParent() const { return fParent; }
- SkView* attachChildToFront(SkView* child);
- /** Attach the child view to this view, and increment the child's reference count. The child view is added
- such that it will be drawn before all other child views.
- The child view parameter is returned.
- */
- SkView* attachChildToBack(SkView* child);
- /** If the view has a parent, detach the view from its parent and decrement the view's reference count.
- If the parent was the only owner of the view, this will cause the view to be deleted.
- */
- void detachFromParent();
- /** Attach the child view to this view, and increment the child's reference count. The child view is added
- such that it will be drawn after all other child views.
- The child view parameter is returned.
- */
- /** Detach all child views from this view. */
- void detachAllChildren();
-
- /** Convert the specified point from global coordinates into view-local coordinates
- */
- void globalToLocal(SkPoint* pt) const { if (pt) this->globalToLocal(pt->fX, pt->fY, pt); }
- /** Convert the specified x,y from global coordinates into view-local coordinates, returning
- the answer in the local parameter.
- */
- void globalToLocal(SkScalar globalX, SkScalar globalY, SkPoint* local) const;
-
- /** \class F2BIter
-
- Iterator that will return each of this view's children, in
- front-to-back order (the order used for clicking). The first
- call to next() returns the front-most child view. When
- next() returns null, there are no more child views.
- */
- class F2BIter {
- public:
- F2BIter(const SkView* parent);
- SkView* next();
- private:
- SkView* fFirstChild, *fChild;
- };
-
- /** \class B2FIter
-
- Iterator that will return each of this view's children, in
- back-to-front order (the order they are drawn). The first
- call to next() returns the back-most child view. When
- next() returns null, there are no more child views.
- */
- class B2FIter {
- public:
- B2FIter(const SkView* parent);
- SkView* next();
- private:
- SkView* fFirstChild, *fChild;
- };
-
- /** \class Artist
-
- Install a subclass of this in a view (calling setArtist()), and then the
- default implementation of that view's onDraw() will invoke this object
- automatically.
- */
- class Artist : public SkRefCnt {
- public:
- void draw(SkView*, SkCanvas*);
- void inflate(const SkDOM&, const SkDOM::Node*);
- protected:
- virtual void onDraw(SkView*, SkCanvas*) = 0;
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
- };
- /** Return the artist attached to this view (or null). The artist's reference
- count is not affected.
- */
- Artist* getArtist() const;
- /** Attach the specified artist (or null) to the view, replacing any existing
- artist. If the new artist is not null, its reference count is incremented.
- The artist parameter is returned.
- */
- Artist* setArtist(Artist* artist);
-
- /** \class Layout
-
- Install a subclass of this in a view (calling setLayout()), and then the
- default implementation of that view's onLayoutChildren() will invoke
- this object automatically.
- */
- class Layout : public SkRefCnt {
- public:
- void layoutChildren(SkView* parent);
- void inflate(const SkDOM&, const SkDOM::Node*);
- protected:
- virtual void onLayoutChildren(SkView* parent) = 0;
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
- };
-
- /** Return the layout attached to this view (or null). The layout's reference
- count is not affected.
- */
- Layout* getLayout() const;
- /** Attach the specified layout (or null) to the view, replacing any existing
- layout. If the new layout is not null, its reference count is incremented.
- The layout parameter is returned.
- */
- Layout* setLayout(Layout*, bool invokeLayoutNow = true);
- /** If a layout is attached to this view, call its layoutChildren() method
- */
- void invokeLayout();
-
- /** Call this to initialize this view based on the specified XML node
- */
- void inflate(const SkDOM& dom, const SkDOM::Node* node);
- /** After a view hierarchy is inflated, this may be called with a dictionary
- containing pairs of <name, view*>, where the name string was the view's
- "id" attribute when it was inflated.
-
- This will call the virtual onPostInflate for this view, and the recursively
- call postInflate on all of the view's children.
- */
- void postInflate(const SkTDict<SkView*>& ids);
-
- SkDEBUGCODE(void dump(bool recurse) const;)
-
-protected:
- /** Override this to draw inside the view. Be sure to call the inherited version too */
- virtual void onDraw(SkCanvas*);
- /** Override this to be notified when the view's size changes. Be sure to call the inherited version too */
- virtual void onSizeChange();
- /** Override this if you want to handle an inval request from this view or one of its children.
- Tyically this is only overridden by the by the "window". If your subclass does handle the
- request, return true so the request will not continue to propogate to the parent.
- */
- virtual bool handleInval(const SkRect*);
- //! called once before all of the children are drawn (or clipped/translated)
- virtual SkCanvas* beforeChildren(SkCanvas* c) { return c; }
- //! called once after all of the children are drawn (or clipped/translated)
- virtual void afterChildren(SkCanvas* orig) {}
-
- //! called right before this child's onDraw is called
- virtual void beforeChild(SkView* child, SkCanvas* canvas) {}
- //! called right after this child's onDraw is called
- virtual void afterChild(SkView* child, SkCanvas* canvas) {}
-
- /** Override this if you might handle the click
- */
- virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
- /** Override this to decide if your children are targets for a click.
- The default returns true, in which case your children views will be
- candidates for onFindClickHandler. Returning false wil skip the children
- and just call your onFindClickHandler.
- */
- virtual bool onSendClickToChildren(SkScalar x, SkScalar y);
- /** Override this to track clicks, returning true as long as you want to track
- the pen/mouse.
- */
- virtual bool onClick(Click*);
- /** Override this to initialize your subclass from the XML node. Be sure to call the inherited version too */
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
- /** Override this if you want to perform post initialization work based on the ID dictionary built
- during XML parsing. Be sure to call the inherited version too.
- */
- virtual void onPostInflate(const SkTDict<SkView*>&);
-
-public:
- // default action is to inval the view
- virtual void onFocusChange(bool gainFocusP);
-protected:
-
- // override these if you're acting as a layer/host
- virtual bool onGetFocusView(SkView**) const { return false; }
- virtual bool onSetFocusView(SkView*) { return false; }
-
-private:
- SkScalar fWidth, fHeight;
- SkPoint fLoc;
- SkView* fParent;
- SkView* fFirstChild;
- SkView* fNextSibling;
- SkView* fPrevSibling;
- uint8_t fFlags;
- uint8_t fContainsFocus;
-
- friend class B2FIter;
- friend class F2BIter;
-
- friend class SkLayerView;
-
- bool setFocusView(SkView* fvOrNull);
- SkView* acceptFocus(FocusDirection);
- void detachFromParent_NoLayout();
-};
-
-#endif
-
diff --git a/include/views/SkViewInflate.h b/include/views/SkViewInflate.h
deleted file mode 100644
index 3ec65a6..0000000
--- a/include/views/SkViewInflate.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkViewInflate_DEFINED
-#define SkViewInflate_DEFINED
-
-#include "SkDOM.h"
-#include "SkTDict.h"
-#include "SkEvent.h"
-
-class SkView;
-
-class SkViewInflate {
-public:
- SkViewInflate();
- virtual ~SkViewInflate();
-
- /** Return the tree of inflated views. If root is null, create the root element
- as a view, otherwise assume root is that view, and just "inflate" it.
-
- Returns null if the tree cannot be built.
- */
- SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NULL);
- SkView* inflate(const char xml[], size_t len, SkView* root = NULL);
-
- /** Given an id attribute value, return the corresponding view, or null
- if no match is found.
- */
- SkView* findViewByID(const char id[]) const;
-
- SkDEBUGCODE(void dump() const;)
-
-protected:
- /* Override this in your subclass to handle instantiating views
- Call the inherited version for nodes you don't recognize.
-
- Do not call "inflate" on the view, just return it. This will
- get called automatically after createView returns.
- */
- virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
- /** Base implementation calls view->inflate(dom, node). Subclasses may override this
- to perform additional initializations to view, either before or after calling
- the inherited version.
- */
- virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- enum {
- kMinIDStrAlloc = 64
- };
- SkTDict<SkView*> fIDs;
-
- struct IDStr {
- SkView* fView;
- char* fStr;
- };
- SkTDArray<IDStr> fListenTo, fBroadcastTo;
- SkChunkAlloc fStrings;
-
- void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
-
- void rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
-};
-
-#endif
-
diff --git a/include/views/SkWidget.h b/include/views/SkWidget.h
deleted file mode 100644
index db85f01..0000000
--- a/include/views/SkWidget.h
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkWidget_DEFINED
-#define SkWidget_DEFINED
-
-#include "SkView.h"
-#include "SkBitmap.h"
-#include "SkDOM.h"
-#include "SkPaint.h"
-#include "SkString.h"
-#include "SkTDArray.h"
-
-//////////////////////////////////////////////////////////////////////////////
-
-class SkWidget : public SkView {
-public:
- SkWidget(uint32_t flags = 0) : SkView(flags | kFocusable_Mask | kEnabled_Mask) {}
-
- /** Call this to post the widget's event to its listeners */
- void postWidgetEvent();
-
- static void Init();
- static void Term();
-protected:
- // override to add slots to an event before posting
- virtual void prepareWidgetEvent(SkEvent*);
- virtual void onEnabledChange();
-
- // <event ...> to initialize the event from XML
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkEvent fEvent;
- typedef SkView INHERITED;
-};
-
-class SkHasLabelWidget : public SkWidget {
-public:
- SkHasLabelWidget(uint32_t flags = 0) : SkWidget(flags) {}
-
- size_t getLabel(SkString* label = NULL) const;
- size_t getLabel(char lable[] = NULL) const;
- void setLabel(const SkString&);
- void setLabel(const char label[]);
- void setLabel(const char label[], size_t len);
-
-protected:
- // called when the label changes
- virtual void onLabelChange();
-
- // overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- SkString fLabel;
- typedef SkWidget INHERITED;
-};
-
-class SkButtonWidget : public SkHasLabelWidget {
-public:
- SkButtonWidget(uint32_t flags = 0) : SkHasLabelWidget(flags), fState(kOff_State) {}
-
- enum State {
- kOff_State, //!< XML: buttonState="off"
- kOn_State, //!< XML: buttonState="on"
- kUnknown_State //!< XML: buttonState="unknown"
- };
- State getButtonState() const { return fState; }
- void setButtonState(State);
-
-protected:
- /** called when the label changes. default behavior is to inval the widget */
- virtual void onButtonStateChange();
-
- // overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- State fState;
- typedef SkHasLabelWidget INHERITED;
-};
-
-class SkPushButtonWidget : public SkButtonWidget {
-public:
- SkPushButtonWidget(uint32_t flags = 0) : SkButtonWidget(flags) {}
-
-protected:
- virtual bool onEvent(const SkEvent&);
- virtual void onDraw(SkCanvas*);
- virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
- virtual bool onClick(Click* click);
-
-private:
- typedef SkButtonWidget INHERITED;
-};
-
-class SkCheckBoxWidget : public SkButtonWidget {
-public:
- SkCheckBoxWidget(uint32_t flags = 0);
-
-protected:
- virtual bool onEvent(const SkEvent&);
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- typedef SkButtonWidget INHERITED;
-};
-
-#include "SkTextBox.h"
-
-class SkStaticTextView : public SkView {
-public:
- SkStaticTextView(uint32_t flags = 0);
- virtual ~SkStaticTextView();
-
- enum Mode {
- kFixedSize_Mode,
- kAutoWidth_Mode,
- kAutoHeight_Mode,
-
- kModeCount
- };
- Mode getMode() const { return (Mode)fMode; }
- void setMode(Mode);
-
- SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
- void setSpacingAlign(SkTextBox::SpacingAlign);
-
- void getMargin(SkPoint* margin) const;
- void setMargin(SkScalar dx, SkScalar dy);
-
- size_t getText(SkString* text = NULL) const;
- size_t getText(char text[] = NULL) const;
- void setText(const SkString&);
- void setText(const char text[]);
- void setText(const char text[], size_t len);
-
- void getPaint(SkPaint*) const;
- void setPaint(const SkPaint&);
-
-protected:
- // overrides
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- SkPoint fMargin;
- SkString fText;
- SkPaint fPaint;
- uint8_t fMode;
- uint8_t fSpacingAlign;
-
- void computeSize();
-
- typedef SkView INHERITED;
-};
-
-class SkBitmapView : public SkView {
-public:
- SkBitmapView(uint32_t flags = 0);
- virtual ~SkBitmapView();
-
- bool getBitmap(SkBitmap*) const;
- void setBitmap(const SkBitmap*, bool viewOwnsPixels);
- bool loadBitmapFromFile(const char path[]);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-
-private:
- SkBitmap fBitmap;
- typedef SkView INHERITED;
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-class SkShader;
-class SkInterpolator;
-
-class SkWidgetView : public SkView {
-public:
- SkWidgetView(uint32_t flags = 0);
- virtual ~SkWidgetView();
-
- static const char* GetEventType();
-};
-
-class SkSliderView : public SkWidgetView {
-public:
- SkSliderView(uint32_t flags = 0);
-
- uint16_t getValue() const { return fValue; }
- uint16_t getMax() const { return fMax; }
-
- void setMax(U16CPU max);
- void setValue(U16CPU value);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
- virtual bool onClick(Click*);
-
-private:
- uint16_t fValue, fMax;
-
- typedef SkWidgetView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-class SkHasLabelView : public SkView {
-public:
- void getLabel(SkString*) const;
- void setLabel(const SkString&);
- void setLabel(const char label[]);
-
-protected:
- SkString fLabel;
-
- // called when the label changes
- virtual void onLabelChange();
-
- // overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-};
-
-class SkPushButtonView : public SkHasLabelView {
-public:
- SkPushButtonView(uint32_t flags = 0);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-};
-
-class SkCheckBoxView : public SkHasLabelView {
-public:
- SkCheckBoxView(uint32_t flags = 0);
-
- enum State {
- kOff_State,
- kOn_State,
- kMaybe_State
- };
- State getState() const { return fState; }
- void setState(State);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- State fState;
-};
-
-class SkProgressView : public SkView {
-public:
- SkProgressView(uint32_t flags = 0);
- virtual ~SkProgressView();
-
- uint16_t getValue() const { return fValue; }
- uint16_t getMax() const { return fMax; }
-
- void setMax(U16CPU max);
- void setValue(U16CPU value);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- uint16_t fValue, fMax;
- SkShader* fOnShader, *fOffShader;
- SkInterpolator* fInterp;
- bool fDoInterp;
-
- typedef SkView INHERITED;
-};
-
-class SkTextView : public SkView {
-public:
- SkTextView(uint32_t flags = 0);
- virtual ~SkTextView();
-
- enum AnimaDir {
- kNeutral_AnimDir,
- kForward_AnimDir,
- kBackward_AnimDir,
- kAnimDirCount
- };
-
- void getText(SkString*) const;
- void setText(const SkString&, AnimaDir dir = kNeutral_AnimDir);
- void setText(const char text[], AnimaDir dir = kNeutral_AnimDir);
- void setText(const char text[], size_t len, AnimaDir dir = kNeutral_AnimDir);
-
- void getMargin(SkPoint* margin) const;
- void setMargin(const SkPoint&);
-
- SkPaint& paint() { return fPaint; }
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkString fText;
- SkPaint fPaint;
- SkPoint fMargin;
-
- class Interp;
- Interp* fInterp;
- bool fDoInterp;
- // called by the other setText methods. This guy does not check for !=
- // before doing the assign, so the caller must check for us
- void privSetText(const SkString&, AnimaDir dir);
-
- typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////
-
-class SkEvent;
-
-class SkListSource : public SkEventSink {
-public:
- virtual int countRows() = 0;
- virtual void getRow(int index, SkString* left, SkString* right) = 0;
- virtual SkEvent* getEvent(int index);
-
- static SkListSource* CreateFromDir(const char path[], const char suffix[],
- const char targetPrefix[]);
- static SkListSource* CreateFromDOM(const SkDOM& dom, const SkDOM::Node* node);
-};
-
-class SkListView : public SkWidgetView {
-public:
- SkListView(uint32_t flags = 0);
- virtual ~SkListView();
-
- SkScalar getRowHeight() const { return fRowHeight; }
- void setRowHeight(SkScalar);
-
- /** Return the index of the selected row, or -1 if none
- */
- int getSelection() const { return fCurrIndex; }
- /** Set the index of the selected row, or -1 for none
- */
- void setSelection(int);
-
- void moveSelectionUp();
- void moveSelectionDown();
-
- enum Attr {
- kBG_Attr,
- kNormalText_Attr,
- kHiliteText_Attr,
- kHiliteCell_Attr,
- kAttrCount
- };
- SkPaint& paint(Attr);
-
- SkListSource* getListSource() const { return fSource; }
- SkListSource* setListSource(SkListSource*);
-
-#if 0
- enum Action {
- kSelectionChange_Action,
- kSelectionPicked_Action,
- kActionCount
- };
- /** If event is not null, it is retained by the view, and a copy
- of the event will be posted to its listeners when the specified
- action occurs. If event is null, then no event will be posted for
- the specified action.
- */
- void setActionEvent(Action, SkEvent* event);
-#endif
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onSizeChange();
- virtual bool onEvent(const SkEvent&);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkPaint fPaint[kAttrCount];
- SkListSource* fSource;
- SkScalar fRowHeight;
- int fCurrIndex; // logical index
- int fScrollIndex; // logical index of top-most visible row
- int fVisibleRowCount;
- SkString* fStrCache;
-
- void dirtyStrCache();
- void ensureStrCache(int visibleCount);
-
- int logicalToVisualIndex(int index) const { return index - fScrollIndex; }
- void invalSelection();
- bool getRowRect(int index, SkRect*) const;
- void ensureSelectionIsVisible();
-
- typedef SkWidgetView INHERITED;
-};
-
-//////////////////////////////////////////////////////////
-
-class SkGridView : public SkWidgetView {
-public:
- SkGridView(uint32_t flags = 0);
- virtual ~SkGridView();
-
- void getCellSize(SkPoint*) const;
- void setCellSize(SkScalar x, SkScalar y);
-
- /** Return the index of the selected item, or -1 if none
- */
- int getSelection() const { return fCurrIndex; }
- /** Set the index of the selected row, or -1 for none
- */
- void setSelection(int);
-
- void moveSelectionUp();
- void moveSelectionDown();
-
- enum Attr {
- kBG_Attr,
- kHiliteCell_Attr,
- kAttrCount
- };
- SkPaint& paint(Attr);
-
- SkListSource* getListSource() const { return fSource; }
- SkListSource* setListSource(SkListSource*);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onSizeChange();
- virtual bool onEvent(const SkEvent&);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkView* fScrollBar;
- SkPaint fPaint[kAttrCount];
- SkListSource* fSource;
- int fCurrIndex; // logical index
-
- SkPoint fCellSize;
- SkIPoint fVisibleCount;
-
- int logicalToVisualIndex(int index) const { return index; }
- void invalSelection();
- bool getCellRect(int index, SkRect*) const;
- void ensureSelectionIsVisible();
-
- typedef SkWidgetView INHERITED;
-};
-
-#endif
-
diff --git a/include/views/SkWidgetViews.h b/include/views/SkWidgetViews.h
deleted file mode 100644
index 4dd8866..0000000
--- a/include/views/SkWidgetViews.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkWidgetViews_DEFINED
-#define SkWidgetViews_DEFINED
-
-#include "SkView.h"
-
-
-enum SkWidgetEnum {
- kBorder_WidgetEnum, //!< <sk-border>
- kButton_WidgetEnum, //!< <sk-button>
- kImage_WidgetEnum, //!< <sk-image>
- kList_WidgetEnum, //!< <sk-list>
- kProgress_WidgetEnum, //!< <sk-progress>
- kScroll_WidgetEnum, //!< <sk-scroll>
- kText_WidgetEnum, //!< <sk-text>
-
- kWidgetEnumCount
-};
-
-//determines which skin to use
-enum SkinEnum {
- kBorder_SkinEnum,
- kButton_SkinEnum,
- kProgress_SkinEnum,
- kScroll_SkinEnum,
- kStaticText_SkinEnum,
-
- kSkinEnumCount
-};
-
-#include "SkAnimator.h"
-//used for inflates
-const char* get_skin_enum_path(SkinEnum se);
-void init_skin_anim(const char path[], SkAnimator* anim);
-void init_skin_anim(SkinEnum se, SkAnimator* anim);
-void init_skin_paint(SkinEnum se, SkPaint* paint);
-void inflate_paint(const SkDOM& dom, const SkDOM::Node* node, SkPaint* paint);
-
-/** Given an enum value, return an instance of the specified widget.
- If the enum is out of range, returns null
-*/
-SkView* SkWidgetFactory(SkWidgetEnum);
-/** Given the inflate/element name of a widget, return an instance of
- the specified widget, or null if name does not match any known
- widget type.
-*/
-SkView* SkWidgetFactory(const char name[]);
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-class SkWidgetView : public SkView {
-public:
- SkWidgetView();
-
- const char* getLabel() const;
- void getLabel(SkString* label) const;
-
- void setLabel(const char[]);
- void setLabel(const char[], size_t len);
- void setLabel(const SkString&);
-
- SkEvent& event() { return fEvent; }
- const SkEvent& event() const { return fEvent; }
-
- /** Returns true if the widget can post its event to its listeners.
- */
- bool postWidgetEvent();
-
- /** Returns the sinkID of the widgetview that posted the event, or 0
- */
- static SkEventSinkID GetWidgetEventSinkID(const SkEvent&);
-
-protected:
- /** called when the label changes. override in subclasses. default action invals the view's bounds.
- called with the old and new labels, before the label has actually changed.
- */
- virtual void onLabelChange(const char oldLabel[], const char newLabel[]);
- /** called before posting the event to our listeners. Override to add slots to the event
- before posting. Return true to proceed with posting, or false to not post the event to any
- listener. Note: the event passed in may not be the same as calling this->event().
- Be sure to call your INHERITED method as well, so that all classes in the hierarchy get a shot
- at modifying the event (and possibly returning false to abort).
- */
- virtual bool onPrepareWidgetEvent(SkEvent* evt);
-
- // overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- SkString fLabel;
- SkEvent fEvent;
-
- typedef SkView INHERITED;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-class SkButtonView : public SkWidgetView {
-public:
- // inflate: "sk-button"
-
-protected:
- // overrides
- virtual bool onEvent(const SkEvent&);
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-class SkCheckButtonView : public SkWidgetView {
-public:
- SkCheckButtonView();
-
- // inflate: "sk-checkbutton"
-
- enum CheckState {
- kOff_CheckState, //!< inflate: check-state="off"
- kOn_CheckState, //!< inflate: check-state="on"
- kUnknown_CheckState //!< inflate: check-state="unknown"
- };
- CheckState getCheckState() const { return (CheckState)fCheckState; }
- void setCheckState(CheckState);
-
- /** use this to extract the CheckState from an event (i.e. one that as posted
- by a SkCheckButtonView). Returns true if the proper slot was present in the event,
- and sets state to that value. If no proper slot is found, returns false and does not
- modify state.
- */
- static bool GetWidgetEventCheckState(const SkEvent&, CheckState* state);
-
-protected:
- // called when the check-state is about to change, but before it actually has
- virtual void onCheckStateChange(CheckState oldState, CheckState newState);
-
- // overrides
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
- virtual bool onPrepareWidgetEvent(SkEvent* evt);
-
-private:
- uint8_t fCheckState;
-
- typedef SkWidgetView INHERITED;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-#include "SkTextBox.h"
-
-class SkStaticTextView : public SkView {
-public:
- SkStaticTextView();
- virtual ~SkStaticTextView();
-
- enum Mode {
- kFixedSize_Mode,
- kAutoWidth_Mode,
- kAutoHeight_Mode,
-
- kModeCount
- };
- Mode getMode() const { return (Mode)fMode; }
- void setMode(Mode);
-
- SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
- void setSpacingAlign(SkTextBox::SpacingAlign);
-
- void getMargin(SkPoint* margin) const;
- void setMargin(SkScalar dx, SkScalar dy);
-
- size_t getText(SkString* text = NULL) const;
- size_t getText(char text[] = NULL) const;
- void setText(const SkString&);
- void setText(const char text[]);
- void setText(const char text[], size_t len);
-
- void getPaint(SkPaint*) const;
- void setPaint(const SkPaint&);
-
-protected:
- // overrides
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-
-private:
- SkPoint fMargin;
- SkString fText;
- SkPaint fPaint;
- uint8_t fMode;
- uint8_t fSpacingAlign;
-
- void computeSize();
-
- typedef SkView INHERITED;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-class SkAnimator;
-class SkListSource;
-class SkScrollBarView;
-
-class SkListView : public SkWidgetView {
-public:
- SkListView();
- virtual ~SkListView();
-
- bool hasScrollBar() const { return fScrollBar != NULL; }
- void setHasScrollBar(bool);
-
- /** Return the number of visible rows
- */
- int getVisibleRowCount() const { return fVisibleRowCount; }
- /** Return the index of the selected row, or -1 if none
- */
- int getSelection() const { return fCurrIndex; }
- /** Set the index of the selected row, or -1 for none
- */
- void setSelection(int);
- /** If possible, move the selection up and return true,
- else do nothing and return false
- If nothing is selected, select the last item (unless there are no items).
- */
- bool moveSelectionUp();
- /** If possible, move the selection down and return true,
- else do nothing and return false.
- If nothing is selected, select the first item (unless there are no items).
- */
- bool moveSelectionDown();
-
- SkListSource* getListSource() const { return fSource; }
- SkListSource* setListSource(SkListSource*);
-
- /** Call this in your event handler. If the specified event is from a SkListView,
- then it returns the index of the selected item in this list, otherwise it
- returns -1
- */
- static int GetWidgetEventListIndex(const SkEvent&);
-
-protected:
- // overrides
- virtual void onDraw(SkCanvas*);
- virtual void onSizeChange();
- virtual bool onEvent(const SkEvent&);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
- virtual bool onPrepareWidgetEvent(SkEvent*);
-
-private:
- enum DirtyFlags {
- kAnimCount_DirtyFlag = 0x01,
- kAnimContent_DirtyFlag = 0x02
- };
- void dirtyCache(unsigned dirtyFlags);
- bool ensureCache();
-
- int logicalToVisualIndex(int index) const { return index - fScrollIndex; }
- void invalSelection();
- SkScalar getContentWidth() const;
- bool getRowRect(int index, SkRect*) const;
- void ensureSelectionIsVisible();
- void ensureVisibleRowCount();
-
- struct BindingRec;
-
- enum Heights {
- kNormal_Height,
- kSelected_Height
- };
- SkListSource* fSource;
- SkScrollBarView* fScrollBar;
- SkAnimator* fAnims;
- BindingRec* fBindings;
- SkString fSkinName;
- SkScalar fHeights[2];
- int16_t fScrollIndex, fCurrIndex;
- uint16_t fVisibleRowCount, fBindingCount;
- SkBool8 fAnimContentDirty;
- SkBool8 fAnimFocusDirty;
-
- typedef SkWidgetView INHERITED;
-};
-
-class SkListSource : public SkRefCnt {
-public:
- virtual int countFields();
- virtual void getFieldName(int index, SkString* field);
- /** Return the index of the named field, or -1 if not found */
- virtual int findFieldIndex(const char field[]);
-
- virtual int countRecords();
- virtual void getRecord(int rowIndex, int fieldIndex, SkString* data);
-
- virtual bool prepareWidgetEvent(SkEvent*, int rowIndex);
-
- static SkListSource* Factory(const char name[]);
-};
-
-#endif
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
deleted file mode 100644
index 5deefd5..0000000
--- a/include/views/SkWindow.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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 SkWindow_DEFINED
-#define SkWindow_DEFINED
-
-#include "SkView.h"
-#include "SkBitmap.h"
-#include "SkMatrix.h"
-#include "SkRegion.h"
-#include "SkEvent.h"
-#include "SkKey.h"
-#include "SkTDArray.h"
-
-#ifdef SK_BUILD_FOR_WINCEx
- #define SHOW_FPS
-#endif
-//#define USE_GX_SCREEN
-
-class SkCanvas;
-
-class SkOSMenu;
-
-class SkWindow : public SkView {
-public:
- SkWindow();
- virtual ~SkWindow();
-
- const SkBitmap& getBitmap() const { return fBitmap; }
-
- void setConfig(SkBitmap::Config);
- void resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config);
- void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
- void eraseRGB(U8CPU r, U8CPU g, U8CPU b);
-
- bool isDirty() const { return !fDirtyRgn.isEmpty(); }
- bool update(SkIRect* updateArea, SkCanvas* = NULL);
- // does not call through to onHandleInval(), but does force the fDirtyRgn
- // to be wide open. Call before update() to ensure we redraw everything.
- void forceInvalAll();
- // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
- const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
-
- bool handleClick(int x, int y, Click::State);
- bool handleChar(SkUnichar);
- bool handleKey(SkKey);
- bool handleKeyUp(SkKey);
- bool handleMenu(uint32_t os_cmd);
-
- void addMenu(SkOSMenu*);
-
- const char* getTitle() const { return fTitle.c_str(); }
- void setTitle(const char title[]);
-
- const SkMatrix& getMatrix() const { return fMatrix; }
- void setMatrix(const SkMatrix&);
- void preConcat(const SkMatrix&);
- void postConcat(const SkMatrix&);
-
-protected:
- virtual bool onEvent(const SkEvent&);
-
- // called if part of our bitmap is invalidated
- virtual void onHandleInval(const SkIRect&);
- virtual bool onHandleChar(SkUnichar);
- virtual bool onHandleKey(SkKey);
- virtual bool onHandleKeyUp(SkKey);
- virtual void onAddMenu(const SkOSMenu*) {}
- virtual void onSetTitle(const char title[]) {}
-
- // overrides from SkView
- virtual bool handleInval(const SkRect*);
- virtual bool onGetFocusView(SkView** focus) const;
- virtual bool onSetFocusView(SkView* focus);
-
-private:
- SkBitmap::Config fConfig;
- SkBitmap fBitmap;
- SkRegion fDirtyRgn;
- Click* fClick; // to track clicks
-
- SkTDArray<SkOSMenu*> fMenus;
-
- SkView* fFocusView;
- bool fWaitingOnInval;
-
- SkString fTitle;
- SkMatrix fMatrix;
-
- typedef SkView INHERITED;
-};
-
-///////////////////////////////////////////////////////////
-
-#ifdef SK_USE_WXWIDGETS
- #include "SkOSWindow_wxwidgets.h"
-#elif defined(SK_BUILD_FOR_MAC)
- #include "SkOSWindow_Mac.h"
-#elif defined(SK_BUILD_FOR_WIN)
- #include "SkOSWindow_Win.h"
-#elif defined(SK_BUILD_FOR_UNIXx)
- #include "SkOSWindow_Unix.h"
-#elif defined(SK_BUILD_FOR_SDL)
- #include "SkOSWindow_SDL.h"
-#elif defined(SK_BUILD_FOR_IOS)
- #include "SkOSWindow_iOS.h"
-#endif
-
-#endif
-