Changeset 116199 in webkit


Ignore:
Timestamp:
May 4, 2012 6:12:54 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Blackberry] Implement over-scroll background image
https://bugs.webkit.org/show_bug.cgi?id=85538

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

Use over-scroll image when set instead of the solid colour.
Internal PR146652

  • Api/BackingStore.cpp:

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

  • Api/BackingStore_p.h:

(BackingStorePrivate):

  • Api/WebSettings.cpp:

(WebKit):
(BlackBerry::WebKit::WebSettings::standardSettings):
(BlackBerry::WebKit::WebSettings::overScrollImagePath):
(BlackBerry::WebKit::WebSettings::setOverScrollImagePath):

  • Api/WebSettings.h:
Location:
trunk/Source/WebKit/blackberry
Files:
5 edited

Legend:

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

    r115289 r116199  
    3838#include "WebSettings.h"
    3939
     40#include <BlackBerryPlatformClient.h>
    4041#include <BlackBerryPlatformExecutableMessage.h>
     42#include <BlackBerryPlatformGraphics.h>
    4143#include <BlackBerryPlatformIntRectRegion.h>
    4244#include <BlackBerryPlatformLog.h>
     
    4446#include <BlackBerryPlatformMessageClient.h>
    4547#include <BlackBerryPlatformScreen.h>
     48#include <BlackBerryPlatformSettings.h>
    4649#include <BlackBerryPlatformWindow.h>
     50
     51#include <SkImageDecoder.h>
    4752
    4853#include <wtf/CurrentTime.h>
     
    7378const int s_renderTimerTimeout = 1.0;
    7479WebPage* BackingStorePrivate::s_currentBackingStoreOwner = 0;
     80Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0;
     81std::string BackingStorePrivate::s_overScrollImagePath;
    7582
    7683typedef std::pair<int, int> Divisor;
     
    11921199}
    11931200
     1201bool BackingStorePrivate::ensureOverScrollImage()
     1202{
     1203    std::string path = m_webPage->settings()->overScrollImagePath().utf8();
     1204    if (path == "")
     1205        return false;
     1206
     1207    if (s_overScrollImage && path == s_overScrollImagePath)
     1208        return true;
     1209
     1210    std::string imagePath = Platform::Client::get()->getApplicationDirectory() + path;
     1211
     1212    SkBitmap bitmap;
     1213
     1214    if (!SkImageDecoder::DecodeFile(imagePath.c_str(), &bitmap)) {
     1215        BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
     1216                    "BackingStorePrivate::ensureOverScrollImage could not decode overscroll image: %s", imagePath.c_str());
     1217        return false;
     1218    }
     1219
     1220    // FIXME: Make it orientation and resolution agnostic
     1221    if (bitmap.width() != surfaceSize().width() || bitmap.height() != surfaceSize().height())
     1222        return false;
     1223
     1224    // FIXME: For now we fallback to solid color if sizes don't match, later we can implement tiling
     1225    s_overScrollImage = createBuffer(Platform::IntSize(bitmap.width(), bitmap.height()), Platform::Graphics::TemporaryBuffer);
     1226
     1227    SkCanvas* canvas = Platform::Graphics::lockBufferDrawable(s_overScrollImage);
     1228
     1229    if (!canvas) {
     1230        destroyBuffer(s_overScrollImage);
     1231        s_overScrollImage = 0;
     1232        return false;
     1233    }
     1234    SkPaint paint;
     1235    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
     1236    paint.setFlags(SkPaint::kAntiAlias_Flag);
     1237    paint.setFilterBitmap(true);
     1238
     1239    SkRect rect = SkRect::MakeXYWH(0, 0, bitmap.width(), bitmap.height());
     1240
     1241    canvas->save();
     1242    canvas->drawBitmapRect(bitmap, 0, rect, &paint);
     1243    canvas->restore();
     1244
     1245    Platform::Graphics::releaseBufferDrawable(s_overScrollImage);
     1246
     1247    s_overScrollImagePath = path;
     1248
     1249    return true;
     1250}
     1251
    11941252void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& contents,
    11951253                                                 const WebCore::TransformationMatrix& transformation,
     
    11991257    Platform::IntPoint origin = contents.location();
    12001258    Platform::IntRect contentsClipped = contents;
     1259
    12011260
    12021261    // We have to paint the default background in the case of overzoom and
     
    12201279        }
    12211280
    1222         clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
     1281        if (ensureOverScrollImage())
     1282            blitToWindow(overScrollRect, s_overScrollImage, overScrollRect, false, 255);
     1283        else
     1284            clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
    12231285    }
    12241286}
  • trunk/Source/WebKit/blackberry/Api/BackingStore_p.h

    r115289 r116199  
    327327    BlackBerry::Platform::Graphics::Buffer* buffer() const;
    328328
     329    bool ensureOverScrollImage();
     330
    329331    static WebPage* s_currentBackingStoreOwner;
    330332
     
    368370#endif
    369371
     372    static Platform::Graphics::Buffer* s_overScrollImage;
     373    static std::string s_overScrollImagePath;
     374
    370375protected:
    371376    virtual ~BackingStorePrivate();
  • trunk/Source/WebKit/blackberry/Api/WebSettings.cpp

    r116145 r116199  
    4545DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, ("BlackBerryMaxPluginInstances"));
    4646DEFINE_STATIC_LOCAL(String, BlackBerryOverZoomColor, ("BlackBerryOverZoomColor"));
     47DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollImagePath, ("BlackBerryOverScrollImagePath"));
    4748DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, ("BlackBerryRenderAnimationsOnScrollOrZoomEnabled"));
    4849DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, ("BlackBerryScrollbarsEnabled"));
     
    153154    settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1);
    154155    settings->m_private->setUnsigned(BlackBerryOverZoomColor, WebCore::Color::white);
     156    settings->m_private->setString(BlackBerryOverScrollImagePath, "");
    155157    settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true);
    156158
     
    662664}
    663665
     666WebString WebSettings::overScrollImagePath() const
     667{
     668    return m_private->getString(BlackBerryOverScrollImagePath);
     669}
     670
     671void WebSettings::setOverScrollImagePath(const char* path)
     672{
     673    m_private->setString(BlackBerryOverScrollImagePath, path);
     674}
     675
    664676unsigned WebSettings::backgroundColor() const
    665677{
  • trunk/Source/WebKit/blackberry/Api/WebSettings.h

    r116145 r116199  
    194194    void setOverZoomColor(unsigned);
    195195
     196    WebString overScrollImagePath() const;
     197    void setOverScrollImagePath(const char*);
     198
    196199    unsigned backgroundColor() const;
    197200    void setBackgroundColor(unsigned);
  • trunk/Source/WebKit/blackberry/ChangeLog

    r116145 r116199  
     12012-05-04  Andrew Lo  <anlo@rim.com>
     2
     3        [Blackberry] Implement over-scroll background image
     4        https://bugs.webkit.org/show_bug.cgi?id=85538
     5
     6        Reviewed by Rob Buis.
     7
     8        Use over-scroll image when set instead of the solid colour.
     9        Internal PR146652
     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        * Api/WebSettings.cpp:
     18        (WebKit):
     19        (BlackBerry::WebKit::WebSettings::standardSettings):
     20        (BlackBerry::WebKit::WebSettings::overScrollImagePath):
     21        (BlackBerry::WebKit::WebSettings::setOverScrollImagePath):
     22        * Api/WebSettings.h:
     23
    1242012-05-04  Rob Buis  <rbuis@rim.com>
    225
Note: See TracChangeset for help on using the changeset viewer.