diff options
author | Cary Clark <cary@android.com> | 2010-10-28 17:29:48 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2010-11-01 17:31:41 -0400 |
commit | 5e2280268227ed65a21c4c27ed8f240bd3bea671 (patch) | |
tree | 8e3d99d63a8924b367488126381d7d9d8bfc6edf /WebCore | |
parent | cc519b6e7f277a2aa0aa197bdb7163d662749552 (diff) | |
download | external_webkit-5e2280268227ed65a21c4c27ed8f240bd3bea671.zip external_webkit-5e2280268227ed65a21c4c27ed8f240bd3bea671.tar.gz external_webkit-5e2280268227ed65a21c4c27ed8f240bd3bea671.tar.bz2 |
add function to find color on picture's edge
bug:3065048
Change-Id: I18ef06a4b9ac3bef077f08efd738958bd5abaafe
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/BaseLayerAndroid.cpp | 26 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/BaseLayerAndroid.h | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index f91a3e7..c043edb 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -238,4 +238,30 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, return ret; } +SkColor BaseLayerAndroid::getColor(const SkIRect& rect) +{ + SkBitmap sample, pixel; + SkCanvas canvas; + sample.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); + sample.allocPixels(); + canvas.setBitmapDevice(sample); + canvas.save(); + canvas.translate(-rect.fLeft, -rect.fTop); + draw(&canvas); + canvas.restore(); + pixel.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); + pixel.allocPixels(); + canvas.setBitmapDevice(pixel); + SkPaint paint; + paint.setFlags(SkPaint::kFilterBitmap_Flag); + canvas.scale(SkScalarInvert(SkIntToScalar(rect.width())), + SkScalarInvert(SkIntToScalar(rect.height()))); + canvas.drawBitmap(sample, 0, 0, &paint); + pixel.lockPixels(); + uint32_t* colorAddr = pixel.getAddr32(0, 0); + SkColor result = (SkColor) *colorAddr; + pixel.unlockPixels(); + return result; +} + } // namespace WebCore diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h index 73804a1..66bf119 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -56,6 +56,8 @@ public: bool drawGL(IntRect& rect, SkRect& viewport, float scale, SkColor color = SK_ColorWHITE); + SkColor getColor(const SkIRect& rect); + private: #if USE(ACCELERATED_COMPOSITING) bool drawBasePictureInGL(SkRect& viewport, float scale); |