summaryrefslogtreecommitdiffstats
path: root/Source/WebKit
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-08-17 09:27:48 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-17 09:27:48 -0700
commita40c938b2b473137d000d9ff34962ce54edbbadd (patch)
tree4c30ad5a02a9a0632d6c4023a11a89adcc547444 /Source/WebKit
parenta20260cdd58c5704fa177bc2054bceb933076292 (diff)
parente370de1d415855eb14e8f917acf5217c5ab5a2f9 (diff)
downloadexternal_webkit-a40c938b2b473137d000d9ff34962ce54edbbadd.zip
external_webkit-a40c938b2b473137d000d9ff34962ce54edbbadd.tar.gz
external_webkit-a40c938b2b473137d000d9ff34962ce54edbbadd.tar.bz2
Merge "Fix NinePatch issue when the destination is smaller than the asset"
Diffstat (limited to 'Source/WebKit')
-rw-r--r--Source/WebKit/android/RenderSkinNinePatch.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/WebKit/android/RenderSkinNinePatch.cpp b/Source/WebKit/android/RenderSkinNinePatch.cpp
index 074a65a..faa9dc4 100644
--- a/Source/WebKit/android/RenderSkinNinePatch.cpp
+++ b/Source/WebKit/android/RenderSkinNinePatch.cpp
@@ -20,6 +20,7 @@
#include "NinePatchPeeker.h"
#include "SkCanvas.h"
#include "SkImageDecoder.h"
+#include "SkNinePatch.h"
#include "SkRect.h"
#include "SkStream.h"
#include "SkTemplates.h"
@@ -85,5 +86,20 @@ bool RenderSkinNinePatch::decodeAsset(AssetManager* am, const char* filename, Ni
void RenderSkinNinePatch::DrawNinePatch(SkCanvas* canvas, const SkRect& bounds,
const NinePatch& patch) {
Res_png_9patch* data = Res_png_9patch::deserialize(patch.m_serializedPatchData);
- NinePatch_Draw(canvas, bounds, patch.m_bitmap, *data, 0, 0);
+
+ // if the NinePatch is bigger than the destination on a given axis the default
+ // decoder will not stretch properly, therefore we fall back to skia's decoder
+ // which if needed will down-sample and draw the bitmap as best as possible.
+ if (patch.m_bitmap.width() >= bounds.width() || patch.m_bitmap.height() >= bounds.height()) {
+
+ SkPaint defaultPaint;
+ // matches default dither in NinePatchDrawable.java.
+ defaultPaint.setDither(true);
+ SkNinePatch::DrawMesh(canvas, bounds, patch.m_bitmap,
+ data->xDivs, data->numXDivs,
+ data->yDivs, data->numYDivs,
+ &defaultPaint);
+ } else {
+ NinePatch_Draw(canvas, bounds, patch.m_bitmap, *data, 0, 0);
+ }
}