Title: [116199] trunk/Source/WebKit/blackberry
Revision
116199
Author
[email protected]
Date
2012-05-04 18:12:54 -0700 (Fri, 04 May 2012)

Log Message

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

Patch by Andrew Lo <[email protected]> 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/BackingStore.cpp (116198 => 116199)


--- trunk/Source/WebKit/blackberry/Api/BackingStore.cpp	2012-05-05 00:54:03 UTC (rev 116198)
+++ trunk/Source/WebKit/blackberry/Api/BackingStore.cpp	2012-05-05 01:12:54 UTC (rev 116199)
@@ -37,14 +37,19 @@
 #include "WebPage_p.h"
 #include "WebSettings.h"
 
+#include <BlackBerryPlatformClient.h>
 #include <BlackBerryPlatformExecutableMessage.h>
+#include <BlackBerryPlatformGraphics.h>
 #include <BlackBerryPlatformIntRectRegion.h>
 #include <BlackBerryPlatformLog.h>
 #include <BlackBerryPlatformMessage.h>
 #include <BlackBerryPlatformMessageClient.h>
 #include <BlackBerryPlatformScreen.h>
+#include <BlackBerryPlatformSettings.h>
 #include <BlackBerryPlatformWindow.h>
 
+#include <SkImageDecoder.h>
+
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
 #include <wtf/NotFound.h>
@@ -72,6 +77,8 @@
 
 const int s_renderTimerTimeout = 1.0;
 WebPage* BackingStorePrivate::s_currentBackingStoreOwner = 0;
+Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0;
+std::string BackingStorePrivate::s_overScrollImagePath;
 
 typedef std::pair<int, int> Divisor;
 typedef Vector<Divisor> DivisorList;
@@ -1191,6 +1198,57 @@
     }
 }
 
+bool BackingStorePrivate::ensureOverScrollImage()
+{
+    std::string path = m_webPage->settings()->overScrollImagePath().utf8();
+    if (path == "")
+        return false;
+
+    if (s_overScrollImage && path == s_overScrollImagePath)
+        return true;
+
+    std::string imagePath = Platform::Client::get()->getApplicationDirectory() + 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
+    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_overScrollImagePath = path;
+
+    return true;
+}
+
 void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& contents,
                                                  const WebCore::TransformationMatrix& transformation,
                                                  bool flush)
@@ -1199,6 +1257,7 @@
     Platform::IntPoint origin = contents.location();
     Platform::IntRect contentsClipped = contents;
 
+
     // We have to paint the default background in the case of overzoom and
     // make sure it is invalidated.
     Color color(m_webPage->settings()->overZoomColor());
@@ -1219,7 +1278,10 @@
             overScrollRect.intersect(Platform::IntRect(Platform::IntPoint(0, 0), surfaceSize()));
         }
 
-        clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
+        if (ensureOverScrollImage())
+            blitToWindow(overScrollRect, s_overScrollImage, overScrollRect, false, 255);
+        else
+            clearWindow(overScrollRect, color.red(), color.green(), color.blue(), color.alpha());
     }
 }
 

Modified: trunk/Source/WebKit/blackberry/Api/BackingStore_p.h (116198 => 116199)


--- trunk/Source/WebKit/blackberry/Api/BackingStore_p.h	2012-05-05 00:54:03 UTC (rev 116198)
+++ trunk/Source/WebKit/blackberry/Api/BackingStore_p.h	2012-05-05 01:12:54 UTC (rev 116199)
@@ -326,6 +326,8 @@
     BlackBerry::Platform::IntSize surfaceSize() const;
     BlackBerry::Platform::Graphics::Buffer* buffer() const;
 
+    bool ensureOverScrollImage();
+
     static WebPage* s_currentBackingStoreOwner;
 
     bool m_suspendScreenUpdates;
@@ -367,6 +369,9 @@
     bool m_isDirectRenderingAnimationMessageScheduled;
 #endif
 
+    static Platform::Graphics::Buffer* s_overScrollImage;
+    static std::string s_overScrollImagePath;
+
 protected:
     virtual ~BackingStorePrivate();
 };

Modified: trunk/Source/WebKit/blackberry/Api/WebSettings.cpp (116198 => 116199)


--- trunk/Source/WebKit/blackberry/Api/WebSettings.cpp	2012-05-05 00:54:03 UTC (rev 116198)
+++ trunk/Source/WebKit/blackberry/Api/WebSettings.cpp	2012-05-05 01:12:54 UTC (rev 116199)
@@ -44,6 +44,7 @@
 DEFINE_STATIC_LOCAL(String, BlackBerryLinksHandledExternallyEnabled, ("BlackBerryLinksHandledExternallyEnabled"));
 DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, ("BlackBerryMaxPluginInstances"));
 DEFINE_STATIC_LOCAL(String, BlackBerryOverZoomColor, ("BlackBerryOverZoomColor"));
+DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollImagePath, ("BlackBerryOverScrollImagePath"));
 DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, ("BlackBerryRenderAnimationsOnScrollOrZoomEnabled"));
 DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, ("BlackBerryScrollbarsEnabled"));
 DEFINE_STATIC_LOCAL(String, BlackBerryTextReflowMode, ("BlackBerryTextReflowMode"));
@@ -152,6 +153,7 @@
     settings->m_private->setDouble(BlackBerryInitialScale, -1);
     settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1);
     settings->m_private->setUnsigned(BlackBerryOverZoomColor, WebCore::Color::white);
+    settings->m_private->setString(BlackBerryOverScrollImagePath, "");
     settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true);
 
     // FIXME: We should detect whether we are embedded in a browser or an email client and default to TextReflowEnabledOnlyForBlockZoom and TextReflowEnabled, respectively.
@@ -661,6 +663,16 @@
     m_private->setUnsigned(BlackBerryOverZoomColor, color);
 }
 
+WebString WebSettings::overScrollImagePath() const
+{
+    return m_private->getString(BlackBerryOverScrollImagePath);
+}
+
+void WebSettings::setOverScrollImagePath(const char* path)
+{
+    m_private->setString(BlackBerryOverScrollImagePath, path);
+}
+
 unsigned WebSettings::backgroundColor() const
 {
     return m_private->getUnsigned(BlackBerryBackgroundColor);

Modified: trunk/Source/WebKit/blackberry/Api/WebSettings.h (116198 => 116199)


--- trunk/Source/WebKit/blackberry/Api/WebSettings.h	2012-05-05 00:54:03 UTC (rev 116198)
+++ trunk/Source/WebKit/blackberry/Api/WebSettings.h	2012-05-05 01:12:54 UTC (rev 116199)
@@ -193,6 +193,9 @@
     unsigned overZoomColor() const;
     void setOverZoomColor(unsigned);
 
+    WebString overScrollImagePath() const;
+    void setOverScrollImagePath(const char*);
+
     unsigned backgroundColor() const;
     void setBackgroundColor(unsigned);
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (116198 => 116199)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-05 00:54:03 UTC (rev 116198)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-05 01:12:54 UTC (rev 116199)
@@ -1,3 +1,26 @@
+2012-05-04  Andrew Lo  <[email protected]>
+
+        [Blackberry] Implement over-scroll background image
+        https://bugs.webkit.org/show_bug.cgi?id=85538
+
+        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:
+
 2012-05-04  Rob Buis  <[email protected]>
 
         [BlackBerry] Rendering bmp file as text file when Content-Type:image/x-ms-bmp from apache web server.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to