summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-09-10 14:32:16 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-11 13:31:45 -0700
commit8cae124af2142687a6833dbaab8a43df6dd67b43 (patch)
tree662ea14668e4b07cb2336d62fdb0241713182480 /core/jni
parent7ff269f359a8848fd0c39993d8fe21a8324806f9 (diff)
downloadframeworks_base-8cae124af2142687a6833dbaab8a43df6dd67b43.zip
frameworks_base-8cae124af2142687a6833dbaab8a43df6dd67b43.tar.gz
frameworks_base-8cae124af2142687a6833dbaab8a43df6dd67b43.tar.bz2
Various cleanup around resources and nine-patches.
Remove the stuff that doesn't use preloaded drawables when in compatibility mode, since this works fine ever since we were able to deal with drawables in a different density than the canvas. Change the snapshot function on View to return a snapshot at the same size that will actually be drawn on screen (when in compatibility mode), to be able to show scaling artifacts and all. This change was original an attempt to fix issue #2101917: Text field edges appears to be improperly rounded. That turns out to probably be something deeper in the graphics system, but also included here is the debugging code I did to try to track down the problem to make it easy to turn on again later. Change-Id: I34bfca629639c7ff103f3989d88874112ef778d9
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android/graphics/NinePatch.cpp29
-rw-r--r--core/jni/android/graphics/NinePatchImpl.cpp28
2 files changed, 44 insertions, 13 deletions
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index fd5271e..50df0f7 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -1,4 +1,25 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#define LOG_TAG "9patch"
+#define LOG_NDEBUG 1
+
#include <utils/ResourceTypes.h>
+#include <utils/Log.h>
#include "SkCanvas.h"
#include "SkRegion.h"
@@ -62,6 +83,9 @@ public:
if (destDensity == srcDensity || destDensity == 0
|| srcDensity == 0) {
+ LOGV("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();
@@ -74,6 +98,11 @@ public:
bounds.fBottom = SkScalarDiv(bounds.fBottom-bounds.fTop, scale);
bounds.fLeft = bounds.fTop = 0;
+ LOGV("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();
diff --git a/core/jni/android/graphics/NinePatchImpl.cpp b/core/jni/android/graphics/NinePatchImpl.cpp
index 32d9b57..ff24a87 100644
--- a/core/jni/android/graphics/NinePatchImpl.cpp
+++ b/core/jni/android/graphics/NinePatchImpl.cpp
@@ -16,8 +16,10 @@
*/
#define LOG_TAG "NinePatch"
+#define LOG_NDEBUG 1
#include <utils/ResourceTypes.h>
+#include <utils/Log.h>
#include "SkBitmap.h"
#include "SkCanvas.h"
@@ -25,7 +27,7 @@
#include "SkPaint.h"
#include "SkUnPreMultiply.h"
-#define USE_TRACEx
+#define USE_TRACE
#ifdef USE_TRACE
static bool gTrace;
@@ -130,10 +132,10 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
SkASSERT(canvas || outRegion);
-#if 0
+#ifdef USE_TRACE
if (canvas) {
const SkMatrix& m = canvas->getTotalMatrix();
- SkDebugf("ninepatch [%g %g %g] [%g %g %g]\n",
+ LOGV("ninepatch [%g %g %g] [%g %g %g]\n",
SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]),
SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5]));
}
@@ -141,10 +143,10 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
#ifdef USE_TRACE
if (gTrace) {
- SkDEBUGF(("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height())));
- SkDEBUGF(("======== ninepatch paint bm [%d,%d]\n", bitmap.width(), bitmap.height()));
- SkDEBUGF(("======== ninepatch xDivs [%d,%d]\n", chunk.xDivs[0], chunk.xDivs[1]));
- SkDEBUGF(("======== ninepatch yDivs [%d,%d]\n", chunk.yDivs[0], chunk.yDivs[1]));
+ LOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()));
+ LOGV("======== ninepatch paint bm [%d,%d]\n", bitmap.width(), bitmap.height());
+ LOGV("======== ninepatch xDivs [%d,%d]\n", chunk.xDivs[0], chunk.xDivs[1]);
+ LOGV("======== ninepatch yDivs [%d,%d]\n", chunk.yDivs[0], chunk.yDivs[1]);
}
#endif
@@ -153,7 +155,7 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
(paint && paint->getXfermode() == NULL && paint->getAlpha() == 0))
{
#ifdef USE_TRACE
- if (gTrace) SkDEBUGF(("======== abort ninepatch draw\n"));
+ if (gTrace) LOGV("======== abort ninepatch draw\n");
#endif
return;
}
@@ -198,8 +200,8 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
}
int numFixedYPixelsRemaining = bitmapHeight - numStretchyYPixelsRemaining;
-#if 0
- SkDebugf("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n",
+#ifdef USE_TRACE
+ LOGV("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n",
bitmap.width(), bitmap.height(),
SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop),
SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()),
@@ -302,13 +304,13 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
goto nextDiv;
}
if (canvas) {
-#if 0
- SkDebugf("-- src [%d %d %d %d] dst [%g %g %g %g]\n",
+#ifdef USE_TRACE
+ LOGV("-- src [%d %d %d %d] dst [%g %g %g %g]\n",
src.fLeft, src.fTop, src.width(), src.height(),
SkScalarToFloat(dst.fLeft), SkScalarToFloat(dst.fTop),
SkScalarToFloat(dst.width()), SkScalarToFloat(dst.height()));
if (2 == src.width() && SkIntToScalar(5) == dst.width()) {
- SkDebugf("--- skip patch\n");
+ LOGV("--- skip patch\n");
}
#endif
drawStretchyPatch(canvas, src, dst, bitmap, *paint, initColor,