Changeset 122587 in webkit


Ignore:
Timestamp:
Jul 13, 2012 8:53:24 AM (12 years ago)
Author:
jpetsovits@rim.com
Message:

[BlackBerry] Use fillBuffer() instead of a user-defined background image.
https://bugs.webkit.org/show_bug.cgi?id=91180
RIM PR 171458

Reviewed by Rob Buis.
Internally reviewed by Andrew Lo.

By using Platform::Graphics::fillBuffer() to fill the
overscroll area, we save graphics memory for the buffer
that the background image was occupying.

Also adapt checkerboard drawing as it is now done using
fillBuffer() which replaces checkerBuffer().

In the same go, use the opportunity of the WebSettings
API change to make it more consistent, renaming the
OverZoomColor setting to OverScrollColor.

  • Api/BackingStore.cpp:

(WebKit):
(BlackBerry::WebKit::BackingStorePrivate::paintDefaultBackground):
(BlackBerry::WebKit::BackingStorePrivate::blitContents):
(BlackBerry::WebKit::BackingStorePrivate::fillWindow):

  • Api/BackingStore_p.h:

(BackingStorePrivate):

  • Api/WebSettings.cpp:

(WebKit):
(BlackBerry::WebKit::WebSettings::standardSettings):
(BlackBerry::WebKit::WebSettings::overScrollColor):
(BlackBerry::WebKit::WebSettings::setOverScrollColor):
(BlackBerry::WebKit::WebSettings::isEnableDefaultOverScrollBackground):
(BlackBerry::WebKit::WebSettings::setEnableDefaultOverScrollBackground):

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

Legend:

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

    r121824 r122587  
    7878const int s_renderTimerTimeout = 1.0;
    7979WebPage* BackingStorePrivate::s_currentBackingStoreOwner = 0;
    80 Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0;
    81 std::string BackingStorePrivate::s_overScrollImagePath;
    82 Platform::IntSize BackingStorePrivate::s_overScrollImageSize;
    8380
    8481typedef std::pair<int, int> Divisor;
     
    12201217}
    12211218
    1222 bool BackingStorePrivate::ensureOverScrollImage()
    1223 {
    1224     std::string path = m_webPage->settings()->overScrollImagePath().utf8();
    1225     if (path == "")
    1226         return false;
    1227 
    1228     if (s_overScrollImage && path == s_overScrollImagePath)
    1229         return true;
    1230 
    1231     std::string imagePath = Platform::Client::get()->getApplicationLocalDirectory() + path;
    1232 
    1233     SkBitmap bitmap;
    1234     if (!SkImageDecoder::DecodeFile(imagePath.c_str(), &bitmap)) {
    1235         BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
    1236                     "BackingStorePrivate::ensureOverScrollImage could not decode overscroll image: %s", imagePath.c_str());
    1237         return false;
    1238     }
    1239 
    1240     destroyBuffer(s_overScrollImage);
    1241     s_overScrollImage = createBuffer(Platform::IntSize(bitmap.width(), bitmap.height()), Platform::Graphics::TemporaryBuffer);
    1242 
    1243     SkCanvas* canvas = Platform::Graphics::lockBufferDrawable(s_overScrollImage);
    1244     if (!canvas) {
    1245         destroyBuffer(s_overScrollImage);
    1246         s_overScrollImage = 0;
    1247         return false;
    1248     }
    1249 
    1250     SkPaint paint;
    1251     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
    1252     paint.setFlags(SkPaint::kAntiAlias_Flag);
    1253     paint.setFilterBitmap(true);
    1254 
    1255     SkRect rect = SkRect::MakeXYWH(0, 0, bitmap.width(), bitmap.height());
    1256     canvas->save();
    1257     canvas->drawBitmapRect(bitmap, 0, rect, &paint);
    1258     canvas->restore();
    1259 
    1260     Platform::Graphics::releaseBufferDrawable(s_overScrollImage);
    1261 
    1262     s_overScrollImageSize = Platform::IntSize(bitmap.width(), bitmap.height());
    1263     s_overScrollImagePath = path;
    1264 
    1265     return true;
    1266 }
    1267 
    12681219void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& contents,
    12691220                                                 const WebCore::TransformationMatrix& transformation,
     
    12741225    Platform::IntRect contentsClipped = contents;
    12751226
    1276 
    12771227    // We have to paint the default background in the case of overzoom and
    12781228    // make sure it is invalidated.
    1279     Color color(m_webPage->settings()->overZoomColor());
    1280 
    12811229    Platform::IntRectRegion overScrollRegion
    12821230            = Platform::IntRectRegion::subtractRegions(Platform::IntRect(contentsClipped), contentsRect);
     
    12951243        }
    12961244
    1297         if (ensureOverScrollImage()) {
    1298             // Tile the image on the window region.
    1299             Platform::IntRect dstRect;
    1300             for (int y = overScrollRect.y(); y < overScrollRect.y() + overScrollRect.height(); y += dstRect.height()) {
    1301                 for (int x = overScrollRect.x(); x < overScrollRect.x() + overScrollRect.width(); x += dstRect.width()) {
    1302                     Platform::IntRect imageRect = Platform::IntRect(Platform::IntPoint(x - (x % s_overScrollImageSize.width()),
    1303                             y - (y % s_overScrollImageSize.height())), s_overScrollImageSize);
    1304                     dstRect = imageRect;
    1305                     dstRect.intersect(overScrollRect);
    1306                     Platform::IntRect srcRect = Platform::IntRect(x - imageRect.x(), y - imageRect.y(), dstRect.width(), dstRect.height());
    1307                     blitToWindow(dstRect, s_overScrollImage, srcRect, false, 255);
    1308                 }
    1309             }
    1310         } else
     1245        if (m_webPage->settings()->isEnableDefaultOverScrollBackground()) {
     1246            fillWindow(BlackBerry::Platform::Graphics::DefaultBackgroundPattern,
     1247                overScrollRect, overScrollRect.location(), 1.0 /*contentsScale*/);
     1248        } else {
     1249            Color color(m_webPage->settings()->overScrollColor());
    13111250            clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
     1251        }
    13121252    }
    13131253}
     
    14271367                blitCheckered = true;
    14281368#endif
    1429                 checkerWindow(dstRect, checkeredRects.at(i).location(), transformation.a());
     1369                fillWindow(BlackBerry::Platform::Graphics::CheckerboardPattern,
     1370                    dstRect, checkeredRects.at(i).location(), transformation.a());
    14301371            }
    14311372        }
     
    14861427                blitCheckered = true;
    14871428#endif
    1488                 checkerWindow(dirtyRectT, contentsOrigin, transformation.a());
     1429                fillWindow(BlackBerry::Platform::Graphics::CheckerboardPattern,
     1430                    dirtyRectT, contentsOrigin, transformation.a());
    14891431            }
    14901432
     
    25082450}
    25092451
    2510 void BackingStorePrivate::checkerWindow(const Platform::IntRect& dstRect,
    2511                                         const Platform::IntPoint& contentsOrigin,
    2512                                         double contentsScale)
     2452void BackingStorePrivate::fillWindow(Platform::Graphics::FillPattern pattern,
     2453                                     const Platform::IntRect& dstRect,
     2454                                     const Platform::IntPoint& contentsOrigin,
     2455                                     double contentsScale)
    25132456{
    25142457    ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread());
     
    25202463    ASSERT(dstBuffer);
    25212464    if (!dstBuffer)
    2522         BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't checkerWindow");
    2523 
    2524     Color color(m_webPage->settings()->backgroundColor());
    2525     unsigned char alpha = color.alpha();
    2526     BlackBerry::Platform::Graphics::checkerBuffer(dstBuffer, dstRect, contentsOrigin, contentsScale, alpha);
     2465        BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't fillWindow");
     2466
     2467    BlackBerry::Platform::Graphics::fillBuffer(dstBuffer, pattern, dstRect, contentsOrigin, contentsScale);
    25272468}
    25282469
  • trunk/Source/WebKit/blackberry/Api/BackingStore_p.h

    r119718 r122587  
    308308
    309309    void blitToWindow(const Platform::IntRect& dstRect, const BlackBerry::Platform::Graphics::Buffer* srcBuffer, const Platform::IntRect& srcRect, bool blend, unsigned char globalAlpha);
    310     void checkerWindow(const Platform::IntRect& dstRect, const Platform::IntPoint& contentsOrigin, double contentsScale);
     310    void fillWindow(Platform::Graphics::FillPattern, const Platform::IntRect& dstRect, const Platform::IntPoint& contentsOrigin, double contentsScale);
    311311
    312312    void invalidateWindow();
     
    335335    BlackBerry::Platform::IntSize surfaceSize() const;
    336336    BlackBerry::Platform::Graphics::Buffer* buffer() const;
    337 
    338     bool ensureOverScrollImage();
    339337
    340338    static WebPage* s_currentBackingStoreOwner;
     
    379377#endif
    380378
    381     static Platform::Graphics::Buffer* s_overScrollImage;
    382     static std::string s_overScrollImagePath;
    383     static Platform::IntSize s_overScrollImageSize;
    384 
    385379protected:
    386380    virtual ~BackingStorePrivate();
  • trunk/Source/WebKit/blackberry/Api/WebSettings.cpp

    r121555 r122587  
    4949DEFINE_STATIC_LOCAL(String, BlackBerryLinksHandledExternallyEnabled, ("BlackBerryLinksHandledExternallyEnabled"));
    5050DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, ("BlackBerryMaxPluginInstances"));
    51 DEFINE_STATIC_LOCAL(String, BlackBerryOverZoomColor, ("BlackBerryOverZoomColor"));
    52 DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollImagePath, ("BlackBerryOverScrollImagePath"));
     51DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollColor, ("BlackBerryOverScrollColor"));
     52DEFINE_STATIC_LOCAL(String, BlackBerryEnableDefaultOverScrollBackground, ("BlackBerryEnableDefaultOverScrollBackground"));
    5353DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, ("BlackBerryRenderAnimationsOnScrollOrZoomEnabled"));
    5454DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, ("BlackBerryScrollbarsEnabled"));
     
    165165    settings->m_private->setDouble(BlackBerryInitialScale, -1);
    166166    settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1);
    167     settings->m_private->setUnsigned(BlackBerryOverZoomColor, WebCore::Color::white);
    168     settings->m_private->setString(BlackBerryOverScrollImagePath, "");
     167    settings->m_private->setUnsigned(BlackBerryOverScrollColor, WebCore::Color::white);
     168    settings->m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, true);
    169169    settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true);
    170170
     
    708708}
    709709
    710 unsigned WebSettings::overZoomColor() const
    711 {
    712     return m_private->getUnsigned(BlackBerryOverZoomColor);
    713 }
    714 
    715 void WebSettings::setOverZoomColor(unsigned color)
    716 {
    717     m_private->setUnsigned(BlackBerryOverZoomColor, color);
    718 }
    719 
    720 WebString WebSettings::overScrollImagePath() const
    721 {
    722     return m_private->getString(BlackBerryOverScrollImagePath);
    723 }
    724 
    725 void WebSettings::setOverScrollImagePath(const char* path)
    726 {
    727     m_private->setString(BlackBerryOverScrollImagePath, path);
     710unsigned WebSettings::overScrollColor() const
     711{
     712    return m_private->getUnsigned(BlackBerryOverScrollColor);
     713}
     714
     715void WebSettings::setOverScrollColor(unsigned color)
     716{
     717    m_private->setUnsigned(BlackBerryOverScrollColor, color);
     718}
     719
     720bool WebSettings::isEnableDefaultOverScrollBackground() const
     721{
     722    return m_private->getBoolean(BlackBerryEnableDefaultOverScrollBackground);
     723}
     724
     725void WebSettings::setEnableDefaultOverScrollBackground(bool enabled)
     726{
     727    m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, enabled);
    728728}
    729729
  • trunk/Source/WebKit/blackberry/Api/WebSettings.h

    r121555 r122587  
    199199    void setShouldRenderAnimationsOnScrollOrZoom(bool enable);
    200200
    201     unsigned overZoomColor() const;
    202     void setOverZoomColor(unsigned);
    203 
    204     WebString overScrollImagePath() const;
    205     void setOverScrollImagePath(const char*);
     201    unsigned overScrollColor() const;
     202    void setOverScrollColor(unsigned);
     203
     204    bool isEnableDefaultOverScrollBackground() const;
     205    void setEnableDefaultOverScrollBackground(bool);
    206206
    207207    unsigned backgroundColor() const;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r122573 r122587  
     12012-07-13  Jakob Petsovits  <jpetsovits@rim.com>
     2
     3        [BlackBerry] Use fillBuffer() instead of a user-defined background image.
     4        https://bugs.webkit.org/show_bug.cgi?id=91180
     5        RIM PR 171458
     6
     7        Reviewed by Rob Buis.
     8        Internally reviewed by Andrew Lo.
     9
     10        By using Platform::Graphics::fillBuffer() to fill the
     11        overscroll area, we save graphics memory for the buffer
     12        that the background image was occupying.
     13
     14        Also adapt checkerboard drawing as it is now done using
     15        fillBuffer() which replaces checkerBuffer().
     16
     17        In the same go, use the opportunity of the WebSettings
     18        API change to make it more consistent, renaming the
     19        OverZoomColor setting to OverScrollColor.
     20
     21        * Api/BackingStore.cpp:
     22        (WebKit):
     23        (BlackBerry::WebKit::BackingStorePrivate::paintDefaultBackground):
     24        (BlackBerry::WebKit::BackingStorePrivate::blitContents):
     25        (BlackBerry::WebKit::BackingStorePrivate::fillWindow):
     26        * Api/BackingStore_p.h:
     27        (BackingStorePrivate):
     28        * Api/WebSettings.cpp:
     29        (WebKit):
     30        (BlackBerry::WebKit::WebSettings::standardSettings):
     31        (BlackBerry::WebKit::WebSettings::overScrollColor):
     32        (BlackBerry::WebKit::WebSettings::setOverScrollColor):
     33        (BlackBerry::WebKit::WebSettings::isEnableDefaultOverScrollBackground):
     34        (BlackBerry::WebKit::WebSettings::setEnableDefaultOverScrollBackground):
     35        * Api/WebSettings.h:
     36
    1372012-07-13  Joshua Netterfield  <jnetterfield@rim.com>
    238
Note: See TracChangeset for help on using the changeset viewer.