Upstreaming changes from android.
- fix compile warnings in the GPU code
- upstream android specific code (ifdef protected)
- fail gracefully when a custom allocator fails
git-svn-id: http://skia.googlecode.com/svn/trunk@936 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 56d7478..1d21a2f 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -468,16 +468,29 @@
*/
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);
}
- void extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
+ /** 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 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
+ @param allocator Allocator used to allocate the pixelref for the dst
+ bitmap. If this is null, the standard HeapAllocator
+ will be used.
+ @param offset If not null, it is set to top-left coordinate to position
+ the returned bitmap so that it visually lines up with the
+ original
+ */
+ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
SkIPoint* offset) const;
void flatten(SkFlattenableWriteBuffer&) const;
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index eef3aea..5aecacb 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -626,6 +626,21 @@
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
+ @param byteLength The number of bytes to read from the text parameter
+ @param pos Array of positions, used to position each character
+ @param paint The paint used for the text (e.g. color, size, style)
+ @param path The path to draw on
+ @param matrix The canvas matrix
+ */
+ 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
of this canvas will be unchanged after this call. This contrasts with
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 48b86c2..55d823b 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -197,6 +197,11 @@
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,
diff --git a/include/core/SkDraw.h b/include/core/SkDraw.h
index 1c4a621..99ab342 100644
--- a/include/core/SkDraw.h
+++ b/include/core/SkDraw.h
@@ -55,6 +55,11 @@
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,
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index e669f2c..3c69251 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -278,6 +278,18 @@
static void SetSubpixelOrder(LCDOrder order);
static LCDOrder GetSubpixelOrder();
+
+#ifdef ANDROID
+ ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the number of font units per em.
+ *
+ * @param fontID the font to query.
+ * @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/SkRegion.h b/include/core/SkRegion.h
index 58f4f3f..7ddf087 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -249,6 +249,12 @@
*/
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.
*/
diff --git a/include/effects/SkPorterDuff.h b/include/effects/SkPorterDuff.h
index 6f4ac20..54f81ea 100644
--- a/include/effects/SkPorterDuff.h
+++ b/include/effects/SkPorterDuff.h
@@ -52,6 +52,9 @@
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/utils/SkCamera.h b/include/utils/SkCamera.h
index 8bbcabf..6d76018 100644
--- a/include/utils/SkCamera.h
+++ b/include/utils/SkCamera.h
@@ -157,6 +157,10 @@
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;