Bug 702614 - Use Skia to implement the Android canvas plugin APIs r=blassey
authorBrad Lassey <blassey@mozilla.com>
Tue, 15 Nov 2011 18:05:23 -0500
changeset 82648 e84fa7cf77ad8c4c8f2c9eeeaa80886b31bc7fb0
parent 82647 46de1ead375e5fa93206c9b3f402a98502490e95
child 82649 8d659ca1ae0e227d8da7e016a1f5b438bc05d3fe
push idunknown
push userunknown
push dateunknown
reviewersblassey
bugs702614
milestone11.0a1
Bug 702614 - Use Skia to implement the Android canvas plugin APIs r=blassey
Makefile.in
dom/plugins/base/Makefile.in
dom/plugins/base/android/ANPBase.h
dom/plugins/base/android/ANPCanvas.cpp
dom/plugins/base/android/ANPPaint.cpp
dom/plugins/base/android/ANPPath.cpp
dom/plugins/base/android/ANPSurface.cpp
dom/plugins/base/android/ANPTypeface.cpp
dom/plugins/base/android/Makefile.in
other-licenses/skia-npapi/ANPCanvas.cpp
other-licenses/skia-npapi/ANPPaint.cpp
other-licenses/skia-npapi/ANPPath.cpp
other-licenses/skia-npapi/ANPTypeface.cpp
other-licenses/skia-npapi/Makefile.in
other-licenses/skia-npapi/SkANP.cpp
other-licenses/skia-npapi/SkANP.h
toolkit/library/libxul-config.mk
--- a/Makefile.in
+++ b/Makefile.in
@@ -61,17 +61,17 @@ TIERS += base
 tier_base_dirs = \
 	config \
 	build \
 	probes \
 	$(NULL)
 
 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
 endif
 
 ifdef COMPILE_ENVIRONMENT
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
 endif
--- a/dom/plugins/base/Makefile.in
+++ b/dom/plugins/base/Makefile.in
@@ -128,17 +128,20 @@ else
 	CPPSRCS += nsPluginNativeWindow.cpp
 endif
 endif
 endif
 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)
 
 include $(topsrcdir)/dom/dom-config.mk
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
--- a/dom/plugins/base/android/ANPBase.h
+++ b/dom/plugins/base/android/ANPBase.h
@@ -34,59 +34,34 @@
  * 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 "android_npapi.h"
 #include <stdlib.h>
 #include "nsAutoPtr.h"
-#include "gfxFont.h"
 #include "nsISupportsImpl.h"
 
 #define NOT_IMPLEMENTED_FATAL() do {                                    \
     __android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins",              \
                         "%s not implemented %s, %d",                    \
                         __PRETTY_FUNCTION__, __FILE__, __LINE__);       \
     abort();                                                            \
   } while(0)
 
 #define NOT_IMPLEMENTED()                                               \
     __android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins",              \
                         "!!!!!!!!!!!!!!  %s not implemented %s, %d",    \
                         __PRETTY_FUNCTION__, __FILE__, __LINE__);       \
 
-class gfxFont;
-
 void InitAudioTrackInterface(ANPAudioTrackInterfaceV0 *i);
 void InitBitmapInterface(ANPBitmapInterfaceV0 *i);
 void InitCanvasInterface(ANPCanvasInterfaceV0 *i);
 void InitEventInterface(ANPEventInterfaceV0 *i);
 void InitLogInterface(ANPLogInterfaceV0 *i);
 void InitMatrixInterface(ANPMatrixInterfaceV0 *i);
 void InitPaintInterface(ANPPaintInterfaceV0 *i);
 void InitPathInterface(ANPPathInterfaceV0 *i);
 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;
--- a/dom/plugins/base/android/ANPSurface.cpp
+++ b/dom/plugins/base/android/ANPSurface.cpp
@@ -35,18 +35,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "assert.h"
 #include "ANPBase.h"
 #include <android/log.h>
 #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
 
 
 // used to cache JNI method and field IDs for Surface Objects
 static struct ANPSurfaceInterfaceJavaGlue {
   bool        initialized;
--- a/dom/plugins/base/android/Makefile.in
+++ b/dom/plugins/base/android/Makefile.in
@@ -52,27 +52,23 @@ EXPORT_LIBRARY = 1
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 EXPORTS = \
   android_npapi.h \
   $(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 += \
   -I$(topsrcdir)/dom/plugins/base \
   $(MOZ_CAIRO_CFLAGS) \
   $(NULL)
 
 DEFINES += -DMOZ_APP_NAME='"$(MOZ_APP_NAME)"'
rename from dom/plugins/base/android/ANPCanvas.cpp
rename to other-licenses/skia-npapi/ANPCanvas.cpp
--- a/dom/plugins/base/android/ANPCanvas.cpp
+++ b/other-licenses/skia-npapi/ANPCanvas.cpp
@@ -1,373 +1,194 @@
-/* -*- 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/
+/*
+ * Copyright 2008, The Android Open Source Project
  *
- * 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.
+ * 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.
  *
- * Contributor(s):
- *   Doug Turner <dougt@mozilla.com>
- *
- * 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 <android/log.h>
+ * 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.
+ */
 
-#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;
+// must include config.h first for webkit to fiddle with new/delete
+#include "SkANP.h"
 
-  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;
-  }
+static ANPCanvas* anp_newCanvas(const ANPBitmap* bitmap) {
+    SkBitmap bm;
+    return new ANPCanvas(*SkANP::SetBitmap(&bm, *bitmap));
+}
 
-  gfxImageSurface* pluginSurface = new gfxImageSurface(static_cast<unsigned char*>(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;
-  }
+static void anp_deleteCanvas(ANPCanvas* canvas) {
+    delete canvas;
+}
 
-  gfxContext *pluginContext = new gfxContext(pluginSurface);
-  NS_ADDREF(pluginContext);
-  return (ANPCanvas*) pluginContext;
+static void anp_save(ANPCanvas* canvas) {
+    canvas->skcanvas->save();
 }
 
-void
-anp_canvas_deleteCanvas(ANPCanvas* canvas)
-{
-  if (!canvas)
-    return;
-  gfxContext *ctx = (gfxContext*)canvas;
-  NS_RELEASE( ctx );
+static void anp_restore(ANPCanvas* canvas) {
+    canvas->skcanvas->restore();
 }
 
-void
-anp_canvas_save(ANPCanvas* canvas)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  ctx->Save();
+static void anp_translate(ANPCanvas* canvas, float tx, float ty) {
+    canvas->skcanvas->translate(SkFloatToScalar(tx), SkFloatToScalar(ty));
 }
 
-void
-anp_canvas_restore(ANPCanvas* canvas)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  ctx->Restore();
+static void anp_scale(ANPCanvas* canvas, float sx, float sy) {
+    canvas->skcanvas->scale(SkFloatToScalar(sx), SkFloatToScalar(sy));
 }
 
-void
-anp_canvas_translate(ANPCanvas* canvas, float tx, float ty)
-{
-  if (!canvas)
-    return;
+static void anp_rotate(ANPCanvas* canvas, float degrees) {
+    canvas->skcanvas->rotate(SkFloatToScalar(degrees));
+}
 
-  gfxContext* ctx = (gfxContext*)canvas;
-  ctx->Translate(gfxPoint(tx,ty));
+static void anp_skew(ANPCanvas* canvas, float kx, float ky) {
+    canvas->skcanvas->skew(SkFloatToScalar(kx), SkFloatToScalar(ky));
 }
 
-void
-anp_canvas_scale(ANPCanvas* canvas, float sx, float sy)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  ctx->Scale(sx, sy);
+static void anp_clipRect(ANPCanvas* canvas, const ANPRectF* rect) {
+    SkRect r;
+    canvas->skcanvas->clipRect(*SkANP::SetRect(&r, *rect));
 }
 
-void
-anp_canvas_rotate(ANPCanvas* canvas, float degrees)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  ctx->Rotate(degrees);
+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);
 }
 
-void
-anp_canvas_skew(ANPCanvas* canvas, float kx, float ky)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  LOG("%s is not impl.", __PRETTY_FUNCTION__);
+static void anp_getTotalMatrix(ANPCanvas* canvas, ANPMatrix* matrix) {
+    const SkMatrix& src = canvas->skcanvas->getTotalMatrix();
+    *matrix = *reinterpret_cast<const ANPMatrix*>(&src);
 }
 
-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));
+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;
 }
 
-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__);
+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;
 }
 
-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;
+static void anp_drawColor(ANPCanvas* canvas, ANPColor color) {
+    canvas->skcanvas->drawColor(color);
 }
 
-bool
-anp_canvas_getDeviceClipBounds(ANPCanvas* canvas, ANPRectI* bounds)
-{
-  if (!canvas)
-    return false;
+static void anp_drawPaint(ANPCanvas* canvas, const ANPPaint* paint) {
+    canvas->skcanvas->drawPaint(*paint);
+}
 
-  gfxContext* ctx = (gfxContext*)canvas;
-  LOG("%s is not impl.", __PRETTY_FUNCTION__);
-  return false;
+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);
 }
 
-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__);
+static void anp_drawRect(ANPCanvas* canvas, const ANPRectF* rect,
+                         const ANPPaint* paint) {
+    SkRect  r;
+    canvas->skcanvas->drawRect(*SkANP::SetRect(&r, *rect), *paint);
 }
 
-void
-anp_canvas_drawPaint(ANPCanvas* canvas, const ANPPaint* paint)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
-  LOG("%s", "                    **************   NOT IMPLEMENTED!!!");
+static void anp_drawOval(ANPCanvas* canvas, const ANPRectF* rect,
+                         const ANPPaint* paint) {
+    SkRect  r;
+    canvas->skcanvas->drawOval(*SkANP::SetRect(&r, *rect), *paint);
 }
 
-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();
+static void anp_drawPath(ANPCanvas* canvas, const ANPPath* path,
+                         const ANPPaint* paint) {
+    canvas->skcanvas->drawPath(*path, *paint);
 }
 
-void
-anp_canvas_drawRect(ANPCanvas* canvas, const ANPRectF* r, const ANPPaint* paint)
-{
-  if (!canvas)
-    return;
-
-  gfxContext* ctx = (gfxContext*)canvas;
+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);
+}
 
-  ctx->NewPath();
-  ctx->SetColor(((ANPPaintPrivate*)paint)->color);
-  ctx->Rectangle(gfxRect(r->left,
-                         r->top,
-                         r->right - r->left,
-                         r->bottom - r->top));
-  ctx->Fill();
+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<const SkPoint*>(xy), *paint);
 }
 
-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();
+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);
 }
 
-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__);
-}
+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;
 
-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__);
+    if (src) {
+        srcPtr = SkANP::SetRect(&srcR, *src);
+    }
+    canvas->skcanvas->drawBitmapRect(*SkANP::SetBitmap(&bm, *bitmap), srcPtr,
+                           *SkANP::SetRect(&dstR, *dst), paint);
 }
 
-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__);
-}
+#define ASSIGN(obj, name)   (obj)->name = anp_##name
 
-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);
+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);
 }
rename from dom/plugins/base/android/ANPPaint.cpp
rename to other-licenses/skia-npapi/ANPPaint.cpp
--- a/dom/plugins/base/android/ANPPaint.cpp
+++ b/other-licenses/skia-npapi/ANPPaint.cpp
@@ -1,454 +1,209 @@
-/* -*- 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/
+/*
+ * Copyright 2008, The Android Open Source Project
  *
- * 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 <dougt@mozilla.com>
+ * 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.
  *
- * 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 ***** */
+ * 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.
+ */
 
-#include <stdlib.h>
-#include <assert.h>
-#include <android/log.h>
-#include "ANPBase.h"
+// must include config.h first for webkit to fiddle with new/delete
+#include "SkANP.h"
+#include "SkTypeface.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;
+static ANPPaint* anp_newPaint() {
+    return new ANPPaint;
 }
 
-void
-anp_paint_deletePaint(ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  free((void*)p);
+static void anp_deletePaint(ANPPaint* paint) {
+    delete paint;
 }
 
-
-ANPPaintFlags
-anp_paint_getFlags(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kAntiAlias_ANPPaintFlag;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->flags;
+static ANPPaintFlags anp_getFlags(const ANPPaint* paint) {
+    return paint->getFlags();
 }
 
-void
-anp_paint_setFlags(ANPPaint* paint, ANPPaintFlags flags)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;  
-  p->flags = flags;
+static void anp_setFlags(ANPPaint* paint, ANPPaintFlags flags) {
+    paint->setFlags(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;
+static ANPColor anp_getColor(const ANPPaint* paint) {
+    return paint->getColor();
 }
 
-void
-anp_paint_setColor(ANPPaint* paint, ANPColor color)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->color = color;
+static void anp_setColor(ANPPaint* paint, ANPColor color) {
+    paint->setColor(color);
 }
 
-
-ANPPaintStyle
-anp_paint_getStyle(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kFill_ANPPaintStyle;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->style;
+static ANPPaintStyle anp_getStyle(const ANPPaint* paint) {
+    return paint->getStyle();
 }
 
-void
-anp_paint_setStyle(ANPPaint* paint, ANPPaintStyle style)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->style = style;
+static void anp_setStyle(ANPPaint* paint, ANPPaintStyle style) {
+    paint->setStyle(static_cast<SkPaint::Style>(style));
 }
 
-float
-anp_paint_getStrokeWidth(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return 0;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->strokeWidth;
+static float anp_getStrokeWidth(const ANPPaint* paint) {
+    return SkScalarToFloat(paint->getStrokeWidth());
 }
 
-float
-anp_paint_getStrokeMiter(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return 0;
+static float anp_getStrokeMiter(const ANPPaint* paint) {
+    return SkScalarToFloat(paint->getStrokeMiter());
+}
 
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->strokeMiter;
+static ANPPaintCap anp_getStrokeCap(const ANPPaint* paint) {
+    return paint->getStrokeCap();
 }
 
-ANPPaintCap
-anp_paint_getStrokeCap(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kButt_ANPPaintCap;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->paintCap;
+static ANPPaintJoin anp_getStrokeJoin(const ANPPaint* paint) {
+    return paint->getStrokeJoin();
 }
 
-ANPPaintJoin
-anp_paint_getStrokeJoin(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kMiter_ANPPaintJoin;
+static void anp_setStrokeWidth(ANPPaint* paint, float width) {
+    paint->setStrokeWidth(SkFloatToScalar(width));
+}
 
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->paintJoin;
+static void anp_setStrokeMiter(ANPPaint* paint, float miter) {
+    paint->setStrokeMiter(SkFloatToScalar(miter));
 }
 
-void
-anp_paint_setStrokeWidth(ANPPaint* paint, float width)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
+static void anp_setStrokeCap(ANPPaint* paint, ANPPaintCap cap) {
+    paint->setStrokeCap(static_cast<SkPaint::Cap>(cap));
+}
 
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->strokeWidth = width;
+static void anp_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join) {
+    paint->setStrokeJoin(static_cast<SkPaint::Join>(join));
 }
 
-void
-anp_paint_setStrokeMiter(ANPPaint* paint, float miter)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->strokeMiter = miter;
+static ANPTextEncoding anp_getTextEncoding(const ANPPaint* paint) {
+    return paint->getTextEncoding();
 }
 
-void
-anp_paint_setStrokeCap(ANPPaint* paint, ANPPaintCap cap)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->paintCap = cap;
+static ANPPaintAlign anp_getTextAlign(const ANPPaint* paint) {
+    return paint->getTextAlign();
 }
 
-void
-anp_paint_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->paintJoin = join;
+static float anp_getTextSize(const ANPPaint* paint) {
+    return SkScalarToFloat(paint->getTextSize());
 }
 
+static float anp_getTextScaleX(const ANPPaint* paint) {
+    return SkScalarToFloat(paint->getTextScaleX());
+}
 
-ANPTextEncoding
-anp_paint_getTextEncoding(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kUTF8_ANPTextEncoding;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->textEncoding;
+static float anp_getTextSkewX(const ANPPaint* paint) {
+    return SkScalarToFloat(paint->getTextSkewX());
 }
 
-ANPPaintAlign
-anp_paint_getTextAlign(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return kLeft_ANPPaintAlign;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->paintAlign;
+static ANPTypeface* anp_getTypeface(const ANPPaint* paint) {
+    return reinterpret_cast<ANPTypeface*>(paint->getTypeface());
 }
 
-float
-anp_paint_getTextSize(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return 0;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->textSize;
+static void anp_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding) {
+    paint->setTextEncoding(static_cast<SkPaint::TextEncoding>(encoding));
 }
 
-float
-anp_paint_getTextScaleX(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return 0;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->textScaleX;
+static void anp_setTextAlign(ANPPaint* paint, ANPPaintAlign align) {
+    paint->setTextAlign(static_cast<SkPaint::Align>(align));
 }
 
-float
-anp_paint_getTextSkewX(const ANPPaint* paint)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return 0;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  return p->textSkewX;
+static void anp_setTextSize(ANPPaint* paint, float textSize) {
+    paint->setTextSize(SkFloatToScalar(textSize));
 }
 
-void
-anp_paint_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->textEncoding = encoding;
+static void anp_setTextScaleX(ANPPaint* paint, float scaleX) {
+    paint->setTextScaleX(SkFloatToScalar(scaleX));
 }
 
-void
-anp_paint_setTextAlign(ANPPaint* paint, ANPPaintAlign align)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->paintAlign = align;  
+static void anp_setTextSkewX(ANPPaint* paint, float skewX) {
+    paint->setTextSkewX(SkFloatToScalar(skewX));
 }
 
-void
-anp_paint_setTextSize(ANPPaint* paint, float size)
-{
-  LOG("%s", __PRETTY_FUNCTION__);
-  if (!paint)
-    return;
-
-  ANPPaintPrivate* p = (ANPPaintPrivate*) paint;
-  p->textSize = size;
+static void anp_setTypeface(ANPPaint* paint, ANPTypeface* tf) {
+    paint->setTypeface(tf);
 }
 
-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;
+static float anp_measureText(ANPPaint* paint, const void* text,
+                             uint32_t byteLength, ANPRectF* bounds) {
+    SkScalar w = paint->measureText(text, byteLength,
+                                    reinterpret_cast<SkRect*>(bounds));
+    return SkScalarToFloat(w);
 }
 
-
-/** 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;
+/** 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<SkRect*>(bounds));
 }
 
-
-/** 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;
+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);
 }
 
-
-/** 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;
-}
+#define ASSIGN(obj, name)   (obj)->name = anp_##name
 
-
-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);
+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);
 }
rename from dom/plugins/base/android/ANPPath.cpp
rename to other-licenses/skia-npapi/ANPPath.cpp
--- a/dom/plugins/base/android/ANPPath.cpp
+++ b/other-licenses/skia-npapi/ANPPath.cpp
@@ -1,171 +1,109 @@
-/* -*- 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/
+/*
+ * Copyright 2009, The Android Open Source Project
  *
- * 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 <dougt@mozilla.com>
+ * 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.
  *
- * 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 ***** */
+ * 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.
+ */
 
-#include "assert.h"
-#include "ANPBase.h"
-#include <android/log.h>
-
-#define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
-#define ASSIGN(obj, name)   (obj)->name = anp_path_##name
-
+// must include config.h first for webkit to fiddle with new/delete
+#include "SkANP.h"
 
-// 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;
+static ANPPath* anp_newPath() {
+    return new ANPPath;
 }
 
-
-void
-anp_path_deletePath(ANPPath* p)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
+static void anp_deletePath(ANPPath* path) {
+    delete path;
 }
 
-
-void
-anp_path_copy(ANPPath* dst, const ANPPath* src)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
+static void anp_copy(ANPPath* dst, const ANPPath* src) {
+    *dst = *src;
 }
 
-
-bool
-anp_path_equal(const ANPPath* path0, const ANPPath* path1)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
-  return false;
+static bool anp_equal(const ANPPath* p0, const ANPPath* p1) {
+    return *p0 == *p1;
 }
 
+static void anp_reset(ANPPath* path) {
+    path->reset();
+}
 
-void
-anp_path_reset(ANPPath* p)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
+static bool anp_isEmpty(const ANPPath* path) {
+    return path->isEmpty();
 }
 
+static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) {
+    SkANP::SetRect(bounds, path->getBounds());
+}
 
-bool
-anp_path_isEmpty(const ANPPath* p)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
-  return false;
+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));
 }
 
-
-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;
+static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) {
+    path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0),
+                 SkFloatToScalar(x1), SkFloatToScalar(y1));
 }
 
-
-void
-anp_path_moveTo(ANPPath* p, float x, float y)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
+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));
 }
 
-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__);
+static void anp_close(ANPPath* path) {
+    path->close();
 }
 
-void
-anp_path_cubicTo(ANPPath* p, float x0, float y0, float x1, float y1,
-                      float x2, float y2)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
+static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) {
+    path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst);
 }
 
-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__);
+static void anp_transform(ANPPath* src, const ANPMatrix* matrix,
+                          ANPPath* dst) {
+    src->transform(*matrix, dst);
 }
 
+///////////////////////////////////////////////////////////////////////////////
 
-void
-anp_path_transform(ANPPath* src, const ANPMatrix*, ANPPath* dst)
-{
-  LOG("%s - NOT IMPL.", __PRETTY_FUNCTION__);
-}
-
-
+#define ASSIGN(obj, name)   (obj)->name = anp_##name
 
-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);
+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);
 }
rename from dom/plugins/base/android/ANPTypeface.cpp
rename to other-licenses/skia-npapi/ANPTypeface.cpp
--- a/dom/plugins/base/android/ANPTypeface.cpp
+++ b/other-licenses/skia-npapi/ANPTypeface.cpp
@@ -1,158 +1,101 @@
-/* -*- 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/
+/*
+ * Copyright 2008, The Android Open Source Project
  *
- * 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 <dougt@mozilla.com>
+ * 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.
  *
- * 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 <android/log.h>
-#include "gfxAndroidPlatform.h"
-
-#define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
-#define ASSIGN(obj, name)   (obj)->name = anp_typeface_##name
+ * 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.
+ */
 
-ANPTypeface*
-anp_typeface_createFromName(const char name[], ANPTypefaceStyle aStyle)
-{
-  LOG("%s - %s\n", __PRETTY_FUNCTION__, name);
+// must include config.h first for webkit to fiddle with new/delete
+#include "SkANP.h"
+#include "SkFontHost.h"
 
-  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<gfxFont> font = gfxFT2Font::GetOrMakeFont(NS_ConvertASCIItoUTF16(name), &style);
-  font.forget(&tf->mFont);
-  if (tf->mFont) {
-    ++tf->mRefCnt;
-  }
-  return tf;
+static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) {
+    SkTypeface* tf = SkTypeface::CreateFromName(name,
+                                        static_cast<SkTypeface::Style>(s));
+    return reinterpret_cast<ANPTypeface*>(tf);
 }
 
-ANPTypeface*
-anp_typeface_createFromTypeface(const ANPTypeface* family,
-                                ANPTypefaceStyle)
-{
-  NOT_IMPLEMENTED();
-  return 0;
+static ANPTypeface* anp_createFromTypeface(const ANPTypeface* family,
+                                           ANPTypefaceStyle s) {
+    SkTypeface* tf = SkTypeface::CreateFromTypeface(family,
+                                          static_cast<SkTypeface::Style>(s));
+    return reinterpret_cast<ANPTypeface*>(tf);
 }
 
-int32_t
-anp_typeface_getRefCount(const ANPTypeface*)
-{
-  NOT_IMPLEMENTED();
-  return 0;
+static int32_t anp_getRefCount(const ANPTypeface* tf) {
+    return tf ? tf->getRefCnt() : 0;
 }
 
-void
-anp_typeface_ref(ANPTypeface* tf)
-{
-  LOG("%s\n", __PRETTY_FUNCTION__);
-  if (tf->mFont)
-    ++tf->mRefCnt;
-
+static void anp_ref(ANPTypeface* tf) {
+    SkSafeRef(tf);
 }
 
-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);
-  }
+static void anp_unref(ANPTypeface* tf) {
+    SkSafeUnref(tf);
 }
 
-ANPTypefaceStyle
-anp_typeface_getStyle(const ANPTypeface* ft)
-{
-  LOG("%s\n", __PRETTY_FUNCTION__);
-  return kBold_ANPTypefaceStyle;
+static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) {
+    SkTypeface::Style s = tf ? tf->style() : SkTypeface::kNormal;
+    return static_cast<ANPTypefaceStyle>(s);
 }
 
-int32_t
-anp_typeface_getFontPath(const ANPTypeface*, char path[], int32_t length,
-                         int32_t* index)
-{
-  NOT_IMPLEMENTED();
-  return 0;
+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<int32_t>(size);
 }
 
 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;
+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;
     }
-    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;
+    return gFontDir;
 }
 
-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);
+///////////////////////////////////////////////////////////////////////////////
+
+#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);
 }
-
new file mode 100644
--- /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 <jwillcox@mozilla.com>
+#
+# 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
new file mode 100644
--- /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;
+}
new file mode 100644
--- /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
--- a/toolkit/library/libxul-config.mk
+++ b/toolkit/library/libxul-config.mk
@@ -263,17 +263,17 @@ endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
 COMPONENT_LIBS += widget_gonk
 endif
 
 STATIC_LIBS += thebes ycbcr
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
-STATIC_LIBS += profiler
+STATIC_LIBS += profiler skia_npapi
 endif
 
 STATIC_LIBS += angle
 
 ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += gkwidget
 endif
 ifeq (os2,$(MOZ_WIDGET_TOOLKIT))