Revert "Add ninePatch support to Canvas.h"

This reverts commit edca320a2b42011f98c308fdf25fc0494c6a5454.

Change-Id: I30ee93cfc1cac391ce152f03e9e13a1ad24dc91b
diff --git a/core/java/android/view/DisplayListCanvas.java b/core/java/android/view/DisplayListCanvas.java
index 948cec7..05fa45f 100644
--- a/core/java/android/view/DisplayListCanvas.java
+++ b/core/java/android/view/DisplayListCanvas.java
@@ -221,6 +221,29 @@
     // Drawing
     ///////////////////////////////////////////////////////////////////////////
 
+    // TODO: move to Canvas.java
+    @Override
+    public void drawPatch(NinePatch patch, Rect dst, Paint paint) {
+        Bitmap bitmap = patch.getBitmap();
+        throwIfCannotDraw(bitmap);
+        final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
+        nDrawPatch(mNativeCanvasWrapper, bitmap, patch.mNativeChunk,
+                dst.left, dst.top, dst.right, dst.bottom, nativePaint);
+    }
+
+    // TODO: move to Canvas.java
+    @Override
+    public void drawPatch(NinePatch patch, RectF dst, Paint paint) {
+        Bitmap bitmap = patch.getBitmap();
+        throwIfCannotDraw(bitmap);
+        final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
+        nDrawPatch(mNativeCanvasWrapper, bitmap, patch.mNativeChunk,
+                dst.left, dst.top, dst.right, dst.bottom, nativePaint);
+    }
+
+    private static native void nDrawPatch(long renderer, Bitmap bitmap, long chunk,
+            float left, float top, float right, float bottom, long paint);
+
     public void drawCircle(CanvasProperty<Float> cx, CanvasProperty<Float> cy,
             CanvasProperty<Float> radius, CanvasProperty<Paint> paint) {
         nDrawCircle(mNativeCanvasWrapper, cx.getNativeContainer(), cy.getNativeContainer(),
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 75da27e..b7eda4a 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -114,6 +114,7 @@
     android/graphics/MinikinUtils.cpp \
     android/graphics/Movie.cpp \
     android/graphics/NinePatch.cpp \
+    android/graphics/NinePatchImpl.cpp \
     android/graphics/NinePatchPeeker.cpp \
     android/graphics/Paint.cpp \
     android/graphics/PaintImpl.cpp \
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 1c28262..e69f64e 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -29,11 +29,12 @@
 #include "SkRegion.h"
 #include "GraphicsJNI.h"
 
-#include "utils/NinePatch.h"
-
 #include "JNIHelp.h"
 #include "core_jni_helpers.h"
 
+extern void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, const SkBitmap& bitmap,
+        const android::Res_png_9patch& chunk, const SkPaint* paint, SkRegion** outRegion);
+
 using namespace android;
 
 /**
@@ -87,6 +88,72 @@
         }
     }
 
+    static void draw(JNIEnv* env, SkCanvas* canvas, SkRect& bounds, const SkBitmap& bitmap,
+            Res_png_9patch* chunk, const SkPaint* paint, jint destDensity, jint srcDensity) {
+        if (destDensity == srcDensity || destDensity == 0 || srcDensity == 0) {
+            ALOGV("Drawing unscaled 9-patch: (%g,%g)-(%g,%g)",
+                    SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop),
+                    SkScalarToFloat(bounds.fRight), SkScalarToFloat(bounds.fBottom));
+            NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL);
+        } else {
+            canvas->save();
+
+            SkScalar scale = destDensity / (float)srcDensity;
+            canvas->translate(bounds.fLeft, bounds.fTop);
+            canvas->scale(scale, scale);
+
+            bounds.fRight = (bounds.fRight-bounds.fLeft) / scale;
+            bounds.fBottom = (bounds.fBottom-bounds.fTop) / scale;
+            bounds.fLeft = bounds.fTop = 0;
+
+            ALOGV("Drawing scaled 9-patch: (%g,%g)-(%g,%g) srcDensity=%d destDensity=%d",
+                    SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop),
+                    SkScalarToFloat(bounds.fRight), SkScalarToFloat(bounds.fBottom),
+                    srcDensity, destDensity);
+
+            NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL);
+
+            canvas->restore();
+        }
+    }
+
+    static void drawF(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRectF,
+            jobject jbitmap, jlong chunkHandle, jlong paintHandle,
+            jint destDensity, jint srcDensity) {
+        SkCanvas* canvas       = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas();
+        Res_png_9patch* chunk  = reinterpret_cast<Res_png_9patch*>(chunkHandle);
+        const Paint* paint     = reinterpret_cast<Paint*>(paintHandle);
+        SkASSERT(canvas);
+        SkASSERT(boundsRectF);
+        SkASSERT(chunk);
+        // paint is optional
+
+        SkBitmap bitmap;
+        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+        SkRect bounds;
+        GraphicsJNI::jrectf_to_rect(env, boundsRectF, &bounds);
+
+        draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity);
+    }
+
+    static void drawI(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRect,
+            jobject jbitmap, jlong chunkHandle, jlong paintHandle,
+            jint destDensity, jint srcDensity) {
+        SkCanvas* canvas       = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas();
+        Res_png_9patch* chunk  = reinterpret_cast<Res_png_9patch*>(chunkHandle);
+        const Paint* paint     = reinterpret_cast<Paint*>(paintHandle);
+        SkASSERT(canvas);
+        SkASSERT(boundsRect);
+        SkASSERT(chunk);
+        // paint is optional
+
+        SkBitmap bitmap;
+        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+        SkRect bounds;
+        GraphicsJNI::jrect_to_rect(env, boundsRect, &bounds);
+        draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity);
+    }
+
     static jlong getTransparentRegion(JNIEnv* env, jobject, jobject jbitmap,
             jlong chunkHandle, jobject boundsRect) {
         Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
@@ -99,7 +166,7 @@
         GraphicsJNI::jrect_to_rect(env, boundsRect, &bounds);
 
         SkRegion* region = NULL;
-        NinePatch::Draw(NULL, bounds, bitmap, *chunk, NULL, &region);
+        NinePatch_Draw(NULL, bounds, bitmap, *chunk, NULL, &region);
 
         return reinterpret_cast<jlong>(region);
     }
@@ -113,6 +180,10 @@
     { "validateNinePatchChunk", "([B)J",
             (void*) SkNinePatchGlue::validateNinePatchChunk },
     { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize },
+    { "nativeDraw", "(JLandroid/graphics/RectF;Landroid/graphics/Bitmap;JJII)V",
+            (void*) SkNinePatchGlue::drawF },
+    { "nativeDraw", "(JLandroid/graphics/Rect;Landroid/graphics/Bitmap;JJII)V",
+            (void*) SkNinePatchGlue::drawI },
     { "nativeGetTransparentRegion", "(Landroid/graphics/Bitmap;JLandroid/graphics/Rect;)J",
             (void*) SkNinePatchGlue::getTransparentRegion }
 };
diff --git a/libs/hwui/utils/NinePatchImpl.cpp b/core/jni/android/graphics/NinePatchImpl.cpp
similarity index 97%
rename from libs/hwui/utils/NinePatchImpl.cpp
rename to core/jni/android/graphics/NinePatchImpl.cpp
index f51f5df..978c4a5 100644
--- a/libs/hwui/utils/NinePatchImpl.cpp
+++ b/core/jni/android/graphics/NinePatchImpl.cpp
@@ -15,7 +15,11 @@
 ** limitations under the License.
 */
 
-#include "utils/NinePatch.h"
+#define LOG_TAG "NinePatch"
+#define LOG_NDEBUG 1
+
+#include <androidfw/ResourceTypes.h>
+#include <utils/Log.h>
 
 #include "SkBitmap.h"
 #include "SkCanvas.h"
@@ -26,8 +30,6 @@
 
 #include <utils/Log.h>
 
-namespace android {
-
 static const bool kUseTrace = true;
 static bool gTrace = false;
 
@@ -95,9 +97,9 @@
     return srcSpace * stretchySpaceRemaining / numStrechyPixelsRemaining;
 }
 
-void NinePatch::Draw(SkCanvas* canvas, const SkRect& bounds,
-                     const SkBitmap& bitmap, const Res_png_9patch& chunk,
-                     const SkPaint* paint, SkRegion** outRegion) {
+void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
+                       const SkBitmap& bitmap, const android::Res_png_9patch& chunk,
+                       const SkPaint* paint, SkRegion** outRegion) {
     if (canvas && canvas->quickReject(bounds)) {
         return;
     }
@@ -322,5 +324,3 @@
         dstRightsHaveBeenCached = true;
     }
 }
-
-} // namespace android
diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp
index 97e6bb9..43825ad 100644
--- a/core/jni/android_graphics_Canvas.cpp
+++ b/core/jni/android_graphics_Canvas.cpp
@@ -18,8 +18,6 @@
 #include "GraphicsJNI.h"
 #include "core_jni_helpers.h"
 
-#include <androidfw/ResourceTypes.h>
-
 #include <Canvas.h>
 #include "SkDrawFilter.h"
 #include "SkGraphics.h"
@@ -332,41 +330,6 @@
                                            indices, indexCount, *paint);
 }
 
-static void drawNinePatch(JNIEnv* env, jlong canvasHandle, jobject jbitmap, jlong chunkHandle,
-        jfloat left, jfloat top, jfloat right, jfloat bottom,
-        jlong paintHandle, jint dstDensity, jint srcDensity) {
-
-    Canvas* canvas = get_canvas(canvasHandle);
-    SkBitmap bitmap;
-    GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
-    const android::Res_png_9patch* chunk = reinterpret_cast<android::Res_png_9patch*>(chunkHandle);
-    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
-
-    if (CC_LIKELY(dstDensity == srcDensity || dstDensity == 0 || srcDensity == 0)) {
-        ALOGV("Drawing unscaled 9-patch: (%g,%g)-(%g,%g)", left, top, right, bottom);
-        canvas->drawNinePatch(bitmap, *chunk, left, top, right, bottom, paint);
-    } else {
-        canvas->save(SkCanvas::kMatrixClip_SaveFlag);
-
-        SkScalar scale = dstDensity / (float)srcDensity;
-        canvas->translate(left, top);
-        canvas->scale(scale, scale);
-
-        Paint filteredPaint;
-        if (paint) {
-            filteredPaint = *paint;
-        }
-        filteredPaint.setFilterQuality(kLow_SkFilterQuality);
-
-        ALOGV("Drawing scaled 9-patch: (0,0)-(%g,%g) srcDensity=%d destDensity=%d",
-                (right-left)/scale, (bottom-top)/scale, srcDensity, dstDensity);
-        canvas->drawNinePatch(bitmap, *chunk, 0, 0, (right-left)/scale, (bottom-top)/scale,
-                &filteredPaint);
-
-        canvas->restore();
-    }
-}
-
 static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jobject jbitmap,
                        jfloat left, jfloat top, jlong paintHandle, jint canvasDensity,
                        jint screenDensity, jint bitmapDensity) {
@@ -788,7 +751,6 @@
     {"native_drawArc","(JFFFFFFZJ)V", (void*) CanvasJNI::drawArc},
     {"native_drawPath","(JJJ)V", (void*) CanvasJNI::drawPath},
     {"nativeDrawVertices", "(JII[FI[FI[II[SIIJ)V", (void*)CanvasJNI::drawVertices},
-    {"native_drawNinePatch", "(JLandroid/graphics/Bitmap;JFFFFJII)V", (void*)CanvasJNI::drawNinePatch},
     {"native_drawBitmap","(JLandroid/graphics/Bitmap;FFJIII)V", (void*) CanvasJNI::drawBitmap},
     {"nativeDrawBitmapMatrix", "(JLandroid/graphics/Bitmap;JJ)V", (void*)CanvasJNI::drawBitmapMatrix},
     {"native_drawBitmap","(JLandroid/graphics/Bitmap;FFFFFFFFJII)V", (void*) CanvasJNI::drawBitmapRect},
diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp
index 3833325..2953db4 100644
--- a/core/jni/android_view_DisplayListCanvas.cpp
+++ b/core/jni/android_view_DisplayListCanvas.cpp
@@ -22,6 +22,8 @@
 
 #include <android_runtime/AndroidRuntime.h>
 
+#include <androidfw/ResourceTypes.h>
+
 #include <cutils/properties.h>
 
 #include <SkBitmap.h>
@@ -81,6 +83,17 @@
 // Drawing
 // ----------------------------------------------------------------------------
 
+static void android_view_DisplayListCanvas_drawPatch(JNIEnv* env, jobject clazz,
+        jlong rendererPtr, jobject jbitmap, jlong patchPtr,
+        float left, float top, float right, float bottom, jlong paintPtr) {
+    SkBitmap bitmap;
+    GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+    DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
+    Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(patchPtr);
+    Paint* paint = reinterpret_cast<Paint*>(paintPtr);
+    renderer->drawPatch(bitmap, patch, left, top, right, bottom, paint);
+}
+
 static void android_view_DisplayListCanvas_drawRoundRectProps(JNIEnv* env, jobject clazz,
         jlong rendererPtr, jlong leftPropPtr, jlong topPropPtr, jlong rightPropPtr,
         jlong bottomPropPtr, jlong rxPropPtr, jlong ryPropPtr, jlong paintPropPtr) {
@@ -183,6 +196,8 @@
 
     { "nCallDrawGLFunction", "(JJ)V",          (void*) android_view_DisplayListCanvas_callDrawGLFunction },
 
+    { "nDrawPatch",         "(JLandroid/graphics/Bitmap;JFFFFJ)V",     (void*) android_view_DisplayListCanvas_drawPatch },
+
     { "nDrawRoundRect",     "(JJJJJJJJ)V",     (void*) android_view_DisplayListCanvas_drawRoundRectProps },
     { "nDrawCircle",        "(JJJJJ)V",        (void*) android_view_DisplayListCanvas_drawCircleProps },
 
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index d0eb26d..7bcc7f9 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1281,10 +1281,7 @@
      * @hide
      */
     public void drawPatch(@NonNull NinePatch patch, @NonNull Rect dst, @Nullable Paint paint) {
-        final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
-        native_drawNinePatch(mNativeCanvasWrapper, patch.getBitmap(), patch.mNativeChunk,
-                dst.left, dst.top, dst.right, dst.bottom, nativePaint,
-                mDensity, patch.getDensity());
+        patch.drawSoftware(this, dst, paint);
     }
 
     /**
@@ -1297,10 +1294,7 @@
      * @hide
      */
     public void drawPatch(@NonNull NinePatch patch, @NonNull RectF dst, @Nullable Paint paint) {
-        final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
-        native_drawNinePatch(mNativeCanvasWrapper, patch.getBitmap(), patch.mNativeChunk,
-                dst.left, dst.top, dst.right, dst.bottom, nativePaint,
-                mDensity, patch.getDensity());
+        patch.drawSoftware(this, dst, paint);
     }
 
     /**
@@ -2068,9 +2062,6 @@
                                                long nativePaint);
     private static native void native_drawRegion(long nativeCanvas,
             long nativeRegion, long nativePaint);
-    private native void native_drawNinePatch(long nativeCanvas, Bitmap bitmap,
-            long ninePatch, float dstLeft, float dstTop, float dstRight, float dstBottom,
-            long nativePaintOrZero, int screenDensity, int bitmapDensity);
     private native void native_drawBitmap(long nativeCanvas, Bitmap bitmap,
                                                  float left, float top,
                                                  long nativePaintOrZero,
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index b9a1eda..21a212a 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -198,6 +198,16 @@
         canvas.drawPatch(this, location, paint);
     }
 
+    void drawSoftware(Canvas canvas, RectF location, Paint paint) {
+        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap, mNativeChunk,
+                paint != null ? paint.getNativeInstance() : 0, canvas.mDensity, mBitmap.mDensity);
+    }
+
+    void drawSoftware(Canvas canvas, Rect location, Paint paint) {
+        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap, mNativeChunk,
+                paint != null ? paint.getNativeInstance() : 0, canvas.mDensity, mBitmap.mDensity);
+    }
+
     /**
      * Return the underlying bitmap's density, as per
      * {@link Bitmap#getDensity() Bitmap.getDensity()}.
@@ -263,5 +273,9 @@
      */
     private static native long validateNinePatchChunk(byte[] chunk);
     private static native void nativeFinalize(long chunk);
+    private static native void nativeDraw(long canvas_instance, RectF loc, Bitmap bitmap_instance,
+            long c, long paint_instance_or_null, int destDensity, int srcDensity);
+    private static native void nativeDraw(long canvas_instance, Rect loc, Bitmap bitmap_instance,
+            long c, long paint_instance_or_null, int destDensity, int srcDensity);
     private static native long nativeGetTransparentRegion(Bitmap bitmap, long chunk, Rect location);
 }
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index b3b3479..e5bc664 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -23,7 +23,6 @@
     utils/Blur.cpp \
     utils/GLUtils.cpp \
     utils/LinearAllocator.cpp \
-    utils/NinePatchImpl.cpp \
     AmbientShadow.cpp \
     AnimationContext.cpp \
     Animator.cpp \
diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h
index 3c77b3d..a0b87f9 100644
--- a/libs/hwui/Canvas.h
+++ b/libs/hwui/Canvas.h
@@ -19,8 +19,6 @@
 
 #include <cutils/compiler.h>
 
-#include "utils/NinePatch.h"
-
 #include <SkBitmap.h>
 #include <SkCanvas.h>
 #include <SkMatrix.h>
@@ -146,9 +144,6 @@
             float dstRight, float dstBottom, const SkPaint* paint) = 0;
     virtual void drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshHeight,
             const float* vertices, const int* colors, const SkPaint* paint) = 0;
-    virtual void drawNinePatch(const SkBitmap& bitmap, const android::Res_png_9patch& chunk,
-            float dstLeft, float dstTop, float dstRight, float dstBottom,
-            const SkPaint* paint) = 0;
 
     // Text
     /**
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp
index a8dd71e..c48b070 100644
--- a/libs/hwui/DisplayListCanvas.cpp
+++ b/libs/hwui/DisplayListCanvas.cpp
@@ -320,14 +320,13 @@
            vertices, colors, paint));
 }
 
-void DisplayListCanvas::drawNinePatch(const SkBitmap& bitmap, const Res_png_9patch& patch,
-        float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint) {
+void DisplayListCanvas::drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
+        float left, float top, float right, float bottom, const SkPaint* paint) {
     const SkBitmap* bitmapPtr = refBitmap(bitmap);
-    const Res_png_9patch* patchPtr = refPatch(&patch);
+    patch = refPatch(patch);
     paint = refPaint(paint);
 
-    addDrawOp(new (alloc()) DrawPatchOp(bitmapPtr, patchPtr,
-            dstLeft, dstTop, dstRight, dstBottom, paint));
+    addDrawOp(new (alloc()) DrawPatchOp(bitmapPtr, patch, left, top, right, bottom, paint));
 }
 
 void DisplayListCanvas::drawColor(int color, SkXfermode::Mode mode) {
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index 3b61904..f3f5713 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -79,6 +79,10 @@
 // HWUI Canvas draw operations
 // ----------------------------------------------------------------------------
 
+    // TODO: move drawPatch() to Canvas.h
+    void drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
+            float left, float top, float right, float bottom, const SkPaint* paint);
+
     // Shapes
     void drawRoundRect(CanvasPropertyPrimitive* left, CanvasPropertyPrimitive* top,
                 CanvasPropertyPrimitive* right, CanvasPropertyPrimitive* bottom,
@@ -205,9 +209,6 @@
             float dstRight, float dstBottom, const SkPaint* paint) override;
     virtual void drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshHeight,
             const float* vertices, const int* colors, const SkPaint* paint) override;
-    virtual void drawNinePatch(const SkBitmap& bitmap, const android::Res_png_9patch& chunk,
-            float dstLeft, float dstTop, float dstRight, float dstBottom,
-            const SkPaint* paint) override;
 
     // Text
     virtual void drawText(const uint16_t* glyphs, const float* positions, int count,
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index f7dd83a..b2d1fec 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -124,9 +124,6 @@
             float dstRight, float dstBottom, const SkPaint* paint) override;
     virtual void drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshHeight,
             const float* vertices, const int* colors, const SkPaint* paint) override;
-    virtual void drawNinePatch(const SkBitmap& bitmap, const android::Res_png_9patch& chunk,
-            float dstLeft, float dstTop, float dstRight, float dstBottom,
-            const SkPaint* paint) override;
 
     virtual void drawText(const uint16_t* text, const float* positions, int count,
             const SkPaint& paint, float x, float y,
@@ -683,12 +680,6 @@
                          indexCount, tmpPaint);
 }
 
-void SkiaCanvas::drawNinePatch(const SkBitmap& bitmap, const Res_png_9patch& chunk,
-        float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint) {
-    SkRect bounds = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
-    NinePatch::Draw(mCanvas, bounds, bitmap, chunk, paint, nullptr);
-}
-
 // ----------------------------------------------------------------------------
 // Canvas draw operations: Text
 // ----------------------------------------------------------------------------
diff --git a/libs/hwui/utils/NinePatch.h b/libs/hwui/utils/NinePatch.h
deleted file mode 100644
index 323e563..0000000
--- a/libs/hwui/utils/NinePatch.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-**
-** Copyright 2015, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#ifndef ANDROID_GRAPHICS_NINEPATCH_H
-#define ANDROID_GRAPHICS_NINEPATCH_H
-
-#include <androidfw/ResourceTypes.h>
-#include <cutils/compiler.h>
-
-#include "SkCanvas.h"
-#include "SkRegion.h"
-
-namespace android {
-
-class ANDROID_API NinePatch {
-public:
-    static void Draw(SkCanvas* canvas, const SkRect& bounds, const SkBitmap& bitmap,
-            const Res_png_9patch& chunk, const SkPaint* paint, SkRegion** outRegion);
-};
-
-} // namespace android
-
-#endif // ANDROID_GRAPHICS_NINEPATCH_H