summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-04-15 15:52:10 -0700
committerJohn Reck <jreck@google.com>2015-04-15 15:56:12 -0700
commit4bd981ec533a65e8dee053a0a709b484770b0a76 (patch)
treec9563c173961c03ed25fceec3aace0373212c31c
parent87ffb63d90fb6dd2689fe72dcb24fda9a6156220 (diff)
downloadframeworks_base-4bd981ec533a65e8dee053a0a709b484770b0a76.zip
frameworks_base-4bd981ec533a65e8dee053a0a709b484770b0a76.tar.gz
frameworks_base-4bd981ec533a65e8dee053a0a709b484770b0a76.tar.bz2
Remove Bitmap#getSkBitmap
Change-Id: Ifb9047b426122d3e5a445eb7a0eb3fce38dedf27
-rw-r--r--core/java/android/view/DisplayListCanvas.java6
-rw-r--r--core/jni/android/graphics/NinePatch.cpp45
-rw-r--r--core/jni/android_graphics_Canvas.cpp42
-rw-r--r--core/jni/android_view_DisplayListCanvas.cpp8
-rw-r--r--graphics/java/android/graphics/Bitmap.java5
-rw-r--r--graphics/java/android/graphics/Canvas.java18
-rw-r--r--graphics/java/android/graphics/NinePatch.java16
-rw-r--r--libs/hwui/DisplayListRenderer.cpp14
-rw-r--r--libs/hwui/DisplayListRenderer.h4
-rw-r--r--libs/hwui/ResourceCache.cpp6
-rw-r--r--libs/hwui/ResourceCache.h10
11 files changed, 88 insertions, 86 deletions
diff --git a/core/java/android/view/DisplayListCanvas.java b/core/java/android/view/DisplayListCanvas.java
index ec8f802..e9f2353 100644
--- a/core/java/android/view/DisplayListCanvas.java
+++ b/core/java/android/view/DisplayListCanvas.java
@@ -283,7 +283,7 @@ public class DisplayListCanvas extends Canvas {
Bitmap bitmap = patch.getBitmap();
throwIfCannotDraw(bitmap);
final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
- nDrawPatch(mNativeCanvasWrapper, bitmap.getSkBitmap(), patch.mNativeChunk,
+ nDrawPatch(mNativeCanvasWrapper, bitmap, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
}
@@ -293,11 +293,11 @@ public class DisplayListCanvas extends Canvas {
Bitmap bitmap = patch.getBitmap();
throwIfCannotDraw(bitmap);
final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
- nDrawPatch(mNativeCanvasWrapper, bitmap.getSkBitmap(), patch.mNativeChunk,
+ nDrawPatch(mNativeCanvasWrapper, bitmap, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
}
- private static native void nDrawPatch(long renderer, long bitmap, long chunk,
+ 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,
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 3f8bfe2..348b0ec 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -64,7 +64,7 @@ public:
return JNI_FALSE;
}
- static jlong validateNinePatchChunk(JNIEnv* env, jobject, jlong, jbyteArray obj) {
+ static jlong validateNinePatchChunk(JNIEnv* env, jobject, jbyteArray obj) {
size_t chunkSize = env->GetArrayLength(obj);
if (chunkSize < (int) (sizeof(Res_png_9patch))) {
jniThrowRuntimeException(env, "Array too small for chunk.");
@@ -88,13 +88,13 @@ public:
}
}
- static void draw(JNIEnv* env, SkCanvas* canvas, SkRect& bounds, const SkBitmap* bitmap,
+ 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);
+ NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL);
} else {
canvas->save();
@@ -111,25 +111,25 @@ public:
SkScalarToFloat(bounds.fRight), SkScalarToFloat(bounds.fBottom),
srcDensity, destDensity);
- NinePatch_Draw(canvas, bounds, *bitmap, *chunk, paint, NULL);
+ NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL);
canvas->restore();
}
}
static void drawF(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRectF,
- jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
+ jobject jbitmap, jlong chunkHandle, jlong paintHandle,
jint destDensity, jint srcDensity) {
SkCanvas* canvas = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas();
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
SkASSERT(canvas);
SkASSERT(boundsRectF);
- SkASSERT(bitmap);
SkASSERT(chunk);
// paint is optional
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
SkRect bounds;
GraphicsJNI::jrectf_to_rect(env, boundsRectF, &bounds);
@@ -137,36 +137,36 @@ public:
}
static void drawI(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRect,
- jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
+ jobject jbitmap, jlong chunkHandle, jlong paintHandle,
jint destDensity, jint srcDensity) {
SkCanvas* canvas = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas();
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
SkASSERT(canvas);
SkASSERT(boundsRect);
- SkASSERT(bitmap);
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, jlong bitmapHandle,
+ static jlong getTransparentRegion(JNIEnv* env, jobject, jobject jbitmap,
jlong chunkHandle, jobject boundsRect) {
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle);
- SkASSERT(bitmap);
SkASSERT(chunk);
SkASSERT(boundsRect);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
SkRect bounds;
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);
}
@@ -176,13 +176,16 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gNinePatchMethods[] = {
- { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk },
- { "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk },
- { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize },
- { "nativeDraw", "(JLandroid/graphics/RectF;JJJII)V", (void*) SkNinePatchGlue::drawF },
- { "nativeDraw", "(JLandroid/graphics/Rect;JJJII)V", (void*) SkNinePatchGlue::drawI },
- { "nativeGetTransparentRegion", "(JJLandroid/graphics/Rect;)J",
- (void*) SkNinePatchGlue::getTransparentRegion }
+ { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk },
+ { "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 }
};
int register_android_graphics_NinePatch(JNIEnv* env) {
diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp
index 50a1069..9b5fb3a 100644
--- a/core/jni/android_graphics_Canvas.cpp
+++ b/core/jni/android_graphics_Canvas.cpp
@@ -318,11 +318,12 @@ static void drawVertices(JNIEnv* env, jobject, jlong canvasHandle,
indices, indexCount, *paint);
}
-static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jobject jbitmap,
jfloat left, jfloat top, jlong paintHandle, jint canvasDensity,
jint screenDensity, jint bitmapDensity) {
Canvas* canvas = get_canvas(canvasHandle);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
if (canvasDensity == bitmapDensity || canvasDensity == 0 || bitmapDensity == 0) {
@@ -332,9 +333,9 @@ static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong b
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, left, top, &filteredPaint);
+ canvas->drawBitmap(bitmap, left, top, &filteredPaint);
} else {
- canvas->drawBitmap(*bitmap, left, top, paint);
+ canvas->drawBitmap(bitmap, left, top, paint);
}
} else {
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
@@ -348,37 +349,39 @@ static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong b
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint);
+ canvas->drawBitmap(bitmap, 0, 0, &filteredPaint);
canvas->restore();
}
}
-static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
jlong matrixHandle, jlong paintHandle) {
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
- get_canvas(canvasHandle)->drawBitmap(*bitmap, *matrix, paint);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+ get_canvas(canvasHandle)->drawBitmap(bitmap, *matrix, paint);
}
-static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
float srcLeft, float srcTop, float srcRight, float srcBottom,
float dstLeft, float dstTop, float dstRight, float dstBottom,
jlong paintHandle, jint screenDensity, jint bitmapDensity) {
Canvas* canvas = get_canvas(canvasHandle);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
if (screenDensity != 0 && screenDensity != bitmapDensity) {
Paint filteredPaint;
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
+ canvas->drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, &filteredPaint);
} else {
- canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
+ canvas->drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, paint);
}
}
@@ -406,16 +409,17 @@ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle,
get_canvas(canvasHandle)->drawBitmap(bitmap, x, y, paint);
}
-static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
jint meshWidth, jint meshHeight, jfloatArray jverts,
jint vertIndex, jintArray jcolors, jint colorIndex, jlong paintHandle) {
const int ptCount = (meshWidth + 1) * (meshHeight + 1);
AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
- get_canvas(canvasHandle)->drawBitmapMesh(*bitmap, meshWidth, meshHeight,
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+ get_canvas(canvasHandle)->drawBitmapMesh(bitmap, meshWidth, meshHeight,
vertA.ptr(), colorA.ptr(), paint);
}
@@ -700,11 +704,11 @@ static JNINativeMethod gMethods[] = {
{"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_drawBitmap","(JJFFJIII)V", (void*) CanvasJNI::drawBitmap},
- {"nativeDrawBitmapMatrix", "(JJJJ)V", (void*)CanvasJNI::drawBitmapMatrix},
- {"native_drawBitmap","(JJFFFFFFFFJII)V", (void*) CanvasJNI::drawBitmapRect},
+ {"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},
{"native_drawBitmap", "(J[IIIFFIIZJ)V", (void*)CanvasJNI::drawBitmapArray},
- {"nativeDrawBitmapMesh", "(JJII[FI[IIJ)V", (void*)CanvasJNI::drawBitmapMesh},
+ {"nativeDrawBitmapMesh", "(JLandroid/graphics/Bitmap;II[FI[IIJ)V", (void*)CanvasJNI::drawBitmapMesh},
{"native_drawText","(J[CIIFFIJJ)V", (void*) CanvasJNI::drawTextChars},
{"native_drawText","(JLjava/lang/String;IIFFIJJ)V", (void*) CanvasJNI::drawTextString},
{"native_drawTextRun","(J[CIIIIFFZJJ)V", (void*) CanvasJNI::drawTextRunChars},
diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp
index f2e6c4b..f42c89c 100644
--- a/core/jni/android_view_DisplayListCanvas.cpp
+++ b/core/jni/android_view_DisplayListCanvas.cpp
@@ -133,10 +133,10 @@ static jint android_view_DisplayListCanvas_getMaxTextureHeight(JNIEnv* env, jobj
// ----------------------------------------------------------------------------
static void android_view_DisplayListCanvas_drawPatch(JNIEnv* env, jobject clazz,
- jlong rendererPtr, jlong bitmapPtr, jlong patchPtr,
+ jlong rendererPtr, jobject jbitmap, jlong patchPtr,
float left, float top, float right, float bottom, jlong paintPtr) {
- SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapPtr);
-
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr);
Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(patchPtr);
Paint* paint = reinterpret_cast<Paint*>(paintPtr);
@@ -276,7 +276,7 @@ static JNINativeMethod gMethods[] = {
{ "nCallDrawGLFunction", "(JJ)V", (void*) android_view_DisplayListCanvas_callDrawGLFunction },
- { "nDrawPatch", "(JJJFFFFJ)V", (void*) android_view_DisplayListCanvas_drawPatch },
+ { "nDrawPatch", "(JLandroid/graphics/Bitmap;JFFFFJ)V", (void*) android_view_DisplayListCanvas_drawPatch },
{ "nDrawRects", "(JJJ)V", (void*) android_view_DisplayListCanvas_drawRegionAsRects },
{ "nDrawRoundRect", "(JJJJJJJJ)V", (void*) android_view_DisplayListCanvas_drawRoundRectProps },
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 76d6edf..be5c52b 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -1568,11 +1568,6 @@ public final class Bitmap implements Parcelable {
nativePrepareToDraw(mSkBitmapPtr);
}
- /** @hide */
- public final long getSkBitmap() {
- return mSkBitmapPtr;
- }
-
/**
* Refs the underlying SkPixelRef and returns a pointer to it.
*
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 2acb8ba..1c56884 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1335,7 +1335,7 @@ public class Canvas {
*/
public void drawBitmap(@NonNull Bitmap bitmap, float left, float top, @Nullable Paint paint) {
throwIfCannotDraw(bitmap);
- native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top,
+ native_drawBitmap(mNativeCanvasWrapper, bitmap, left, top,
paint != null ? paint.getNativeInstance() : 0, mDensity, mScreenDensity, bitmap.mDensity);
}
@@ -1381,7 +1381,7 @@ public class Canvas {
bottom = src.bottom;
}
- native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top, right, bottom,
+ native_drawBitmap(mNativeCanvasWrapper, bitmap, left, top, right, bottom,
dst.left, dst.top, dst.right, dst.bottom, nativePaint, mScreenDensity,
bitmap.mDensity);
}
@@ -1428,7 +1428,7 @@ public class Canvas {
bottom = src.bottom;
}
- native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top, right, bottom,
+ native_drawBitmap(mNativeCanvasWrapper, bitmap, left, top, right, bottom,
dst.left, dst.top, dst.right, dst.bottom, nativePaint, mScreenDensity,
bitmap.mDensity);
}
@@ -1509,7 +1509,7 @@ public class Canvas {
* @param paint May be null. The paint used to draw the bitmap
*/
public void drawBitmap(@NonNull Bitmap bitmap, @NonNull Matrix matrix, @Nullable Paint paint) {
- nativeDrawBitmapMatrix(mNativeCanvasWrapper, bitmap.getSkBitmap(), matrix.ni(),
+ nativeDrawBitmapMatrix(mNativeCanvasWrapper, bitmap, matrix.ni(),
paint != null ? paint.getNativeInstance() : 0);
}
@@ -1564,7 +1564,7 @@ public class Canvas {
// no mul by 2, since we need only 1 color per vertex
checkRange(colors.length, colorOffset, count);
}
- nativeDrawBitmapMesh(mNativeCanvasWrapper, bitmap.getSkBitmap(), meshWidth, meshHeight,
+ nativeDrawBitmapMesh(mNativeCanvasWrapper, bitmap, meshWidth, meshHeight,
verts, vertOffset, colors, colorOffset,
paint != null ? paint.getNativeInstance() : 0);
}
@@ -2052,13 +2052,13 @@ public class Canvas {
private static native void native_drawPath(long nativeCanvas,
long nativePath,
long nativePaint);
- private native void native_drawBitmap(long nativeCanvas, long nativeBitmap,
+ private native void native_drawBitmap(long nativeCanvas, Bitmap bitmap,
float left, float top,
long nativePaintOrZero,
int canvasDensity,
int screenDensity,
int bitmapDensity);
- private native void native_drawBitmap(long nativeCanvas, long nativeBitmap,
+ private native void native_drawBitmap(long nativeCanvas, Bitmap bitmap,
float srcLeft, float srcTop, float srcRight, float srcBottom,
float dstLeft, float dstTop, float dstRight, float dstBottom,
long nativePaintOrZero, int screenDensity, int bitmapDensity);
@@ -2068,11 +2068,11 @@ public class Canvas {
boolean hasAlpha,
long nativePaintOrZero);
private static native void nativeDrawBitmapMatrix(long nativeCanvas,
- long nativeBitmap,
+ Bitmap bitmap,
long nativeMatrix,
long nativePaint);
private static native void nativeDrawBitmapMesh(long nativeCanvas,
- long nativeBitmap,
+ Bitmap bitmap,
int meshWidth, int meshHeight,
float[] verts, int vertOffset,
int[] colors, int colorOffset,
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index 9c4299a..21a212a 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -98,7 +98,7 @@ public class NinePatch {
public NinePatch(Bitmap bitmap, byte[] chunk, String srcName) {
mBitmap = bitmap;
mSrcName = srcName;
- mNativeChunk = validateNinePatchChunk(mBitmap.getSkBitmap(), chunk);
+ mNativeChunk = validateNinePatchChunk(chunk);
}
/**
@@ -199,12 +199,12 @@ public class NinePatch {
}
void drawSoftware(Canvas canvas, RectF location, Paint paint) {
- nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap.getSkBitmap(), mNativeChunk,
+ 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.getSkBitmap(), mNativeChunk,
+ nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap, mNativeChunk,
paint != null ? paint.getNativeInstance() : 0, canvas.mDensity, mBitmap.mDensity);
}
@@ -252,7 +252,7 @@ public class NinePatch {
* that are transparent.
*/
public final Region getTransparentRegion(Rect bounds) {
- long r = nativeGetTransparentRegion(mBitmap.getSkBitmap(), mNativeChunk, bounds);
+ long r = nativeGetTransparentRegion(mBitmap, mNativeChunk, bounds);
return r != 0 ? new Region(r) : null;
}
@@ -271,11 +271,11 @@ public class NinePatch {
* If validation is successful, this method returns a native Res_png_9patch*
* object used by the renderers.
*/
- private static native long validateNinePatchChunk(long bitmap, byte[] chunk);
+ private static native long validateNinePatchChunk(byte[] chunk);
private static native void nativeFinalize(long chunk);
- private static native void nativeDraw(long canvas_instance, RectF loc, long bitmap_instance,
+ 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, long bitmap_instance,
+ 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(long bitmap, long chunk, Rect location);
+ private static native long nativeGetTransparentRegion(Bitmap bitmap, long chunk, Rect location);
}
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 8757e15..4d596fe 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -220,7 +220,7 @@ void DisplayListRenderer::drawLayer(DeferredLayerUpdater* layerHandle, float x,
}
void DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) {
- bitmap = refBitmap(bitmap);
+ bitmap = refBitmap(*bitmap);
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawBitmapOp(bitmap, paint));
@@ -286,7 +286,7 @@ void DisplayListRenderer::drawBitmap(const SkBitmap& bitmap, float srcLeft, floa
dstRight = srcRight - srcLeft;
dstBottom = srcBottom - srcTop;
- addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(&bitmap),
+ addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(bitmap),
srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, paint));
restore();
@@ -294,7 +294,7 @@ void DisplayListRenderer::drawBitmap(const SkBitmap& bitmap, float srcLeft, floa
}
}
- addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(&bitmap),
+ addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(bitmap),
srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, paint));
}
@@ -307,17 +307,17 @@ void DisplayListRenderer::drawBitmapMesh(const SkBitmap& bitmap, int meshWidth,
paint = refPaint(paint);
colors = refBuffer<int>(colors, vertexCount); // 1 color per vertex
- addDrawOp(new (alloc()) DrawBitmapMeshOp(refBitmap(&bitmap), meshWidth, meshHeight,
+ addDrawOp(new (alloc()) DrawBitmapMeshOp(refBitmap(bitmap), meshWidth, meshHeight,
vertices, colors, paint));
}
-void DisplayListRenderer::drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+void DisplayListRenderer::drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
float left, float top, float right, float bottom, const SkPaint* paint) {
- bitmap = refBitmap(bitmap);
+ const SkBitmap* bitmapPtr = refBitmap(bitmap);
patch = refPatch(patch);
paint = refPaint(paint);
- addDrawOp(new (alloc()) DrawPatchOp(bitmap, patch, left, top, right, bottom, paint));
+ addDrawOp(new (alloc()) DrawPatchOp(bitmapPtr, patch, left, top, right, bottom, paint));
}
void DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index ff698f5..44cf546 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -100,7 +100,7 @@ public:
// Bitmap-based
void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint);
// TODO: move drawPatch() to Canvas.h
- void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ void drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
float left, float top, float right, float bottom, const SkPaint* paint);
// Shapes
@@ -347,7 +347,7 @@ private:
return cachedRegion;
}
- inline const SkBitmap* refBitmap(const SkBitmap* bitmap) {
+ inline const SkBitmap* refBitmap(const SkBitmap& bitmap) {
// Note that this assumes the bitmap is immutable. There are cases this won't handle
// correctly, such as creating the bitmap from scratch, drawing with it, changing its
// contents, and drawing again. The only fix would be to always copy it the first time,
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index d3b8d70..454fedc 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -59,13 +59,13 @@ void ResourceCache::unlock() {
mLock.unlock();
}
-const SkBitmap* ResourceCache::insert(const SkBitmap* bitmapResource) {
+const SkBitmap* ResourceCache::insert(const SkBitmap& bitmapResource) {
Mutex::Autolock _l(mLock);
BitmapKey bitmapKey(bitmapResource);
ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
if (index == NAME_NOT_FOUND) {
- SkBitmap* cachedBitmap = new SkBitmap(*bitmapResource);
+ SkBitmap* cachedBitmap = new SkBitmap(bitmapResource);
index = mBitmapCache.add(bitmapKey, cachedBitmap);
return cachedBitmap;
}
@@ -121,7 +121,7 @@ void ResourceCache::decrementRefcountLocked(void* resource) {
}
void ResourceCache::decrementRefcountLocked(const SkBitmap* bitmapResource) {
- BitmapKey bitmapKey(bitmapResource);
+ BitmapKey bitmapKey(*bitmapResource);
ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
LOG_ALWAYS_FATAL_IF(index == NAME_NOT_FOUND,
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index fae55d1..6c483fa 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -53,11 +53,11 @@ public:
class BitmapKey {
public:
- BitmapKey(const SkBitmap* bitmap)
+ BitmapKey(const SkBitmap& bitmap)
: mRefCount(1)
- , mBitmapDimensions(bitmap->dimensions())
- , mPixelRefOrigin(bitmap->pixelRefOrigin())
- , mPixelRefStableID(bitmap->pixelRef()->getStableID()) { }
+ , mBitmapDimensions(bitmap.dimensions())
+ , mPixelRefOrigin(bitmap.pixelRefOrigin())
+ , mPixelRefStableID(bitmap.pixelRef()->getStableID()) { }
void operator=(const BitmapKey& other);
bool operator==(const BitmapKey& other) const;
@@ -101,7 +101,7 @@ public:
* The cache stores a copy of the provided resource or refs an existing resource
* if the bitmap has previously been inserted and returns the cached copy.
*/
- const SkBitmap* insert(const SkBitmap* resource);
+ const SkBitmap* insert(const SkBitmap& resource);
void incrementRefcount(const Res_png_9patch* resource);