summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api/BackingStore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/blackberry/Api/BackingStore.cpp')
-rw-r--r--Source/WebKit/blackberry/Api/BackingStore.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/Source/WebKit/blackberry/Api/BackingStore.cpp b/Source/WebKit/blackberry/Api/BackingStore.cpp
index eeda7dd8a..ddc873fe0 100644
--- a/Source/WebKit/blackberry/Api/BackingStore.cpp
+++ b/Source/WebKit/blackberry/Api/BackingStore.cpp
@@ -79,6 +79,7 @@ const int s_renderTimerTimeout = 1.0;
WebPage* BackingStorePrivate::s_currentBackingStoreOwner = 0;
Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0;
std::string BackingStorePrivate::s_overScrollImagePath;
+Platform::IntSize BackingStorePrivate::s_overScrollImageSize;
typedef std::pair<int, int> Divisor;
typedef Vector<Divisor> DivisorList;
@@ -1207,43 +1208,38 @@ bool BackingStorePrivate::ensureOverScrollImage()
if (s_overScrollImage && path == s_overScrollImagePath)
return true;
- std::string imagePath = Platform::Client::get()->getApplicationDirectory() + path;
+ std::string imagePath = Platform::Client::get()->getApplicationLocalDirectory() + path;
SkBitmap bitmap;
-
if (!SkImageDecoder::DecodeFile(imagePath.c_str(), &bitmap)) {
BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
"BackingStorePrivate::ensureOverScrollImage could not decode overscroll image: %s", imagePath.c_str());
return false;
}
- // FIXME: Make it orientation and resolution agnostic
- if (bitmap.width() != surfaceSize().width() || bitmap.height() != surfaceSize().height())
- return false;
-
- // FIXME: For now we fallback to solid color if sizes don't match, later we can implement tiling
+ destroyBuffer(s_overScrollImage);
s_overScrollImage = createBuffer(Platform::IntSize(bitmap.width(), bitmap.height()), Platform::Graphics::TemporaryBuffer);
SkCanvas* canvas = Platform::Graphics::lockBufferDrawable(s_overScrollImage);
-
if (!canvas) {
destroyBuffer(s_overScrollImage);
s_overScrollImage = 0;
return false;
}
+
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setFilterBitmap(true);
SkRect rect = SkRect::MakeXYWH(0, 0, bitmap.width(), bitmap.height());
-
canvas->save();
canvas->drawBitmapRect(bitmap, 0, rect, &paint);
canvas->restore();
Platform::Graphics::releaseBufferDrawable(s_overScrollImage);
+ s_overScrollImageSize = Platform::IntSize(bitmap.width(), bitmap.height());
s_overScrollImagePath = path;
return true;
@@ -1278,9 +1274,20 @@ void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& conten
overScrollRect.intersect(Platform::IntRect(Platform::IntPoint(0, 0), surfaceSize()));
}
- if (ensureOverScrollImage())
- blitToWindow(overScrollRect, s_overScrollImage, overScrollRect, false, 255);
- else
+ if (ensureOverScrollImage()) {
+ // Tile the image on the window region.
+ Platform::IntRect dstRect;
+ for (int y = overScrollRect.y(); y < overScrollRect.y() + overScrollRect.height(); y += dstRect.height()) {
+ for (int x = overScrollRect.x(); x < overScrollRect.x() + overScrollRect.width(); x += dstRect.width()) {
+ Platform::IntRect imageRect = Platform::IntRect(Platform::IntPoint(x - (x % s_overScrollImageSize.width()),
+ y - (y % s_overScrollImageSize.height())), s_overScrollImageSize);
+ dstRect = imageRect;
+ dstRect.intersect(overScrollRect);
+ Platform::IntRect srcRect = Platform::IntRect(x - imageRect.x(), y - imageRect.y(), dstRect.width(), dstRect.height());
+ blitToWindow(dstRect, s_overScrollImage, srcRect, false, 255);
+ }
+ }
+ } else
clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
}
}