diff options
author | Cary Clark <cary@android.com> | 2009-09-23 14:04:57 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2009-09-23 14:37:09 -0400 |
commit | 757f90b7b68402aa3f32c125bd9b302e60c4b50b (patch) | |
tree | d62b228eb9315378dc6bbec87faba6164d9048d5 /WebKit | |
parent | e23a6d30242a5dbcdce40e708e0f97b21d06c2af (diff) | |
download | external_webkit-757f90b7b68402aa3f32c125bd9b302e60c4b50b.zip external_webkit-757f90b7b68402aa3f32c125bd9b302e60c4b50b.tar.gz external_webkit-757f90b7b68402aa3f32c125bd9b302e60c4b50b.tar.bz2 |
hardcode the correct ninepatch margins for the button skin
The button is drawn using hardcoded margins that look fine
on a g1. The highres resource has different margins. Changing
the margins alone isn't enough; this also moves the button down
by two pixels to center it better.
Neither the hardcoded margin change nor the offset are
good long-term changes, but they allow us to get by for now.
Marked both with FIXME so we can address this issue by
reading the data directly out of the png, and diagnose why
the button is drawn too high.
fixes http://b/issue?id=2107422
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/RenderSkinButton.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/WebKit/android/RenderSkinButton.cpp b/WebKit/android/RenderSkinButton.cpp index c28dccf..d4483a7 100644 --- a/WebKit/android/RenderSkinButton.cpp +++ b/WebKit/android/RenderSkinButton.cpp @@ -51,7 +51,8 @@ static const PatchData gFiles[] = }; static SkBitmap gButton[sizeof(gFiles)/sizeof(gFiles[0])]; -static bool gDecoded; +static bool gDecoded; +static bool gHighRes; namespace WebCore { @@ -63,6 +64,7 @@ void RenderSkinButton::Init(android::AssetManager* am, String drawableDirectory) gInited = true; gDecoded = true; + gHighRes = drawableDirectory[drawableDirectory.length() - 5] == 'h'; for (size_t i = 0; i < sizeof(gFiles)/sizeof(gFiles[0]); i++) { String path = drawableDirectory + gFiles[i].name; if (!RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &gButton[i])) { @@ -99,7 +101,16 @@ void RenderSkinButton::Draw(SkCanvas* canvas, const IntRect& r, RenderSkinAndroi SkIRect margin; margin.set(marginValue, marginValue, marginValue, marginValue); - + if (gHighRes) { + /* FIXME: it shoudn't be necessary to offset the button here, + but gives the right results. */ + bounds.offset(0, SK_Scalar1 * 2); + /* FIXME: This temporarily gets around the fact that the margin values and + positioning were created for a low res asset, which was used on + g1-like devices. A better fix would be to read the offset information + out of the png. */ + margin.set(10, 9, 10, 14); + } // Draw to the canvas. SkNinePatch::DrawNine(canvas, bounds, gButton[newState], margin); } |