Changeset 116199 in webkit
- Timestamp:
- May 4, 2012 6:12:54 PM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/Api/BackingStore.cpp
r115289 r116199 38 38 #include "WebSettings.h" 39 39 40 #include <BlackBerryPlatformClient.h> 40 41 #include <BlackBerryPlatformExecutableMessage.h> 42 #include <BlackBerryPlatformGraphics.h> 41 43 #include <BlackBerryPlatformIntRectRegion.h> 42 44 #include <BlackBerryPlatformLog.h> … … 44 46 #include <BlackBerryPlatformMessageClient.h> 45 47 #include <BlackBerryPlatformScreen.h> 48 #include <BlackBerryPlatformSettings.h> 46 49 #include <BlackBerryPlatformWindow.h> 50 51 #include <SkImageDecoder.h> 47 52 48 53 #include <wtf/CurrentTime.h> … … 73 78 const int s_renderTimerTimeout = 1.0; 74 79 WebPage* BackingStorePrivate::s_currentBackingStoreOwner = 0; 80 Platform::Graphics::Buffer* BackingStorePrivate::s_overScrollImage = 0; 81 std::string BackingStorePrivate::s_overScrollImagePath; 75 82 76 83 typedef std::pair<int, int> Divisor; … … 1192 1199 } 1193 1200 1201 bool 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 1194 1252 void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& contents, 1195 1253 const WebCore::TransformationMatrix& transformation, … … 1199 1257 Platform::IntPoint origin = contents.location(); 1200 1258 Platform::IntRect contentsClipped = contents; 1259 1201 1260 1202 1261 // We have to paint the default background in the case of overzoom and … … 1220 1279 } 1221 1280 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()); 1223 1285 } 1224 1286 } -
trunk/Source/WebKit/blackberry/Api/BackingStore_p.h
r115289 r116199 327 327 BlackBerry::Platform::Graphics::Buffer* buffer() const; 328 328 329 bool ensureOverScrollImage(); 330 329 331 static WebPage* s_currentBackingStoreOwner; 330 332 … … 368 370 #endif 369 371 372 static Platform::Graphics::Buffer* s_overScrollImage; 373 static std::string s_overScrollImagePath; 374 370 375 protected: 371 376 virtual ~BackingStorePrivate(); -
trunk/Source/WebKit/blackberry/Api/WebSettings.cpp
r116145 r116199 45 45 DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, ("BlackBerryMaxPluginInstances")); 46 46 DEFINE_STATIC_LOCAL(String, BlackBerryOverZoomColor, ("BlackBerryOverZoomColor")); 47 DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollImagePath, ("BlackBerryOverScrollImagePath")); 47 48 DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, ("BlackBerryRenderAnimationsOnScrollOrZoomEnabled")); 48 49 DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, ("BlackBerryScrollbarsEnabled")); … … 153 154 settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1); 154 155 settings->m_private->setUnsigned(BlackBerryOverZoomColor, WebCore::Color::white); 156 settings->m_private->setString(BlackBerryOverScrollImagePath, ""); 155 157 settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true); 156 158 … … 662 664 } 663 665 666 WebString WebSettings::overScrollImagePath() const 667 { 668 return m_private->getString(BlackBerryOverScrollImagePath); 669 } 670 671 void WebSettings::setOverScrollImagePath(const char* path) 672 { 673 m_private->setString(BlackBerryOverScrollImagePath, path); 674 } 675 664 676 unsigned WebSettings::backgroundColor() const 665 677 { -
trunk/Source/WebKit/blackberry/Api/WebSettings.h
r116145 r116199 194 194 void setOverZoomColor(unsigned); 195 195 196 WebString overScrollImagePath() const; 197 void setOverScrollImagePath(const char*); 198 196 199 unsigned backgroundColor() const; 197 200 void setBackgroundColor(unsigned); -
trunk/Source/WebKit/blackberry/ChangeLog
r116145 r116199 1 2012-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 1 24 2012-05-04 Rob Buis <rbuis@rim.com> 2 25
Note: See TracChangeset
for help on using the changeset viewer.