Changeset 116429 in webkit


Ignore:
Timestamp:
May 8, 2012 9:21:24 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Over-scroll image should be tiled
https://bugs.webkit.org/show_bug.cgi?id=85860

Patch by Andrew Lo <anlo@rim.com> on 2012-05-08
Reviewed by Rob Buis.

Implement tiling for over-scroll image if image dimension don't match
the surface dimensions.

  • Api/BackingStore.cpp:

(WebKit):
(BlackBerry::WebKit::BackingStorePrivate::ensureOverScrollImage):
(BlackBerry::WebKit::BackingStorePrivate::paintDefaultBackground):

  • Api/BackingStore_p.h:

(BackingStorePrivate):

Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/BackingStore.cpp

    r116350 r116429  
    8080Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0;
    8181std::string BackingStorePrivate::s_overScrollImagePath;
     82Platform::IntSize BackingStorePrivate::s_overScrollImageSize;
    8283
    8384typedef std::pair<int, int> Divisor;
     
    12111212
    12121213    SkBitmap bitmap;
    1213 
    12141214    if (!SkImageDecoder::DecodeFile(imagePath.c_str(), &bitmap)) {
    12151215        BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
     
    12181218    }
    12191219
    1220     // FIXME: Make it orientation and resolution agnostic.
    1221     // For now we fallback to solid color if sizes don't match, later we can implement tiling.
    1222     if (bitmap.width() != surfaceSize().width() || bitmap.height() != surfaceSize().height())
    1223         return false;
    1224 
    12251220    destroyBuffer(s_overScrollImage);
    12261221    s_overScrollImage = createBuffer(Platform::IntSize(bitmap.width(), bitmap.height()), Platform::Graphics::TemporaryBuffer);
    12271222
    12281223    SkCanvas* canvas = Platform::Graphics::lockBufferDrawable(s_overScrollImage);
    1229 
    12301224    if (!canvas) {
    12311225        destroyBuffer(s_overScrollImage);
     
    12331227        return false;
    12341228    }
     1229
    12351230    SkPaint paint;
    12361231    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
     
    12391234
    12401235    SkRect rect = SkRect::MakeXYWH(0, 0, bitmap.width(), bitmap.height());
    1241 
    12421236    canvas->save();
    12431237    canvas->drawBitmapRect(bitmap, 0, rect, &paint);
     
    12461240    Platform::Graphics::releaseBufferDrawable(s_overScrollImage);
    12471241
     1242    s_overScrollImageSize = Platform::IntSize(bitmap.width(), bitmap.height());
    12481243    s_overScrollImagePath = path;
    12491244
     
    12801275        }
    12811276
    1282         if (ensureOverScrollImage())
    1283             blitToWindow(overScrollRect, s_overScrollImage, overScrollRect, false, 255);
    1284         else
     1277        if (ensureOverScrollImage()) {
     1278            // Tile the image on the window region.
     1279            Platform::IntRect dstRect;
     1280            for (int y = overScrollRect.y(); y < overScrollRect.y() + overScrollRect.height(); y += dstRect.height()) {
     1281                for (int x = overScrollRect.x(); x < overScrollRect.x() + overScrollRect.width(); x += dstRect.width()) {
     1282                    Platform::IntRect imageRect = Platform::IntRect(Platform::IntPoint(x - (x % s_overScrollImageSize.width()),
     1283                            y - (y % s_overScrollImageSize.height())), s_overScrollImageSize);
     1284                    dstRect = imageRect;
     1285                    dstRect.intersect(overScrollRect);
     1286                    Platform::IntRect srcRect = Platform::IntRect(x - imageRect.x(), y - imageRect.y(), dstRect.width(), dstRect.height());
     1287                    blitToWindow(dstRect, s_overScrollImage, srcRect, false, 255);
     1288                }
     1289            }
     1290        } else
    12851291            clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
    12861292    }
  • trunk/Source/WebKit/blackberry/Api/BackingStore_p.h

    r116199 r116429  
    372372    static Platform::Graphics::Buffer* s_overScrollImage;
    373373    static std::string s_overScrollImagePath;
     374    static Platform::IntSize s_overScrollImageSize;
    374375
    375376protected:
  • trunk/Source/WebKit/blackberry/ChangeLog

    r116418 r116429  
     12012-05-08  Andrew Lo  <anlo@rim.com>
     2
     3        [BlackBerry] Over-scroll image should be tiled
     4        https://bugs.webkit.org/show_bug.cgi?id=85860
     5
     6        Reviewed by Rob Buis.
     7
     8        Implement tiling for over-scroll image if image dimension don't match
     9        the surface dimensions.
     10
     11        * Api/BackingStore.cpp:
     12        (WebKit):
     13        (BlackBerry::WebKit::BackingStorePrivate::ensureOverScrollImage):
     14        (BlackBerry::WebKit::BackingStorePrivate::paintDefaultBackground):
     15        * Api/BackingStore_p.h:
     16        (BackingStorePrivate):
     17
    1182012-05-08  Chris Guan  <chris.guan@torchmobile.com.cn>
    219
Note: See TracChangeset for help on using the changeset viewer.