diff --git a/Makefile.in b/Makefile.in index 3b9f3234818b..a212b650ec02 100644 --- a/Makefile.in +++ b/Makefile.in @@ -66,7 +66,7 @@ tier_base_dirs = \ ifndef LIBXUL_SDK ifeq (android,$(MOZ_WIDGET_TOOLKIT)) -tier_base_dirs += other-licenses/android +tier_base_dirs += other-licenses/android other-licenses/skia-npapi endif tier_base_dirs += memory diff --git a/dom/plugins/base/Makefile.in b/dom/plugins/base/Makefile.in index 402fe7765545..bece2944c408 100644 --- a/dom/plugins/base/Makefile.in +++ b/dom/plugins/base/Makefile.in @@ -133,7 +133,10 @@ endif endif LOCAL_INCLUDES += \ + -DSK_BUILD_FOR_ANDROID_NDK \ -I$(topsrcdir)/xpcom/base/ \ + -I$(topsrcdir)/gfx/skia/include/core \ + -I$(topsrcdir)/gfx/skia/include/config \ $(MOZ_CAIRO_CFLAGS) \ $(NULL) diff --git a/dom/plugins/base/android/ANPBase.h b/dom/plugins/base/android/ANPBase.h index d84aab988ac0..729de6a5a342 100644 --- a/dom/plugins/base/android/ANPBase.h +++ b/dom/plugins/base/android/ANPBase.h @@ -39,7 +39,6 @@ #include "android_npapi.h" #include #include "nsAutoPtr.h" -#include "gfxFont.h" #include "nsISupportsImpl.h" #define NOT_IMPLEMENTED_FATAL() do { \ @@ -54,8 +53,6 @@ "!!!!!!!!!!!!!! %s not implemented %s, %d", \ __PRETTY_FUNCTION__, __FILE__, __LINE__); \ -class gfxFont; - void InitAudioTrackInterface(ANPAudioTrackInterfaceV0 *i); void InitBitmapInterface(ANPBitmapInterfaceV0 *i); void InitCanvasInterface(ANPCanvasInterfaceV0 *i); @@ -68,25 +65,3 @@ void InitSurfaceInterface(ANPSurfaceInterfaceV0 *i); void InitSystemInterface(ANPSystemInterfaceV0 *i); void InitTypeFaceInterface(ANPTypefaceInterfaceV0 *i); void InitWindowInterface(ANPWindowInterfaceV0 *i); - -struct ANPTypeface { - gfxFont* mFont; - nsAutoRefCnt mRefCnt; -}; - - -typedef struct { - ANPMatrixFlag flags; - ANPColor color; - ANPPaintStyle style; - float strokeWidth; - float strokeMiter; - ANPPaintCap paintCap; - ANPPaintJoin paintJoin; - ANPTextEncoding textEncoding; - ANPPaintAlign paintAlign; - float textSize; - float textScaleX; - float textSkewX; - ANPTypeface typeface; -} ANPPaintPrivate; diff --git a/dom/plugins/base/android/ANPCanvas.cpp b/dom/plugins/base/android/ANPCanvas.cpp deleted file mode 100644 index 918d4fd60dbd..000000000000 --- a/dom/plugins/base/android/ANPCanvas.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android NPAPI support code - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Doug Turner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "assert.h" -#include "ANPBase.h" -#include - -#include "cairo.h" -#include "gfxPlatform.h" -#include "gfxASurface.h" -#include "gfxImageSurface.h" -#include "gfxUtils.h" -#include "gfxContext.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_canvas_##name - - -ANPCanvas* -anp_canvas_newCanvas(const ANPBitmap* bitmap) -{ - PRUint32 stride; - gfxASurface::gfxImageFormat format; - - if (bitmap->format == kRGBA_8888_ANPBitmapFormat) { - stride = bitmap->width * 4; - format = gfxImageSurface::ImageFormatARGB32; - } - else if (bitmap->format == kRGB_565_ANPBitmapFormat) { - stride = bitmap->width * 2; - format = gfxImageSurface::ImageFormatRGB16_565; - } - else { - LOG("%s -- Unknown format", __PRETTY_FUNCTION__); - return nsnull; - } - - gfxImageSurface* pluginSurface = new gfxImageSurface(static_cast(bitmap->baseAddr), - gfxIntSize(bitmap->width, bitmap->height), - stride, - format); - if (pluginSurface->CairoStatus()) { - LOG("%s -- %d x %d FAILED to create gfxImageSurface", __PRETTY_FUNCTION__, bitmap->width, bitmap->height); - return nsnull; - } - - gfxContext *pluginContext = new gfxContext(pluginSurface); - NS_ADDREF(pluginContext); - return (ANPCanvas*) pluginContext; -} - -void -anp_canvas_deleteCanvas(ANPCanvas* canvas) -{ - if (!canvas) - return; - gfxContext *ctx = (gfxContext*)canvas; - NS_RELEASE( ctx ); -} - -void -anp_canvas_save(ANPCanvas* canvas) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Save(); -} - -void -anp_canvas_restore(ANPCanvas* canvas) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Restore(); -} - -void -anp_canvas_translate(ANPCanvas* canvas, float tx, float ty) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Translate(gfxPoint(tx,ty)); -} - -void -anp_canvas_scale(ANPCanvas* canvas, float sx, float sy) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Scale(sx, sy); -} - -void -anp_canvas_rotate(ANPCanvas* canvas, float degrees) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Rotate(degrees); -} - -void -anp_canvas_skew(ANPCanvas* canvas, float kx, float ky) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_concat(ANPCanvas* canvas, const ANPMatrix*) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_clipRect(ANPCanvas* canvas, const ANPRectF* r) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->Clip(gfxRect(r->left, - r->top, - r->right - r->left, - r->bottom - r->top)); -} - -void -anp_canvas_clipPath(ANPCanvas* canvas, const ANPPath*) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_getTotalMatrix(ANPCanvas* canvas, ANPMatrix*) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -bool -anp_canvas_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* bounds, bool aa) -{ - if (!canvas) - return false; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); - return false; -} - -bool -anp_canvas_getDeviceClipBounds(ANPCanvas* canvas, ANPRectI* bounds) -{ - if (!canvas) - return false; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); - return false; -} - -void -anp_canvas_drawColor(ANPCanvas* canvas, ANPColor c) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->SetDeviceColor(gfxRGBA(c, gfxRGBA::PACKED_ARGB)); - LOG("returning from %s", __PRETTY_FUNCTION__); -} - -void -anp_canvas_drawPaint(ANPCanvas* canvas, const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s", " ************** NOT IMPLEMENTED!!!"); -} - -void -anp_canvas_drawLine(ANPCanvas* canvas, float x0, float y0, float x1, float y1, - const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - ctx->NewPath(); - ctx->SetColor(((ANPPaintPrivate*)paint)->color); - ctx->Line(gfxPoint(x0, y0), gfxPoint(x1, y1)); - ctx->Fill(); -} - -void -anp_canvas_drawRect(ANPCanvas* canvas, const ANPRectF* r, const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - - ctx->NewPath(); - ctx->SetColor(((ANPPaintPrivate*)paint)->color); - ctx->Rectangle(gfxRect(r->left, - r->top, - r->right - r->left, - r->bottom - r->top)); - ctx->Fill(); -} - -void -anp_canvas_drawOval(ANPCanvas* canvas, const ANPRectF* r, const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - - ctx->NewPath(); - ctx->SetColor(((ANPPaintPrivate*)paint)->color); - - float sizeX = (r->right - r->left); - float sizeY = (r->bottom - r->top); - - ctx->Ellipse(gfxPoint(r->left + ( sizeX / 2), r->top + ( sizeY / 2)), - gfxSize(sizeX, sizeY)); - ctx->Fill(); -} - -void -anp_canvas_drawPath(ANPCanvas* canvas, const ANPPath*, const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_drawText(ANPCanvas* canvas, const void* text, uint32_t byteLength, - float x, float y, const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_drawPosText(ANPCanvas* canvas, const void* text, uint32_t byteLength, - const float xy[], const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_drawBitmap(ANPCanvas* canvas, const ANPBitmap*, float x, float y, - const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void -anp_canvas_drawBitmapRect(ANPCanvas* canvas, const ANPBitmap*, - const ANPRectI* src, const ANPRectF* dst, - const ANPPaint* paint) -{ - if (!canvas) - return; - - gfxContext* ctx = (gfxContext*)canvas; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -void InitCanvasInterface(ANPCanvasInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, newCanvas); - ASSIGN(i, deleteCanvas); - ASSIGN(i, save); - ASSIGN(i, restore); - ASSIGN(i, translate); - ASSIGN(i, scale); - ASSIGN(i, rotate); - ASSIGN(i, skew); - ASSIGN(i, concat); - ASSIGN(i, clipRect); - ASSIGN(i, clipPath); - ASSIGN(i, getTotalMatrix); - ASSIGN(i, getLocalClipBounds); - ASSIGN(i, getDeviceClipBounds); - ASSIGN(i, drawColor); - ASSIGN(i, drawPaint); - ASSIGN(i, drawLine); - ASSIGN(i, drawRect); - ASSIGN(i, drawOval); - ASSIGN(i, drawPath); - ASSIGN(i, drawText); - ASSIGN(i, drawPosText); - ASSIGN(i, drawBitmap); - ASSIGN(i, drawBitmapRect); -} diff --git a/dom/plugins/base/android/ANPPaint.cpp b/dom/plugins/base/android/ANPPaint.cpp deleted file mode 100644 index 9dc5d4c271b4..000000000000 --- a/dom/plugins/base/android/ANPPaint.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android NPAPI support code - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Doug Turner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include "ANPBase.h" - -#define LOG(args...) -//__android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_paint_##name - -ANPPaint* -anp_paint_newPaint() -{ - LOG("%s", __PRETTY_FUNCTION__); - - ANPPaintPrivate* p = (ANPPaintPrivate*) calloc(1, sizeof(ANPPaintPrivate)); - return (ANPPaint*) p; -} - -void -anp_paint_deletePaint(ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - free((void*)p); -} - - -ANPPaintFlags -anp_paint_getFlags(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kAntiAlias_ANPPaintFlag; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->flags; -} - -void -anp_paint_setFlags(ANPPaint* paint, ANPPaintFlags flags) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->flags = flags; -} - - -ANPColor -anp_paint_getColor(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return ANP_MAKE_COLOR(1, 255, 255, 255); - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->color; -} - -void -anp_paint_setColor(ANPPaint* paint, ANPColor color) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->color = color; -} - - -ANPPaintStyle -anp_paint_getStyle(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kFill_ANPPaintStyle; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->style; -} - -void -anp_paint_setStyle(ANPPaint* paint, ANPPaintStyle style) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->style = style; -} - -float -anp_paint_getStrokeWidth(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->strokeWidth; -} - -float -anp_paint_getStrokeMiter(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->strokeMiter; -} - -ANPPaintCap -anp_paint_getStrokeCap(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kButt_ANPPaintCap; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->paintCap; -} - -ANPPaintJoin -anp_paint_getStrokeJoin(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kMiter_ANPPaintJoin; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->paintJoin; -} - -void -anp_paint_setStrokeWidth(ANPPaint* paint, float width) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->strokeWidth = width; -} - -void -anp_paint_setStrokeMiter(ANPPaint* paint, float miter) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->strokeMiter = miter; -} - -void -anp_paint_setStrokeCap(ANPPaint* paint, ANPPaintCap cap) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->paintCap = cap; -} - -void -anp_paint_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->paintJoin = join; -} - - -ANPTextEncoding -anp_paint_getTextEncoding(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kUTF8_ANPTextEncoding; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->textEncoding; -} - -ANPPaintAlign -anp_paint_getTextAlign(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return kLeft_ANPPaintAlign; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->paintAlign; -} - -float -anp_paint_getTextSize(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->textSize; -} - -float -anp_paint_getTextScaleX(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->textScaleX; -} - -float -anp_paint_getTextSkewX(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return p->textSkewX; -} - -void -anp_paint_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->textEncoding = encoding; -} - -void -anp_paint_setTextAlign(ANPPaint* paint, ANPPaintAlign align) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->paintAlign = align; -} - -void -anp_paint_setTextSize(ANPPaint* paint, float size) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->textSize = size; -} - -void -anp_paint_setTextScaleX(ANPPaint* paint, float scale) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->textScaleX = scale; -} - -void -anp_paint_setTextSkewX(ANPPaint* paint, float skew) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - p->textSkewX = skew; -} - - -/** Return the typeface in paint, or null if there is none. This does not - modify the owner count of the returned typeface. -*/ -ANPTypeface* -anp_paint_getTypeface(const ANPPaint* paint) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return NULL; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - return &p->typeface; -} - - -/** Set the paint's typeface. If the paint already had a non-null typeface, - its owner count is decremented. If the new typeface is non-null, its - owner count is incremented. -*/ -void -anp_paint_setTypeface(ANPPaint* paint, ANPTypeface* typeface) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - LOG("%s is not impl.", __PRETTY_FUNCTION__); -} - -/** Return the width of the text. If bounds is not null, return the bounds - of the text in that rectangle. -*/ -float -anp_paint_measureText(ANPPaint* paint, const void* text, uint32_t byteLength, - ANPRectF* bounds) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - - LOG("%s is not impl.", __PRETTY_FUNCTION__); - return 0; -} - - -/** Return the number of unichars specifed by the text. - If widths is not null, returns the array of advance widths for each - unichar. - If bounds is not null, returns the array of bounds for each unichar. -*/ -int -anp_paint_getTextWidths(ANPPaint* paint, const void* text, uint32_t byteLength, - float widths[], ANPRectF bounds[]) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - LOG("%s is not impl.", __PRETTY_FUNCTION__); - return 0; -} - - -/** Return in metrics the spacing values for text, respecting the paint's - typeface and pointsize, and return the spacing between lines - (descent - ascent + leading). If metrics is NULL, it will be ignored. -*/ -float -anp_paint_getFontMetrics(ANPPaint* paint, ANPFontMetrics* metrics) -{ - LOG("%s", __PRETTY_FUNCTION__); - if (!paint) - return 0; - - ANPPaintPrivate* p = (ANPPaintPrivate*) paint; - LOG("%s is not impl.", __PRETTY_FUNCTION__); - return 0; -} - - -void InitPaintInterface(ANPPaintInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, newPaint); - ASSIGN(i, deletePaint); - ASSIGN(i, getFlags); - ASSIGN(i, setFlags); - ASSIGN(i, getColor); - ASSIGN(i, setColor); - ASSIGN(i, getStyle); - ASSIGN(i, setStyle); - ASSIGN(i, getStrokeWidth); - ASSIGN(i, getStrokeMiter); - ASSIGN(i, getStrokeCap); - ASSIGN(i, getStrokeJoin); - ASSIGN(i, setStrokeWidth); - ASSIGN(i, setStrokeMiter); - ASSIGN(i, setStrokeCap); - ASSIGN(i, setStrokeJoin); - ASSIGN(i, getTextEncoding); - ASSIGN(i, getTextAlign); - ASSIGN(i, getTextSize); - ASSIGN(i, getTextScaleX); - ASSIGN(i, getTextSkewX); - ASSIGN(i, setTextEncoding); - ASSIGN(i, setTextAlign); - ASSIGN(i, setTextSize); - ASSIGN(i, setTextScaleX); - ASSIGN(i, setTextSkewX); - ASSIGN(i, getTypeface); - ASSIGN(i, setTypeface); - ASSIGN(i, measureText); - ASSIGN(i, getTextWidths); - ASSIGN(i, getFontMetrics); -} diff --git a/dom/plugins/base/android/ANPPath.cpp b/dom/plugins/base/android/ANPPath.cpp deleted file mode 100644 index ca1dbe9d48d0..000000000000 --- a/dom/plugins/base/android/ANPPath.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android NPAPI support code - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Doug Turner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "assert.h" -#include "ANPBase.h" -#include - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_path_##name - - -// maybe this should store a list of actions (lineTo, -// moveTo), and when canvas_drawPath() we apply all of these -// actions to the gfxContext. - -ANPPath* -anp_path_newPath() -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); - return 0; -} - - -void -anp_path_deletePath(ANPPath* p) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - -void -anp_path_copy(ANPPath* dst, const ANPPath* src) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - -bool -anp_path_equal(const ANPPath* path0, const ANPPath* path1) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); - return false; -} - - -void -anp_path_reset(ANPPath* p) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - -bool -anp_path_isEmpty(const ANPPath* p) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); - return false; -} - - -void -anp_path_getBounds(const ANPPath* p, ANPRectF* bounds) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); - - bounds->left = 0; - bounds->top = 0; - bounds->right = 1000; - bounds->left = 1000; -} - - -void -anp_path_moveTo(ANPPath* p, float x, float y) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - -void -anp_path_lineTo(ANPPath* p, float x, float y) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - -void -anp_path_quadTo(ANPPath* p, float x0, float y0, float x1, float y1) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - -void -anp_path_cubicTo(ANPPath* p, float x0, float y0, float x1, float y1, - float x2, float y2) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - -void -anp_path_close(ANPPath* p) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - -void -anp_path_offset(ANPPath* src, float dx, float dy, ANPPath* dst) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - -void -anp_path_transform(ANPPath* src, const ANPMatrix*, ANPPath* dst) -{ - LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__); -} - - - -void InitPathInterface(ANPPathInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, newPath); - ASSIGN(i, deletePath); - ASSIGN(i, copy); - ASSIGN(i, equal); - ASSIGN(i, reset); - ASSIGN(i, isEmpty); - ASSIGN(i, getBounds); - ASSIGN(i, moveTo); - ASSIGN(i, lineTo); - ASSIGN(i, quadTo); - ASSIGN(i, cubicTo); - ASSIGN(i, close); - ASSIGN(i, offset); - ASSIGN(i, transform); -} diff --git a/dom/plugins/base/android/ANPSurface.cpp b/dom/plugins/base/android/ANPSurface.cpp index f4984b1d286e..53ddd50c4d18 100644 --- a/dom/plugins/base/android/ANPSurface.cpp +++ b/dom/plugins/base/android/ANPSurface.cpp @@ -40,8 +40,6 @@ #include "ANPBase.h" #include #include "AndroidBridge.h" -#include "gfxImageSurface.h" -#include "gfxContext.h" #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) #define ASSIGN(obj, name) (obj)->name = anp_surface_##name diff --git a/dom/plugins/base/android/ANPTypeface.cpp b/dom/plugins/base/android/ANPTypeface.cpp deleted file mode 100644 index 15ed094d2449..000000000000 --- a/dom/plugins/base/android/ANPTypeface.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android NPAPI support code - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Doug Turner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "assert.h" -#include "ANPBase.h" -#include -#include "gfxAndroidPlatform.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_typeface_##name - -ANPTypeface* -anp_typeface_createFromName(const char name[], ANPTypefaceStyle aStyle) -{ - LOG("%s - %s\n", __PRETTY_FUNCTION__, name); - - gfxFontStyle style (aStyle == kItalic_ANPTypefaceStyle ? FONT_STYLE_ITALIC : - FONT_STYLE_NORMAL, - NS_FONT_STRETCH_NORMAL, - aStyle == kBold_ANPTypefaceStyle ? 700 : 400, - 16.0, - NS_NewPermanentAtom(NS_LITERAL_STRING("en")), - 0.0, - false, false, - NS_LITERAL_STRING(""), - NS_LITERAL_STRING("")); - ANPTypeface* tf = new ANPTypeface; - gfxAndroidPlatform * p = (gfxAndroidPlatform*)gfxPlatform::GetPlatform(); - nsRefPtr font = gfxFT2Font::GetOrMakeFont(NS_ConvertASCIItoUTF16(name), &style); - font.forget(&tf->mFont); - if (tf->mFont) { - ++tf->mRefCnt; - } - return tf; -} - -ANPTypeface* -anp_typeface_createFromTypeface(const ANPTypeface* family, - ANPTypefaceStyle) -{ - NOT_IMPLEMENTED(); - return 0; -} - -int32_t -anp_typeface_getRefCount(const ANPTypeface*) -{ - NOT_IMPLEMENTED(); - return 0; -} - -void -anp_typeface_ref(ANPTypeface* tf) -{ - LOG("%s\n", __PRETTY_FUNCTION__); - if (tf->mFont) - ++tf->mRefCnt; - -} - -void -anp_typeface_unref(ANPTypeface* tf) -{ - LOG("%s\n", __PRETTY_FUNCTION__); - if (tf->mFont) - --tf->mRefCnt; - if (tf->mRefCnt.get() == 0) { - NS_IF_RELEASE(tf->mFont); - } -} - -ANPTypefaceStyle -anp_typeface_getStyle(const ANPTypeface* ft) -{ - LOG("%s\n", __PRETTY_FUNCTION__); - return kBold_ANPTypefaceStyle; -} - -int32_t -anp_typeface_getFontPath(const ANPTypeface*, char path[], int32_t length, - int32_t* index) -{ - NOT_IMPLEMENTED(); - return 0; -} - -static const char* gFontDir; -#define FONT_DIR_SUFFIX "/fonts/" - -const char* -anp_typeface_getFontDirectoryPath() -{ - LOG("%s\n", __PRETTY_FUNCTION__); - if (NULL == gFontDir) { - const char* root = getenv("ANDROID_ROOT"); - size_t len = strlen(root); - char* storage = (char*)malloc(len + sizeof(FONT_DIR_SUFFIX)); - if (NULL == storage) { - return NULL; - } - memcpy(storage, root, len); - memcpy(storage + len, FONT_DIR_SUFFIX, sizeof(FONT_DIR_SUFFIX)); - // save this assignment for last, so that if multiple threads call us - // (which should never happen), we never return an incomplete global. - // At worst, we would allocate storage for the path twice. - gFontDir = storage; - } - - return 0; -} - -void InitTypeFaceInterface(ANPTypefaceInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, createFromName); - ASSIGN(i, createFromTypeface); - ASSIGN(i, getRefCount); - ASSIGN(i, ref); - ASSIGN(i, unref); - ASSIGN(i, getStyle); - ASSIGN(i, getFontPath); - ASSIGN(i, getFontDirectoryPath); -} - diff --git a/dom/plugins/base/android/Makefile.in b/dom/plugins/base/android/Makefile.in index 42e5067f3aed..d1f6aee1d619 100644 --- a/dom/plugins/base/android/Makefile.in +++ b/dom/plugins/base/android/Makefile.in @@ -57,17 +57,13 @@ EXPORTS = \ $(NULL) CPPSRCS += ANPAudio.cpp \ - ANPCanvas.cpp \ ANPEvent.cpp \ ANPMatrix.cpp \ - ANPPath.cpp \ ANPSystem.cpp \ ANPWindow.cpp \ ANPBitmap.cpp \ ANPLog.cpp \ - ANPPaint.cpp \ ANPSurface.cpp \ - ANPTypeface.cpp \ $(NULL) LOCAL_INCLUDES += \ diff --git a/other-licenses/skia-npapi/ANPCanvas.cpp b/other-licenses/skia-npapi/ANPCanvas.cpp new file mode 100644 index 000000000000..ce7eb56a47a9 --- /dev/null +++ b/other-licenses/skia-npapi/ANPCanvas.cpp @@ -0,0 +1,194 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "SkANP.h" + +static ANPCanvas* anp_newCanvas(const ANPBitmap* bitmap) { + SkBitmap bm; + return new ANPCanvas(*SkANP::SetBitmap(&bm, *bitmap)); +} + +static void anp_deleteCanvas(ANPCanvas* canvas) { + delete canvas; +} + +static void anp_save(ANPCanvas* canvas) { + canvas->skcanvas->save(); +} + +static void anp_restore(ANPCanvas* canvas) { + canvas->skcanvas->restore(); +} + +static void anp_translate(ANPCanvas* canvas, float tx, float ty) { + canvas->skcanvas->translate(SkFloatToScalar(tx), SkFloatToScalar(ty)); +} + +static void anp_scale(ANPCanvas* canvas, float sx, float sy) { + canvas->skcanvas->scale(SkFloatToScalar(sx), SkFloatToScalar(sy)); +} + +static void anp_rotate(ANPCanvas* canvas, float degrees) { + canvas->skcanvas->rotate(SkFloatToScalar(degrees)); +} + +static void anp_skew(ANPCanvas* canvas, float kx, float ky) { + canvas->skcanvas->skew(SkFloatToScalar(kx), SkFloatToScalar(ky)); +} + +static void anp_clipRect(ANPCanvas* canvas, const ANPRectF* rect) { + SkRect r; + canvas->skcanvas->clipRect(*SkANP::SetRect(&r, *rect)); +} + +static void anp_clipPath(ANPCanvas* canvas, const ANPPath* path) { + canvas->skcanvas->clipPath(*path); +} +static void anp_concat(ANPCanvas* canvas, const ANPMatrix* matrix) { + canvas->skcanvas->concat(*matrix); +} + +static void anp_getTotalMatrix(ANPCanvas* canvas, ANPMatrix* matrix) { + const SkMatrix& src = canvas->skcanvas->getTotalMatrix(); + *matrix = *reinterpret_cast(&src); +} + +static bool anp_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* r, + bool antialias) { + SkRect bounds; + if (canvas->skcanvas->getClipBounds(&bounds, + antialias ? SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) { + SkANP::SetRect(r, bounds); + return true; + } + return false; +} + +static bool anp_getDeviceClipBounds(ANPCanvas* canvas, ANPRectI* r) { + const SkRegion& clip = canvas->skcanvas->getTotalClip(); + if (!clip.isEmpty()) { + SkANP::SetRect(r, clip.getBounds()); + return true; + } + return false; +} + +static void anp_drawColor(ANPCanvas* canvas, ANPColor color) { + canvas->skcanvas->drawColor(color); +} + +static void anp_drawPaint(ANPCanvas* canvas, const ANPPaint* paint) { + canvas->skcanvas->drawPaint(*paint); +} + +static void anp_drawLine(ANPCanvas* canvas, float x0, float y0, + float x1, float y1, const ANPPaint* paint) { + canvas->skcanvas->drawLine(SkFloatToScalar(x0), SkFloatToScalar(y0), + SkFloatToScalar(x1), SkFloatToScalar(y1), *paint); +} + +static void anp_drawRect(ANPCanvas* canvas, const ANPRectF* rect, + const ANPPaint* paint) { + SkRect r; + canvas->skcanvas->drawRect(*SkANP::SetRect(&r, *rect), *paint); +} + +static void anp_drawOval(ANPCanvas* canvas, const ANPRectF* rect, + const ANPPaint* paint) { + SkRect r; + canvas->skcanvas->drawOval(*SkANP::SetRect(&r, *rect), *paint); +} + +static void anp_drawPath(ANPCanvas* canvas, const ANPPath* path, + const ANPPaint* paint) { + canvas->skcanvas->drawPath(*path, *paint); +} + +static void anp_drawText(ANPCanvas* canvas, const void* text, uint32_t length, + float x, float y, const ANPPaint* paint) { + canvas->skcanvas->drawText(text, length, + SkFloatToScalar(x), SkFloatToScalar(y), + *paint); +} + +static void anp_drawPosText(ANPCanvas* canvas, const void* text, + uint32_t byteLength, const float xy[], const ANPPaint* paint) { + canvas->skcanvas->drawPosText(text, byteLength, + reinterpret_cast(xy), *paint); +} + +static void anp_drawBitmap(ANPCanvas* canvas, const ANPBitmap* bitmap, + float x, float y, const ANPPaint* paint) { + SkBitmap bm; + canvas->skcanvas->drawBitmap(*SkANP::SetBitmap(&bm, *bitmap), + SkFloatToScalar(x), SkFloatToScalar(y), + paint); +} + +static void anp_drawBitmapRect(ANPCanvas* canvas, const ANPBitmap* bitmap, + const ANPRectI* src, const ANPRectF* dst, + const ANPPaint* paint) { + SkBitmap bm; + SkRect dstR; + SkIRect srcR, *srcPtr = NULL; + + if (src) { + srcPtr = SkANP::SetRect(&srcR, *src); + } + canvas->skcanvas->drawBitmapRect(*SkANP::SetBitmap(&bm, *bitmap), srcPtr, + *SkANP::SetRect(&dstR, *dst), paint); +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void InitCanvasInterface(ANPCanvasInterfaceV0* i) { + ASSIGN(i, newCanvas); + ASSIGN(i, deleteCanvas); + ASSIGN(i, save); + ASSIGN(i, restore); + ASSIGN(i, translate); + ASSIGN(i, scale); + ASSIGN(i, rotate); + ASSIGN(i, skew); + ASSIGN(i, clipRect); + ASSIGN(i, clipPath); + ASSIGN(i, concat); + ASSIGN(i, getTotalMatrix); + ASSIGN(i, getLocalClipBounds); + ASSIGN(i, getDeviceClipBounds); + ASSIGN(i, drawColor); + ASSIGN(i, drawPaint); + ASSIGN(i, drawLine); + ASSIGN(i, drawRect); + ASSIGN(i, drawOval); + ASSIGN(i, drawPath); + ASSIGN(i, drawText); + ASSIGN(i, drawPosText); + ASSIGN(i, drawBitmap); + ASSIGN(i, drawBitmapRect); +} diff --git a/other-licenses/skia-npapi/ANPPaint.cpp b/other-licenses/skia-npapi/ANPPaint.cpp new file mode 100644 index 000000000000..aa9d2fbd680e --- /dev/null +++ b/other-licenses/skia-npapi/ANPPaint.cpp @@ -0,0 +1,209 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "SkANP.h" +#include "SkTypeface.h" + +static ANPPaint* anp_newPaint() { + return new ANPPaint; +} + +static void anp_deletePaint(ANPPaint* paint) { + delete paint; +} + +static ANPPaintFlags anp_getFlags(const ANPPaint* paint) { + return paint->getFlags(); +} + +static void anp_setFlags(ANPPaint* paint, ANPPaintFlags flags) { + paint->setFlags(flags); +} + +static ANPColor anp_getColor(const ANPPaint* paint) { + return paint->getColor(); +} + +static void anp_setColor(ANPPaint* paint, ANPColor color) { + paint->setColor(color); +} + +static ANPPaintStyle anp_getStyle(const ANPPaint* paint) { + return paint->getStyle(); +} + +static void anp_setStyle(ANPPaint* paint, ANPPaintStyle style) { + paint->setStyle(static_cast(style)); +} + +static float anp_getStrokeWidth(const ANPPaint* paint) { + return SkScalarToFloat(paint->getStrokeWidth()); +} + +static float anp_getStrokeMiter(const ANPPaint* paint) { + return SkScalarToFloat(paint->getStrokeMiter()); +} + +static ANPPaintCap anp_getStrokeCap(const ANPPaint* paint) { + return paint->getStrokeCap(); +} + +static ANPPaintJoin anp_getStrokeJoin(const ANPPaint* paint) { + return paint->getStrokeJoin(); +} + +static void anp_setStrokeWidth(ANPPaint* paint, float width) { + paint->setStrokeWidth(SkFloatToScalar(width)); +} + +static void anp_setStrokeMiter(ANPPaint* paint, float miter) { + paint->setStrokeMiter(SkFloatToScalar(miter)); +} + +static void anp_setStrokeCap(ANPPaint* paint, ANPPaintCap cap) { + paint->setStrokeCap(static_cast(cap)); +} + +static void anp_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join) { + paint->setStrokeJoin(static_cast(join)); +} + +static ANPTextEncoding anp_getTextEncoding(const ANPPaint* paint) { + return paint->getTextEncoding(); +} + +static ANPPaintAlign anp_getTextAlign(const ANPPaint* paint) { + return paint->getTextAlign(); +} + +static float anp_getTextSize(const ANPPaint* paint) { + return SkScalarToFloat(paint->getTextSize()); +} + +static float anp_getTextScaleX(const ANPPaint* paint) { + return SkScalarToFloat(paint->getTextScaleX()); +} + +static float anp_getTextSkewX(const ANPPaint* paint) { + return SkScalarToFloat(paint->getTextSkewX()); +} + +static ANPTypeface* anp_getTypeface(const ANPPaint* paint) { + return reinterpret_cast(paint->getTypeface()); +} + +static void anp_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding) { + paint->setTextEncoding(static_cast(encoding)); +} + +static void anp_setTextAlign(ANPPaint* paint, ANPPaintAlign align) { + paint->setTextAlign(static_cast(align)); +} + +static void anp_setTextSize(ANPPaint* paint, float textSize) { + paint->setTextSize(SkFloatToScalar(textSize)); +} + +static void anp_setTextScaleX(ANPPaint* paint, float scaleX) { + paint->setTextScaleX(SkFloatToScalar(scaleX)); +} + +static void anp_setTextSkewX(ANPPaint* paint, float skewX) { + paint->setTextSkewX(SkFloatToScalar(skewX)); +} + +static void anp_setTypeface(ANPPaint* paint, ANPTypeface* tf) { + paint->setTypeface(tf); +} + +static float anp_measureText(ANPPaint* paint, const void* text, + uint32_t byteLength, ANPRectF* bounds) { + SkScalar w = paint->measureText(text, byteLength, + reinterpret_cast(bounds)); + return SkScalarToFloat(w); +} + +/** Return the number of unichars specifed by the text. + If widths is not null, returns the array of advance widths for each + unichar. + If bounds is not null, returns the array of bounds for each unichar. + */ +static int anp_getTextWidths(ANPPaint* paint, const void* text, + uint32_t byteLength, float widths[], ANPRectF bounds[]) { + return paint->getTextWidths(text, byteLength, widths, + reinterpret_cast(bounds)); +} + +static float anp_getFontMetrics(ANPPaint* paint, ANPFontMetrics* metrics) { + SkPaint::FontMetrics fm; + SkScalar spacing = paint->getFontMetrics(&fm); + if (metrics) { + metrics->fTop = SkScalarToFloat(fm.fTop); + metrics->fAscent = SkScalarToFloat(fm.fAscent); + metrics->fDescent = SkScalarToFloat(fm.fDescent); + metrics->fBottom = SkScalarToFloat(fm.fBottom); + metrics->fLeading = SkScalarToFloat(fm.fLeading); + } + return SkScalarToFloat(spacing); +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void InitPaintInterface(ANPPaintInterfaceV0* i) { + ASSIGN(i, newPaint); + ASSIGN(i, deletePaint); + ASSIGN(i, getFlags); + ASSIGN(i, setFlags); + ASSIGN(i, getColor); + ASSIGN(i, setColor); + ASSIGN(i, getStyle); + ASSIGN(i, setStyle); + ASSIGN(i, getStrokeWidth); + ASSIGN(i, getStrokeMiter); + ASSIGN(i, getStrokeCap); + ASSIGN(i, getStrokeJoin); + ASSIGN(i, setStrokeWidth); + ASSIGN(i, setStrokeMiter); + ASSIGN(i, setStrokeCap); + ASSIGN(i, setStrokeJoin); + ASSIGN(i, getTextEncoding); + ASSIGN(i, getTextAlign); + ASSIGN(i, getTextSize); + ASSIGN(i, getTextScaleX); + ASSIGN(i, getTextSkewX); + ASSIGN(i, getTypeface); + ASSIGN(i, setTextEncoding); + ASSIGN(i, setTextAlign); + ASSIGN(i, setTextSize); + ASSIGN(i, setTextScaleX); + ASSIGN(i, setTextSkewX); + ASSIGN(i, setTypeface); + ASSIGN(i, measureText); + ASSIGN(i, getTextWidths); + ASSIGN(i, getFontMetrics); +} diff --git a/other-licenses/skia-npapi/ANPPath.cpp b/other-licenses/skia-npapi/ANPPath.cpp new file mode 100644 index 000000000000..7deb871efec3 --- /dev/null +++ b/other-licenses/skia-npapi/ANPPath.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "SkANP.h" + +static ANPPath* anp_newPath() { + return new ANPPath; +} + +static void anp_deletePath(ANPPath* path) { + delete path; +} + +static void anp_copy(ANPPath* dst, const ANPPath* src) { + *dst = *src; +} + +static bool anp_equal(const ANPPath* p0, const ANPPath* p1) { + return *p0 == *p1; +} + +static void anp_reset(ANPPath* path) { + path->reset(); +} + +static bool anp_isEmpty(const ANPPath* path) { + return path->isEmpty(); +} + +static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) { + SkANP::SetRect(bounds, path->getBounds()); +} + +static void anp_moveTo(ANPPath* path, float x, float y) { + path->moveTo(SkFloatToScalar(x), SkFloatToScalar(y)); +} + +static void anp_lineTo(ANPPath* path, float x, float y) { + path->lineTo(SkFloatToScalar(x), SkFloatToScalar(y)); +} + +static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) { + path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0), + SkFloatToScalar(x1), SkFloatToScalar(y1)); +} + +static void anp_cubicTo(ANPPath* path, float x0, float y0, + float x1, float y1, float x2, float y2) { + path->cubicTo(SkFloatToScalar(x0), SkFloatToScalar(y0), + SkFloatToScalar(x1), SkFloatToScalar(y1), + SkFloatToScalar(x2), SkFloatToScalar(y2)); +} + +static void anp_close(ANPPath* path) { + path->close(); +} + +static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) { + path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst); +} + +static void anp_transform(ANPPath* src, const ANPMatrix* matrix, + ANPPath* dst) { + src->transform(*matrix, dst); +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void InitPathInterface(ANPPathInterfaceV0* i) { + ASSIGN(i, newPath); + ASSIGN(i, deletePath); + ASSIGN(i, copy); + ASSIGN(i, equal); + ASSIGN(i, reset); + ASSIGN(i, isEmpty); + ASSIGN(i, getBounds); + ASSIGN(i, moveTo); + ASSIGN(i, lineTo); + ASSIGN(i, quadTo); + ASSIGN(i, cubicTo); + ASSIGN(i, close); + ASSIGN(i, offset); + ASSIGN(i, transform); +} diff --git a/other-licenses/skia-npapi/ANPTypeface.cpp b/other-licenses/skia-npapi/ANPTypeface.cpp new file mode 100644 index 000000000000..e095de9829fb --- /dev/null +++ b/other-licenses/skia-npapi/ANPTypeface.cpp @@ -0,0 +1,101 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "SkANP.h" +#include "SkFontHost.h" + +static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) { + SkTypeface* tf = SkTypeface::CreateFromName(name, + static_cast(s)); + return reinterpret_cast(tf); +} + +static ANPTypeface* anp_createFromTypeface(const ANPTypeface* family, + ANPTypefaceStyle s) { + SkTypeface* tf = SkTypeface::CreateFromTypeface(family, + static_cast(s)); + return reinterpret_cast(tf); +} + +static int32_t anp_getRefCount(const ANPTypeface* tf) { + return tf ? tf->getRefCnt() : 0; +} + +static void anp_ref(ANPTypeface* tf) { + SkSafeRef(tf); +} + +static void anp_unref(ANPTypeface* tf) { + SkSafeUnref(tf); +} + +static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) { + SkTypeface::Style s = tf ? tf->style() : SkTypeface::kNormal; + return static_cast(s); +} + +static int32_t anp_getFontPath(const ANPTypeface* tf, char fileName[], + int32_t length, int32_t* index) { + size_t size = SkFontHost::GetFileName(SkTypeface::UniqueID(tf), fileName, + length, index); + return static_cast(size); +} + +static const char* gFontDir; +#define FONT_DIR_SUFFIX "/fonts/" + +static const char* anp_getFontDirectoryPath() { + if (NULL == gFontDir) { + const char* root = getenv("ANDROID_ROOT"); + size_t len = strlen(root); + char* storage = (char*)malloc(len + sizeof(FONT_DIR_SUFFIX)); + if (NULL == storage) { + return NULL; + } + memcpy(storage, root, len); + memcpy(storage + len, FONT_DIR_SUFFIX, sizeof(FONT_DIR_SUFFIX)); + // save this assignment for last, so that if multiple threads call us + // (which should never happen), we never return an incomplete global. + // At worst, we would allocate storage for the path twice. + gFontDir = storage; + } + return gFontDir; +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void InitTypeFaceInterface(ANPTypefaceInterfaceV0* i) { + ASSIGN(i, createFromName); + ASSIGN(i, createFromTypeface); + ASSIGN(i, getRefCount); + ASSIGN(i, ref); + ASSIGN(i, unref); + ASSIGN(i, getStyle); + ASSIGN(i, getFontPath); + ASSIGN(i, getFontDirectoryPath); +} diff --git a/other-licenses/skia-npapi/Makefile.in b/other-licenses/skia-npapi/Makefile.in new file mode 100644 index 000000000000..c067c426077e --- /dev/null +++ b/other-licenses/skia-npapi/Makefile.in @@ -0,0 +1,72 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (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.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Mozilla browser. +# +# The Initial Developer of the Original Code is +# Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# James Willcox +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = skia_npapi +LIBRARY_NAME = skia_npapi +LIBXUL_LIBRARY = 1 +EXPORT_LIBRARY = 1 + +DEFINES += \ + -DSK_BUILD_FOR_ANDROID_NDK \ + $(NULL) + +LOCAL_INCLUDES += \ + -I$(topsrcdir)/dom/plugins/base \ + -I$(topsrcdir)/dom/plugins/base/android \ + -I$(topsrcdir)/gfx/skia/include/core \ + -I$(topsrcdir)/gfx/skia/include/config \ + $(NULL) + + +CPPSRCS = \ + SkANP.cpp \ + ANPCanvas.cpp \ + ANPPaint.cpp \ + ANPPath.cpp \ + ANPTypeface.cpp \ + $(NULL) + +EXPORTS = SkANP.h + +include $(topsrcdir)/config/rules.mk diff --git a/other-licenses/skia-npapi/SkANP.cpp b/other-licenses/skia-npapi/SkANP.cpp new file mode 100644 index 000000000000..ca02de9ffe53 --- /dev/null +++ b/other-licenses/skia-npapi/SkANP.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "SkANP.h" + +SkRect* SkANP::SetRect(SkRect* dst, const ANPRectF& src) { + dst->set(SkFloatToScalar(src.left), + SkFloatToScalar(src.top), + SkFloatToScalar(src.right), + SkFloatToScalar(src.bottom)); + return dst; +} + +SkIRect* SkANP::SetRect(SkIRect* dst, const ANPRectI& src) { + dst->set(src.left, src.top, src.right, src.bottom); + return dst; +} + +ANPRectI* SkANP::SetRect(ANPRectI* dst, const SkIRect& src) { + dst->left = src.fLeft; + dst->top = src.fTop; + dst->right = src.fRight; + dst->bottom = src.fBottom; + return dst; +} + +ANPRectF* SkANP::SetRect(ANPRectF* dst, const SkRect& src) { + dst->left = SkScalarToFloat(src.fLeft); + dst->top = SkScalarToFloat(src.fTop); + dst->right = SkScalarToFloat(src.fRight); + dst->bottom = SkScalarToFloat(src.fBottom); + return dst; +} + +SkBitmap* SkANP::SetBitmap(SkBitmap* dst, const ANPBitmap& src) { + SkBitmap::Config config = SkBitmap::kNo_Config; + + switch (src.format) { + case kRGBA_8888_ANPBitmapFormat: + config = SkBitmap::kARGB_8888_Config; + break; + case kRGB_565_ANPBitmapFormat: + config = SkBitmap::kRGB_565_Config; + break; + default: + break; + } + + dst->setConfig(config, src.width, src.height, src.rowBytes); + dst->setPixels(src.baseAddr); + return dst; +} + +bool SkANP::SetBitmap(ANPBitmap* dst, const SkBitmap& src) { + if (!(dst->baseAddr = src.getPixels())) { + SkDebugf("SkANP::SetBitmap - getPixels() returned null\n"); + return false; + } + + switch (src.config()) { + case SkBitmap::kARGB_8888_Config: + dst->format = kRGBA_8888_ANPBitmapFormat; + break; + case SkBitmap::kRGB_565_Config: + dst->format = kRGB_565_ANPBitmapFormat; + break; + default: + SkDebugf("SkANP::SetBitmap - unsupported src.config %d\n", src.config()); + return false; + } + + dst->width = src.width(); + dst->height = src.height(); + dst->rowBytes = src.rowBytes(); + return true; +} + +void SkANP::InitEvent(ANPEvent* event, ANPEventType et) { + event->inSize = sizeof(ANPEvent); + event->eventType = et; +} diff --git a/other-licenses/skia-npapi/SkANP.h b/other-licenses/skia-npapi/SkANP.h new file mode 100644 index 000000000000..5c2a936501b8 --- /dev/null +++ b/other-licenses/skia-npapi/SkANP.h @@ -0,0 +1,79 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SkANP_DEFINED +#define SkANP_DEFINED + +#include "android_npapi.h" +#include "SkCanvas.h" +#include "SkMatrix.h" +#include "SkPaint.h" +#include "SkPath.h" +#include "SkTypeface.h" + +struct ANPMatrix : SkMatrix { +}; + +struct ANPPath : SkPath { +}; + +struct ANPPaint : SkPaint { +}; + +struct ANPTypeface : SkTypeface { +}; + +struct ANPCanvas { + SkCanvas* skcanvas; + + // draw into the specified bitmap + explicit ANPCanvas(const SkBitmap& bm) { + skcanvas = new SkCanvas(bm); + } + + // redirect all drawing to the specific SkCanvas + explicit ANPCanvas(SkCanvas* other) { + skcanvas = other; + skcanvas->ref(); + } + + ~ANPCanvas() { + skcanvas->unref(); + } +}; + +class SkANP { +public: + static SkRect* SetRect(SkRect* dst, const ANPRectF& src); + static SkIRect* SetRect(SkIRect* dst, const ANPRectI& src); + static ANPRectI* SetRect(ANPRectI* dst, const SkIRect& src); + static ANPRectF* SetRect(ANPRectF* dst, const SkRect& src); + static SkBitmap* SetBitmap(SkBitmap* dst, const ANPBitmap& src); + static bool SetBitmap(ANPBitmap* dst, const SkBitmap& src); + + static void InitEvent(ANPEvent* event, ANPEventType et); +}; + +#endif diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 14fa06380da2..6cbf75dc5a7b 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -268,7 +268,7 @@ endif STATIC_LIBS += thebes ycbcr ifeq ($(MOZ_WIDGET_TOOLKIT),android) -STATIC_LIBS += profiler +STATIC_LIBS += profiler skia_npapi endif STATIC_LIBS += angle