aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-05-29 11:22:44 -0400
committerMike Reed <reed@google.com>2009-05-29 13:07:11 -0400
commitdab163f0b2658c2dba48839e72f81d3d8ee0ae8b (patch)
treec5d930c6372b11c826f83342a8d75da0c6f8f2e6 /include
parent98ce92aad4dc2c7808abb7cedc8dfbdb3700e590 (diff)
downloadexternal_skia-dab163f0b2658c2dba48839e72f81d3d8ee0ae8b.zip
external_skia-dab163f0b2658c2dba48839e72f81d3d8ee0ae8b.tar.gz
external_skia-dab163f0b2658c2dba48839e72f81d3d8ee0ae8b.tar.bz2
refresh from skia/trunk
- add canvas entry-point for shapes - add SDL support to GL port - rowbytes computation fixes in bitmaps
Diffstat (limited to 'include')
-rw-r--r--include/core/SkBitmap.h16
-rw-r--r--include/core/SkCanvas.h5
-rw-r--r--include/core/SkColorPriv.h2
-rw-r--r--include/core/SkPreConfig.h2
-rw-r--r--include/core/SkRefCnt.h17
-rw-r--r--include/core/SkShape.h40
-rw-r--r--include/images/SkImageDecoder.h35
-rw-r--r--include/utils/SkDumpCanvas.h4
-rw-r--r--include/utils/SkProxyCanvas.h3
-rw-r--r--include/views/SkWindow.h10
10 files changed, 103 insertions, 31 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 48055d0..4c20412 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -367,12 +367,11 @@ public:
*/
bool extractSubset(SkBitmap* dst, const SkIRect& subset) const;
- /** Tries to make a new bitmap based on the dimensions of this bitmap,
- setting the new bitmap's config to the one specified, and then copying
- this bitmap's pixels into the new bitmap. If the conversion is not
- supported, or the allocator fails, then this method returns false and
- dst is left unchanged.
- @param dst The bitmap to be sized and allocated
+ /** Makes a deep copy of this bitmap, respecting the requested config.
+ Returns false if either there is an error (i.e. the src does not have
+ pixels) or the request cannot be satisfied (e.g. the src has per-pixel
+ alpha, and the requested config does not support alpha).
+ @param dst The bitmap to be sized and allocated
@param c The desired config for dst
@param allocator Allocator used to allocate the pixelref for the dst
bitmap. If this is null, the standard HeapAllocator
@@ -381,6 +380,11 @@ public:
*/
bool copyTo(SkBitmap* dst, Config c, Allocator* allocator = NULL) const;
+ /** Returns true if this bitmap can be deep copied into the requested config
+ by calling copyTo().
+ */
+ bool canCopyTo(Config newConfig) const;
+
bool hasMipMap() const;
void buildMipMap(bool forceRebuild = false);
void freeMipMap();
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index a19a5ae..77eb134 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -32,6 +32,7 @@ class SkDevice;
class SkDraw;
class SkDrawFilter;
class SkPicture;
+class SkShape;
/** \class SkCanvas
@@ -591,6 +592,10 @@ public:
*/
virtual void drawPicture(SkPicture& picture);
+ /** Draws the specified shape
+ */
+ virtual void drawShape(SkShape*);
+
enum VertexMode {
kTriangles_VertexMode,
kTriangleStrip_VertexMode,
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index a82697e..7658d5b 100644
--- a/include/core/SkColorPriv.h
+++ b/include/core/SkColorPriv.h
@@ -33,7 +33,7 @@
*/
static inline unsigned SkAlpha255To256(U8CPU alpha) {
SkASSERT(SkToU8(alpha) == alpha);
-#if 1
+#ifndef SK_USE_OLD_255_TO_256
// this one assues that blending on top of an opaque dst keeps it that way
// even though it is less accurate than a+(a>>7) for non-opaque dsts
return alpha + 1;
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index 05f3d43..b66c97e 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -19,7 +19,7 @@
//////////////////////////////////////////////////////////////////////
-#if !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_SYMBIAN) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC)
+#if !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_SYMBIAN) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_SDL)
#if defined(PALMOS_SDK_VERSION)
#define SK_BUILD_FOR_PALM
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index adb59dd..7e325e0 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -130,5 +130,22 @@ private:
dst = src; \
} while (0)
+
+/** Check if the argument is non-null, and if so, call obj->ref()
+ */
+template <typename T> static inline void SkSafeRef(T* obj) {
+ if (obj) {
+ obj->ref();
+ }
+}
+
+/** Check if the argument is non-null, and if so, call obj->unref()
+ */
+template <typename T> static inline void SkSafeUnref(T* obj) {
+ if (obj) {
+ obj->unref();
+ }
+}
+
#endif
diff --git a/include/core/SkShape.h b/include/core/SkShape.h
new file mode 100644
index 0000000..abe4e26
--- /dev/null
+++ b/include/core/SkShape.h
@@ -0,0 +1,40 @@
+#ifndef SkShape_DEFINED
+#define SkShape_DEFINED
+
+#include "SkFlattenable.h"
+
+class SkCanvas;
+class SkMatrix;
+class SkWStream;
+
+class SkShape : public SkFlattenable {
+public:
+ SkShape() {}
+
+ void draw(SkCanvas*);
+
+ /** Draw the shape translated by (dx,dy), which is applied before the
+ shape's matrix (if any).
+ */
+ void drawXY(SkCanvas*, SkScalar dx, SkScalar dy);
+
+ /** Draw the shape with the specified matrix, applied before the shape's
+ matrix (if any).
+ */
+ void drawMatrix(SkCanvas*, const SkMatrix&);
+
+ // overrides
+ virtual void flatten(SkFlattenableWriteBuffer&);
+
+protected:
+ virtual void onDraw(SkCanvas*) = 0;
+
+ SkShape(SkFlattenableReadBuffer&) {}
+
+private:
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
+
+ typedef SkFlattenable INHERITED;
+};
+
+#endif
diff --git a/include/images/SkImageDecoder.h b/include/images/SkImageDecoder.h
index c85a7cd..d2b23a1 100644
--- a/include/images/SkImageDecoder.h
+++ b/include/images/SkImageDecoder.h
@@ -29,7 +29,7 @@ class SkStream;
class SkImageDecoder {
public:
virtual ~SkImageDecoder();
-
+
enum Format {
kUnknown_Format,
kBMP_Format,
@@ -38,10 +38,10 @@ public:
kJPEG_Format,
kPNG_Format,
kWBMP_Format,
-
+
kLastKnownFormat = kWBMP_Format
};
-
+
/** Return the compressed data's format (see Format enum)
*/
virtual Format getFormat() const;
@@ -50,14 +50,14 @@ public:
The default setting is true.
*/
bool getDitherImage() const { return fDitherImage; }
-
+
/** Set to true if the the decoder should try to dither the resulting image.
The default setting is true.
*/
void setDitherImage(bool dither) { fDitherImage = dither; }
/** \class Peeker
-
+
Base class for optional callbacks to retrieve meta/chunk data out of
an image as it is being decoded.
*/
@@ -71,9 +71,9 @@ public:
Peeker* getPeeker() const { return fPeeker; }
Peeker* setPeeker(Peeker*);
-
+
/** \class Peeker
-
+
Base class for optional callbacks to retrieve meta/chunk data out of
an image as it is being decoded.
*/
@@ -100,7 +100,7 @@ public:
// approximate the sample size.
int getSampleSize() const { return fSampleSize; }
void setSampleSize(int size);
-
+
/** Reset the sampleSize to its default of 1
*/
void resetSampleSize() { this->setSampleSize(1); }
@@ -113,7 +113,7 @@ public:
it is possible that cancelDecode() will be called, but will be ignored
and decode() will return true (assuming no other problems were
encountered).
-
+
This state is automatically reset at the beginning of decode().
*/
void cancelDecode() {
@@ -130,16 +130,19 @@ public:
kDecodeBounds_Mode, //!< only return width/height/config in bitmap
kDecodePixels_Mode //!< return entire bitmap (including pixels)
};
-
+
/** Given a stream, decode it into the specified bitmap.
If the decoder can decompress the image, it calls bitmap.setConfig(),
and then if the Mode is kDecodePixels_Mode, call allocPixelRef(),
which will allocated a pixelRef. To access the pixel memory, the codec
needs to call lockPixels/unlockPixels on the
bitmap. It can then set the pixels with the decompressed image.
- If the image cannot be decompressed, return false.
-
- note: document use of Allocator, Peeker and Chooser
+ * If the image cannot be decompressed, return false. After the
+ * decoding, the function converts the decoded config in bitmap
+ * to pref if possible. Whether a conversion is feasible is
+ * tested by Bitmap::canCopyTo(pref).
+
+ note: document use of Allocator, Peeker and Chooser
*/
bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode);
@@ -198,7 +201,7 @@ public:
return DecodeStream(stream, bitmap, SkBitmap::kNo_Config,
kDecodePixels_Mode);
}
-
+
/** Return the default config for the running device.
Currently this used as a suggestion to image decoders that need to guess
what config they should decode into.
@@ -227,14 +230,14 @@ protected:
true, your onDecode() should stop and return false.
Each subclass needs to decide how often it can query this, to balance
responsiveness with performance.
-
+
Calling this outside of onDecode() may return undefined values.
*/
public:
bool shouldCancelDecode() const { return fShouldCancelDecode; }
-protected:
+protected:
SkImageDecoder();
// helper function for decoders to handle the (common) case where there is only
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
index b919627..5347309 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -33,6 +33,7 @@ public:
kDrawBitmap_Verb,
kDrawText_Verb,
kDrawPicture_Verb,
+ kDrawShape_Verb,
kDrawVertices_Verb
};
@@ -92,7 +93,8 @@ public:
virtual void drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint);
- virtual void drawPicture(SkPicture& picture);
+ virtual void drawPicture(SkPicture&);
+ virtual void drawShape(SkShape*);
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index 1bc411a..f2e57ab 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -68,7 +68,8 @@ public:
virtual void drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint);
- virtual void drawPicture(SkPicture& picture);
+ virtual void drawPicture(SkPicture&);
+ virtual void drawShape(SkShape*);
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index da3912e..1c8f9a3 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -90,16 +90,16 @@ private:
///////////////////////////////////////////////////////////
-#ifndef SK_USE_WXWIDGETS
-#ifdef SK_BUILD_FOR_MAC
+#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"
-#endif
-#else
- #include "SkOSWindow_wxwidgets.h"
+#elif defined(SK_BUILD_FOR_SDL)
+ #include "SkOSWindow_SDL.h"
#endif
#endif