diff options
Diffstat (limited to 'Source/WebKit')
90 files changed, 3490 insertions, 1042 deletions
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index eee8a48f6..9a2adea37 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,36 @@ +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * PlatformEfl.cmake: + +2012-07-20 Christophe Dumez <christophe.dumez@intel.com> + + [EFL] Proxy configuration should honor the no_proxy environment variable + https://bugs.webkit.org/show_bug.cgi?id=91747 + + Reviewed by Kenneth Rohde Christiansen. + + Add WebCore/platform/network/soup to INCLUDE paths. + + * PlatformEfl.cmake: + +2012-07-18 Yong Li <yoli@rim.com> + + [BlackBerry] Move about: URL handling out of WebCore + https://bugs.webkit.org/show_bug.cgi?id=91541 + + Reviewed by Rob Buis. + + AboutData.cpp is moved from WebCoreSupport to WebKitSupport. + + * PlatformBlackBerry.cmake: + 2012-07-18 Thiago Marcos P. Santos <thiago.santos@intel.com> [CMake] Make gtest a shared library diff --git a/Source/WebKit/PlatformBlackBerry.cmake b/Source/WebKit/PlatformBlackBerry.cmake index 0c2f18336..05aaed8a9 100644 --- a/Source/WebKit/PlatformBlackBerry.cmake +++ b/Source/WebKit/PlatformBlackBerry.cmake @@ -68,7 +68,6 @@ LIST(APPEND WebKit_SOURCES blackberry/Api/WebSettings.cpp blackberry/Api/WebString.cpp blackberry/Api/WebViewportArguments.cpp - blackberry/WebCoreSupport/AboutData.cpp blackberry/WebCoreSupport/AutofillManager.cpp blackberry/WebCoreSupport/CacheClientBlackBerry.cpp blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp @@ -92,6 +91,7 @@ LIST(APPEND WebKit_SOURCES blackberry/WebCoreSupport/PagePopupBlackBerry.cpp blackberry/WebCoreSupport/SelectPopupClient.cpp blackberry/WebCoreSupport/DatePickerClient.cpp + blackberry/WebKitSupport/AboutData.cpp blackberry/WebKitSupport/BackingStoreCompositingSurface.cpp blackberry/WebKitSupport/BackingStoreTile.cpp blackberry/WebKitSupport/BackingStoreClient.cpp diff --git a/Source/WebKit/PlatformEfl.cmake b/Source/WebKit/PlatformEfl.cmake index c6243da30..6cdc9b775 100644 --- a/Source/WebKit/PlatformEfl.cmake +++ b/Source/WebKit/PlatformEfl.cmake @@ -13,6 +13,7 @@ LIST(APPEND WebKit_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/efl" "${WEBCORE_DIR}/platform/graphics/cairo" "${WEBCORE_DIR}/platform/graphics/efl" + "${WEBCORE_DIR}/platform/network/soup" ${CAIRO_INCLUDE_DIRS} ${ECORE_X_INCLUDE_DIRS} ${EDJE_INCLUDE_DIRS} @@ -171,8 +172,8 @@ LIST(APPEND WebKit_LIBRARIES ) SET(WebKit_THEME_DEFINITION "") -IF (ENABLE_PROGRESS_TAG) - LIST(APPEND WebKit_THEME_DEFINITION "-DENABLE_PROGRESS_TAG") +IF (ENABLE_PROGRESS_ELEMENT) + LIST(APPEND WebKit_THEME_DEFINITION "-DENABLE_PROGRESS_ELEMENT") ENDIF () FILE(MAKE_DIRECTORY ${THEME_BINARY_DIR}) diff --git a/Source/WebKit/blackberry/Api/BackingStore.cpp b/Source/WebKit/blackberry/Api/BackingStore.cpp index 61fddfa16..78102c179 100644 --- a/Source/WebKit/blackberry/Api/BackingStore.cpp +++ b/Source/WebKit/blackberry/Api/BackingStore.cpp @@ -196,8 +196,9 @@ Platform::IntSize BackingStoreGeometry::backingStoreSize() const } BackingStorePrivate::BackingStorePrivate() - : m_suspendScreenUpdates(false) - , m_suspendBackingStoreUpdates(false) + : m_suspendScreenUpdates(0) + , m_suspendBackingStoreUpdates(0) + , m_resumeOperation(BackingStore::None) , m_suspendRenderJobs(false) , m_suspendRegularRenderJobs(false) , m_isScrollingOrZooming(false) @@ -279,12 +280,18 @@ bool BackingStorePrivate::isOpenGLCompositing() const void BackingStorePrivate::suspendScreenAndBackingStoreUpdates() { - m_suspendBackingStoreUpdates = true; + if (m_suspendScreenUpdates) { + BlackBerry::Platform::log(BlackBerry::Platform::LogLevelInfo, + "Screen and backingstore already suspended, increasing suspend counter."); + } + + ++m_suspendBackingStoreUpdates; // Make sure the user interface thread gets the message before we proceed // because blitContents can be called from this thread and it must honor // this flag. - m_suspendScreenUpdates = true; + ++m_suspendScreenUpdates; + BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage(); #if USE(ACCELERATED_COMPOSITING) @@ -294,14 +301,42 @@ void BackingStorePrivate::suspendScreenAndBackingStoreUpdates() void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::ResumeUpdateOperation op) { - m_suspendBackingStoreUpdates = false; + ASSERT(m_suspendScreenUpdates); + ASSERT(m_suspendBackingStoreUpdates); + + // Both variables are similar except for the timing of setting them. + ASSERT(m_suspendScreenUpdates == m_suspendBackingStoreUpdates); + + if (!m_suspendScreenUpdates || !m_suspendBackingStoreUpdates) { + BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical, + "Call mismatch: Screen and backingstore haven't been suspended, therefore won't resume!"); + return; + } + + // Out of all nested resume calls, resume with the maximum-impact operation. + if (op == BackingStore::RenderAndBlit + || (m_resumeOperation == BackingStore::None && op == BackingStore::Blit)) + m_resumeOperation = op; + + if (m_suspendScreenUpdates >= 2 && m_suspendBackingStoreUpdates >= 2) { // we're still suspended + BlackBerry::Platform::log(BlackBerry::Platform::LogLevelInfo, + "Screen and backingstore still suspended, decreasing suspend counter."); + --m_suspendBackingStoreUpdates; + --m_suspendScreenUpdates; + return; + } + + --m_suspendBackingStoreUpdates; + + op = m_resumeOperation; + m_resumeOperation = BackingStore::None; #if USE(ACCELERATED_COMPOSITING) if (op != BackingStore::None) { if (isOpenGLCompositing() && !isActive()) { m_webPage->d->setCompositorDrawsRootLayer(true); m_webPage->d->setNeedsOneShotDrawingSynchronization(); - m_suspendScreenUpdates = false; + --m_suspendScreenUpdates; BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage(); return; } @@ -322,7 +357,7 @@ void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::Resum // Make sure the user interface thread gets the message before we proceed // because blitContents can be called from the user interface thread and // it must honor this flag. - m_suspendScreenUpdates = false; + --m_suspendScreenUpdates; BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage(); // Do some blitting if necessary. @@ -1567,7 +1602,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect, for (unsigned int i = 0; i < blittedTiles.size(); ++i) blittedTiles[i]->setBlitGeneration(m_blitGeneration); - clock_gettime(CLOCK_REALTIME, &m_currentBlitEnd); + clock_gettime(CLOCK_MONOTONIC, &m_currentBlitEnd); m_currentBlitEnd.tv_nsec += 30 * 1000 * 1000; if (m_currentBlitEnd.tv_nsec >= 1000000000L) { m_currentBlitEnd.tv_sec += 1; @@ -2179,6 +2214,10 @@ void BackingStorePrivate::createSurfaces() swapState(); createVisibleTileBufferForWebPage(m_webPage->d); + + // Don't try to blit to screen unless we have a buffer. + if (!buffer()) + suspendScreenAndBackingStoreUpdates(); } void BackingStorePrivate::createVisibleTileBuffer() diff --git a/Source/WebKit/blackberry/Api/BackingStore_p.h b/Source/WebKit/blackberry/Api/BackingStore_p.h index e140064e2..50feb041c 100644 --- a/Source/WebKit/blackberry/Api/BackingStore_p.h +++ b/Source/WebKit/blackberry/Api/BackingStore_p.h @@ -336,8 +336,9 @@ public: static WebPage* s_currentBackingStoreOwner; - bool m_suspendScreenUpdates; - bool m_suspendBackingStoreUpdates; + unsigned m_suspendScreenUpdates; + unsigned m_suspendBackingStoreUpdates; + BackingStore::ResumeUpdateOperation m_resumeOperation; bool m_suspendRenderJobs; bool m_suspendRegularRenderJobs; diff --git a/Source/WebKit/blackberry/Api/WebPage.cpp b/Source/WebKit/blackberry/Api/WebPage.cpp index 2e5098d37..b5686707f 100644 --- a/Source/WebKit/blackberry/Api/WebPage.cpp +++ b/Source/WebKit/blackberry/Api/WebPage.cpp @@ -19,6 +19,8 @@ #include "config.h" #include "WebPage.h" +#include "AboutData.h" +#include "AboutTemplate.html.cpp" #include "ApplicationCacheStorage.h" #include "AutofillManager.h" #include "BackForwardController.h" @@ -155,6 +157,8 @@ #include <BlackBerryPlatformMouseEvent.h> #include <BlackBerryPlatformScreen.h> #include <BlackBerryPlatformSettings.h> +#include <BlackBerryPlatformWebKitCredits.h> +#include <BuildInformation.h> #include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSContextRef.h> #include <JavaScriptCore/JSStringRef.h> @@ -615,6 +619,84 @@ private: } }; +bool WebPagePrivate::loadAbout(const char* aboutURL) +{ + if (strncasecmp(aboutURL, "about:", 6)) + return false; + + // First 6 chars are "about:". + String aboutWhat(aboutURL + 6); + + String result; + + if (equalIgnoringCase(aboutWhat, "credits")) { + result.append(writeHeader("Credits")); + result.append(String("<style> .about {padding:14px;} </style>")); + result.append(String(BlackBerry::Platform::WEBKITCREDITS)); + result.append(String("</body></html>")); + } else if (aboutWhat.startsWith("cache?query=", false)) { + BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get(); + ASSERT(client); + std::string key(aboutWhat.substring(12, aboutWhat.length() - 12).utf8().data()); // 12 is length of "cache?query=". + result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>")); + result.append(String(key.data())); + result.append(String("<hr>")); + result.append(String(client->generateHtmlFragmentForCacheHeaders(key).data())); + result.append(String("</body></html>")); + } else if (equalIgnoringCase(aboutWhat, "cache")) { + BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get(); + ASSERT(client); + result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>")); + result.append(String(client->generateHtmlFragmentForCacheKeys().data())); + result.append(String("</body></html>")); +#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD + } else if (equalIgnoringCase(aboutWhat, "cache/disable")) { + BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get(); + ASSERT(client); + client->setDiskCacheEnabled(false); + result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>Http disk cache is disabled.</body></html>")); + } else if (equalIgnoringCase(aboutWhat, "cache/enable")) { + BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get(); + ASSERT(client); + client->setDiskCacheEnabled(true); + result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>Http disk cache is enabled.</body></html>")); + } else if (equalIgnoringCase(aboutWhat, "cookie")) { + result.append(String("<html><head><title>BlackBerry Browser cookie information</title></head><body>")); + result.append(cookieManager().generateHtmlFragmentForCookies()); + result.append(String("</body></html>")); + } else if (equalIgnoringCase(aboutWhat, "version")) { + result.append(writeHeader("Version")); + result.append(String("<div class='box'><div class='box-title'>Build Time</div><br>")); + result.append(String(BlackBerry::Platform::BUILDTIME)); + result.append(String("</div><br><div style='font-size:10px;text-align:center;'>Also see the <A href='about:build'>build information</A>.</body></html>")); + } else if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "config")) { + result = configPage(); + } else if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "build")) { + result.append(writeHeader("Build")); + result.append(String("<div class='box'><div class='box-title'>Basic</div><table>")); + result.append(String("<tr><td>Built On: </td><td>")); + result.append(String(BlackBerry::Platform::BUILDCOMPUTER)); + result.append(String("</td></tr>")); + result.append(String("<tr><td>Build User: </td><td>")); + result.append(String(BlackBerry::Platform::BUILDUSER)); + result.append(String("</td></tr>")); + result.append(String("<tr><td>Build Time: </td><td>")); + result.append(String(BlackBerry::Platform::BUILDTIME)); + result.append(String("</table></div><br>")); + result.append(String(BlackBerry::Platform::BUILDINFO_WEBKIT)); + result.append(String(BlackBerry::Platform::BUILDINFO_PLATFORM)); + result.append(String(BlackBerry::Platform::BUILDINFO_LIBWEBVIEW)); + result.append(String("</body></html>")); + } else if (equalIgnoringCase(aboutWhat, "memory")) { + result = memoryPage(); +#endif + } else + return false; + + loadString(result.latin1().data(), aboutURL, "text/html"); + return true; +} + void WebPagePrivate::load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool forceDownload, const char* overrideContentType, const char* suggestedSaveName) { stopCurrentLoad(); @@ -665,6 +747,8 @@ void WebPagePrivate::load(const char* url, const char* networkToken, const char* void WebPage::load(const char* url, const char* networkToken, bool isInitial) { + if (d->loadAbout(url)) + return; d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false); } @@ -1174,8 +1258,6 @@ bool WebPagePrivate::shouldZoomAboutPoint(double scale, const FloatPoint&, bool *clampedScale = scale; if (currentScale() == scale) { - // Make sure backingstore updates resume from pinch zoom in the case where the final zoom level doesn't change. - m_backingStore->d->resumeScreenAndBackingStoreUpdates(BackingStore::None); m_client->zoomChanged(m_webPage->isMinZoomed(), m_webPage->isMaxZoomed(), !shouldZoomOnEscape(), currentScale()); return false; } @@ -1367,6 +1449,7 @@ void WebPagePrivate::unscheduleZoomAboutPoint() void WebPagePrivate::zoomAboutPointTimerFired(Timer<WebPagePrivate>*) { zoomAboutPoint(m_delayedZoomArguments.scale, m_delayedZoomArguments.anchor, m_delayedZoomArguments.enforceScaleClamping, m_delayedZoomArguments.forceRendering); + m_backingStore->d->resumeScreenAndBackingStoreUpdates(m_delayedZoomArguments.forceRendering ? BackingStore::RenderAndBlit : BackingStore::None); } void WebPagePrivate::setNeedsLayout() @@ -3076,20 +3159,25 @@ IntRect WebPagePrivate::blockZoomRectForNode(Node* node) clipToTransformedContentsRect(blockRect); #if DEBUG_BLOCK_ZOOM - // Re-paint the backingstore to screen to erase other annotations. - m_backingStore->d->resumeScreenAndBackingStoreUpdates(BackingStore::Blit); - - // Render a black square over the calculated block and a gray square over the original block for visual inspection. - originalRect = mapToTransformed(originalRect); - clipToTransformedContentsRect(originalRect); - IntRect renderRect = mapFromTransformedContentsToTransformedViewport(blockRect); - IntRect originalRenderRect = mapFromTransformedContentsToTransformedViewport(originalRect); - IntSize viewportSize = transformedViewportSize(); - renderRect.intersect(IntRect(0, 0, viewportSize.width(), viewportSize.height())); - originalRenderRect.intersect(IntRect(0, 0, viewportSize.width(), viewportSize.height())); - m_backingStore->d->clearWindow(renderRect, 0, 0, 0); - m_backingStore->d->clearWindow(originalRenderRect, 120, 120, 120); - m_backingStore->d->invalidateWindow(renderRect); + if (!m_backingStore->d->isSuspended()) { + // Re-paint the backingstore to screen to erase other annotations. + if (m_backingStore->d->shouldDirectRenderingToWindow()) + m_backingStore->d->renderVisibleContents(); + else + m_backingStore->d->blitVisibleContents(); + + // Render a black square over the calculated block and a gray square over the original block for visual inspection. + originalRect = mapToTransformed(originalRect); + clipToTransformedContentsRect(originalRect); + IntRect renderRect = mapFromTransformedContentsToTransformedViewport(blockRect); + IntRect originalRenderRect = mapFromTransformedContentsToTransformedViewport(originalRect); + IntSize viewportSize = transformedViewportSize(); + renderRect.intersect(IntRect(0, 0, viewportSize.width(), viewportSize.height())); + originalRenderRect.intersect(IntRect(0, 0, viewportSize.width(), viewportSize.height())); + m_backingStore->d->clearWindow(renderRect, 0, 0, 0); + m_backingStore->d->clearWindow(originalRenderRect, 120, 120, 120); + m_backingStore->d->invalidateWindow(renderRect); + } #endif return blockRect; @@ -5865,21 +5953,33 @@ void WebPagePrivate::setCompositor(PassRefPtr<WebPageCompositorPrivate> composit { using namespace BlackBerry::Platform; + // We depend on the current thread being the WebKit thread when it's not the Compositing thread. + // That seems extremely likely to be the case, but let's assert just to make sure. + ASSERT(webKitThreadMessageClient()->isCurrentThread()); + + if (m_backingStore->d->buffer()) + m_backingStore->d->suspendScreenAndBackingStoreUpdates(); + + // This method call always round-trips on the WebKit thread (see WebPageCompositor::WebPageCompositor() and ~WebPageCompositor()), + // and the compositing context must be set on the WebKit thread. How convenient! + if (compositingContext != EGL_NO_CONTEXT) + BlackBerry::Platform::Graphics::setCompositingContext(compositingContext); + // The m_compositor member has to be modified during a sync call for thread // safe access to m_compositor and its refcount. - if (!userInterfaceThreadMessageClient()->isCurrentThread()) { - // We depend on the current thread being the WebKit thread when it's not the Compositing thread. - // That seems extremely likely to be the case, but let's assert just to make sure. - ASSERT(webKitThreadMessageClient()->isCurrentThread()); + userInterfaceThreadMessageClient()->dispatchSyncMessage(createMethodCallMessage(&WebPagePrivate::setCompositorHelper, this, compositor, compositingContext)); - // This method call always round-trips on the WebKit thread (see WebPageCompositor::WebPageCompositor() and ~WebPageCompositor()), - // and the compositing context must be set on the WebKit thread. How convenient! - if (compositingContext != EGL_NO_CONTEXT) - BlackBerry::Platform::Graphics::setCompositingContext(compositingContext); + if (m_backingStore->d->buffer()) // the new compositor, if one was set + m_backingStore->d->resumeScreenAndBackingStoreUpdates(BackingStore::RenderAndBlit); +} - userInterfaceThreadMessageClient()->dispatchSyncMessage(createMethodCallMessage(&WebPagePrivate::setCompositor, this, compositor, compositingContext)); - return; - } +void WebPagePrivate::setCompositorHelper(PassRefPtr<WebPageCompositorPrivate> compositor, EGLContext compositingContext) +{ + using namespace BlackBerry::Platform; + + // The m_compositor member has to be modified during a sync call for thread + // safe access to m_compositor and its refcount. + ASSERT(userInterfaceThreadMessageClient()->isCurrentThread()); m_compositor = compositor; if (m_compositor) { diff --git a/Source/WebKit/blackberry/Api/WebPage_p.h b/Source/WebKit/blackberry/Api/WebPage_p.h index 005631e1b..b4ca9175b 100644 --- a/Source/WebKit/blackberry/Api/WebPage_p.h +++ b/Source/WebKit/blackberry/Api/WebPage_p.h @@ -97,6 +97,7 @@ public: bool handleMouseEvent(WebCore::PlatformMouseEvent&); bool handleWheelEvent(WebCore::PlatformWheelEvent&); + bool loadAbout(const char* aboutURL); void load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool forceDownload = false, const char* overrideContentType = "", const char* suggestedSaveName = ""); void loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL = 0); bool executeJavaScript(const char* script, JavaScriptDataType& returnType, WebString& returnValue); @@ -406,6 +407,7 @@ public: bool isAcceleratedCompositingActive() const { return m_compositor; } WebPageCompositorPrivate* compositor() const { return m_compositor.get(); } void setCompositor(PassRefPtr<WebPageCompositorPrivate>, EGLContext compositingContext); + void setCompositorHelper(PassRefPtr<WebPageCompositorPrivate>, EGLContext compositingContext); void setCompositorBackgroundColor(const WebCore::Color&); bool createCompositor(); void destroyCompositor(); diff --git a/Source/WebKit/blackberry/ChangeLog b/Source/WebKit/blackberry/ChangeLog index 351354a16..6d340d8e2 100644 --- a/Source/WebKit/blackberry/ChangeLog +++ b/Source/WebKit/blackberry/ChangeLog @@ -1,3 +1,178 @@ +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * WebCoreSupport/AboutDataEnableFeatures.in: + +2012-07-20 Jacky Jiang <zhajiang@rim.com> + + [BlackBerry] clock_gettime() in BackingStore.cpp should use CLOCK_MONOTONIC + https://bugs.webkit.org/show_bug.cgi?id=91898 + + Reviewed by Yong Li. + + PR: 181043 + Use CLOCK_MONOTONIC when we do expect a monotonic timer. + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::blitContents): + +2012-07-20 Crystal Zhang <haizhang@rim.com> + + [BlackBerry] Add Cancel button for Select popup + https://bugs.webkit.org/show_bug.cgi?id=91887 + + Reviewed by Yong Li. + + PR 177706 + + * WebCoreSupport/SelectPopupClient.cpp: + (WebCore::SelectPopupClient::generateHTML): + (WebCore::SelectPopupClient::setValueAndClosePopup): + +2012-07-19 Mary Wu <mary.wu@torchmobile.com.cn> + + [BlackBerry] Make sure to send favicon when go back/forward + https://bugs.webkit.org/show_bug.cgi?id=91808 + + Reviewed by George Staikos. + + When go back/forward, if the page was in page cache, it would have no chance + to send favicon. So we'll send it in commitLoad right after send the blank + icon. + RIM PR# 177495 + + * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: + (WebCore::FrameLoaderClientBlackBerry::dispatchDidCommitLoad): + +2012-07-19 Jakob Petsovits <jpetsovits@rim.com> + + [BlackBerry] Suspend when there's no target buffer until an external compositor is set + https://bugs.webkit.org/show_bug.cgi?id=91686 + RIM PR 174365 + + Reviewed by Antonio Gomes. + + If we don't have a client window (i.e. rendering to + GL directly) and a WebPageCompositor is only set + after a rendering operation, then we'll try to render + to BackingStorePrivate::buffer() which doesn't exist + at this point. That's bad, and gets us various + assertions and possibly worse. + + Fix it by starting in a screen-suspended state and only + resuming screen and backingstore once a compositor is + actually set. + + So, in effect, with this patch applied, the sequence + of events will look like this: + + 1) WebPage & BackingStore are initialize, neither window + nor compositor exists, therefore buffer() returns 0. + createSurface() therefore suspends screen and + backingstore. + 2) loadURL() or loadData() is called, web page is + fully loaded, however we don't try to render because + we're still suspended, still have no target buffer. + 3) A WebPageCompositor is being set from outside. + At the beginning of WebPage::setCompositor() we still + don't have a buffer() so there's nothing to suspend, + however, after the sync call to setCompositorHelper() + the compositor is set so buffer() will return a + nonzero value, causing us to resume at this point. + + Using the existence of a target buffer to determine + whether or not to enable rendering or keep it suspended + seems like a good idea, and the implementation (while + not quite perfect yet) is a step forward from before. + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::createSurfaces): + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::setCompositor): + (BlackBerry::WebKit::WebPagePrivate::setCompositorHelper): + * Api/WebPage_p.h: + (WebPagePrivate): + +2012-07-19 Jakob Petsovits <jpetsovits@rim.com> + + [BlackBerry] Allow nested suspend/resume screen & backingstore calls. + https://bugs.webkit.org/show_bug.cgi?id=91644 + RIM PR 174365 + + Reviewed by Adam Treat and Antonio Gomes. + + We expose suspendScreenAndBackingStoreUpdates() to the + outside API, but also use it internally when reacting + to a number of happenings, i.e. zooming, viewport resize, + resetting view state on Committed state or when restoring + it from previous pages, etc. + + These two can clash. For instance, if we get a suspend + call from outside that suspends us for app inactivity, + or we are told to suspend because the main target surface + is not available at the time, and while being suspended + we try to rotate, finish loading a page, the we'll end up + resuming operations even though we shouldn't. + + This patch changes the suspend flag to be a counter + instead, allowing nested suspend/resume calls and making + suspend/resume more robust this way. It also changes + several call sites to make sure suspend/resume calls are + paired up correctly. + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::BackingStorePrivate): + (BlackBerry::WebKit::BackingStorePrivate::suspendScreenAndBackingStoreUpdates): + (BlackBerry::WebKit::BackingStorePrivate::resumeScreenAndBackingStoreUpdates): + * Api/BackingStore_p.h: + (BackingStorePrivate): + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::shouldZoomAboutPoint): + (BlackBerry::WebKit::WebPagePrivate::zoomAboutPointTimerFired): + (BlackBerry::WebKit::WebPagePrivate::blockZoomRectForNode): + * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: + (WebCore::FrameLoaderClientBlackBerry::restoreViewState): + +2012-07-18 Yong Li <yoli@rim.com> + + [BlackBerry] Move about: URL handling out of WebCore + https://bugs.webkit.org/show_bug.cgi?id=91541 + + Reviewed by Rob Buis. + + Move about URL handling code to WebKit/blackberry. Now when WebPage is asked to load an about URL, + it directly calls loadString() with the generated source. + + Also move AboutData.h/cpp from WebCoreSupport to WebKitSupport and change their namespace from WebCore + to BlackBerry::WebKit. + + The change is very mechanical except "procss total memory usage" in about:memory now only accounts used + bytes and ignore free spaces in malloc. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::loadAbout): + (WebKit): + (BlackBerry::WebKit::WebPage::load): + * Api/WebPage_p.h: + (WebPagePrivate): + * WebKitSupport/AboutData.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/AboutData.cpp. + (WebKit): + (BlackBerry::WebKit::writeFeatures): + (BlackBerry::WebKit::numberToHTMLTr): + (BlackBerry::WebKit::bool): + (BlackBerry::WebKit::configPage): + (BlackBerry::WebKit::cacheTypeStatisticToHTMLTr): + (BlackBerry::WebKit::dumpJSCTypeCountSetToTableHTML): + (BlackBerry::WebKit::memoryPage): + * WebKitSupport/AboutData.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/AboutData.h. + (WebKit): + 2012-07-17 Jakob Petsovits <jpetsovits@rim.com> [BlackBerry] Remove unnecessary clearWindow() calls and the method itself diff --git a/Source/WebKit/blackberry/WebCoreSupport/AboutDataEnableFeatures.in b/Source/WebKit/blackberry/WebCoreSupport/AboutDataEnableFeatures.in index 250c3f959..012bf0600 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/AboutDataEnableFeatures.in +++ b/Source/WebKit/blackberry/WebCoreSupport/AboutDataEnableFeatures.in @@ -72,7 +72,7 @@ MEDIA_STATISTICS MEDIA_STREAM MEMORY_SAMPLER META_ALLOCATOR_PROFILE -METER_TAG +METER_ELEMENT MHTML MICRODATA MUTATION_OBSERVERS @@ -93,7 +93,7 @@ PLUGIN_PACKAGE_SIMPLE_HASH PLUGIN_PROCESS PLUGIN_PROXY_FOR_VIDEO POINTER_LOCK -PROGRESS_TAG +PROGRESS_ELEMENT PURGEABLE_MEMORY QUOTA REGEXP_TRACING diff --git a/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp b/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp index 9080272d7..982b13c3e 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp @@ -530,6 +530,9 @@ void FrameLoaderClientBlackBerry::dispatchDidCommitLoad() m_webPagePrivate->m_client->notifyLoadCommitted( originalUrl.characters(), originalUrl.length(), url.characters(), url.length(), token.characters(), token.length()); + HistoryItem* currentItem = m_frame->loader()->history()->currentItem(); + if (currentItem && currentItem->isInPageCache()) + dispatchDidReceiveIcon(); } } @@ -1067,12 +1070,12 @@ void FrameLoaderClientBlackBerry::restoreViewState() m_webPagePrivate->m_shouldReflowBlock = viewState.shouldReflowBlock; - // Will restore updates to backingstore guaranteed! - if (!m_webPagePrivate->zoomAboutPoint(scale, m_frame->view()->scrollPosition(), true /* enforceScaleClamping */, true /*forceRendering*/, true /*isRestoringZoomLevel*/)) { - // If we're already at that scale, then we should still force rendering since - // our scroll position changed. - m_webPagePrivate->m_backingStore->d->renderVisibleContents(); + bool didZoom = m_webPagePrivate->zoomAboutPoint(scale, m_frame->view()->scrollPosition(), true /* enforceScaleClamping */, true /*forceRendering*/, true /*isRestoringZoomLevel*/); + // If we're already at that scale, then we should still force rendering + // since our scroll position changed. + m_webPagePrivate->m_backingStore->d->resumeScreenAndBackingStoreUpdates(BackingStore::RenderAndBlit); + if (!didZoom) { // We need to notify the client of the scroll position and content size change(s) above even if we didn't scale. m_webPagePrivate->notifyTransformedContentsSizeChanged(); m_webPagePrivate->notifyTransformedScrollChanged(); diff --git a/Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp b/Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp index f068f1fda..ab362c492 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp @@ -115,6 +115,7 @@ void SelectPopupClient::generateHTML(bool multiple, int size, const ScopeArray<B source.append(", "); } source.append("] "); + source.append(", 'Cancel'"); // If multi-select, add OK button for confirm. if (m_multiple) source.append(", 'OK'"); @@ -145,7 +146,12 @@ String SelectPopupClient::htmlSource() void SelectPopupClient::setValueAndClosePopup(int, const String& stringValue) { ASSERT(m_element); - ASSERT(m_size == stringValue.length()); + + static const char* cancelValue = "-1"; + if (stringValue == cancelValue) { + closePopup(); + return; + } if (m_size > 0) { bool selecteds[m_size]; diff --git a/Source/WebKit/blackberry/WebCoreSupport/AboutData.cpp b/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp index 34499ba07..745157513 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/AboutData.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp @@ -18,8 +18,8 @@ #include "config.h" #include "AboutData.h" -#include "AboutTemplate.html.cpp" +#include "AboutTemplate.html.cpp" #include "CString.h" #include "JSDOMWindow.h" #include "MemoryCache.h" @@ -27,14 +27,17 @@ #include "SurfacePool.h" #include "WebKitVersion.h" -#include <process.h> #include <BlackBerryPlatformSettings.h> #include <heap/Heap.h> +#include <process.h> #include <runtime/JSGlobalData.h> #include <sys/stat.h> #include <sys/utsname.h> -namespace WebCore { +using namespace WebCore; + +namespace BlackBerry { +namespace WebKit { static String writeFeatures(const Vector<String>& trueList, const Vector<String>& falseList) { @@ -61,7 +64,7 @@ String configPage() { String page; #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD - page = writeHeader("Configuration"); + page = writeHeader("Configuration") + "<div class=\"box\"><div class=\"box-title\">Compiler Information</div><table class='fixed-table'><col width=75%><col width=25%>" #if COMPILER(MSVC) + "<tr><td>Microsoft Visual C++</td><td>MSVC</td></tr>" @@ -246,7 +249,7 @@ String memoryPage() page += "<div class='box'><div class='box-title'>Process memory usage summary</div><table class='fixed-table'><col width=75%><col width=25%>"; - page += numberToHTMLTr("Total memory usage (malloc + JSC)", mallocInfo.arena + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity()); + page += numberToHTMLTr("Total memory usage (malloc + JSC)", mallocInfo.usmblks + mallocInfo.uordblks + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity()); struct stat processInfo; if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo)) @@ -296,4 +299,5 @@ String memoryPage() return page; } -} +} // namespace WebKit +} // namespace BlackBerry diff --git a/Source/WebKit/blackberry/WebCoreSupport/AboutData.h b/Source/WebKit/blackberry/WebKitSupport/AboutData.h index ed977abb6..805054fd5 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/AboutData.h +++ b/Source/WebKit/blackberry/WebKitSupport/AboutData.h @@ -21,11 +21,13 @@ #include "PlatformString.h" -namespace WebCore { +namespace BlackBerry { +namespace WebKit { String configPage(); String memoryPage(); -} // namespace WebCore +} // namespace WebKit +} // namespace BlackBerry #endif // AboutData_h diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 1654cc675..a94bbd7b7 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,637 @@ +2012-07-22 Kent Tamura <tkent@chromium.org> + + [Chromium-Mac] Fix a build error. + + * DEPS: Add third_party/GTM. + +2012-07-23 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * features.gypi: + +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_DETAILS to ENABLE_DETAILS_ELEMENT + https://bugs.webkit.org/show_bug.cgi?id=91928 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * features.gypi: + +2012-07-21 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-07-20 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_DATALIST to ENABLE_DATALIST_ELEMENT + https://bugs.webkit.org/show_bug.cgi?id=91846 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * features.gypi: + * src/WebInputElement.cpp: + (WebKit::WebInputElement::dataListOptions): + +2012-07-20 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Simplify backend interface classes + https://bugs.webkit.org/show_bug.cgi?id=91901 + + Reviewed by Tony Chang. + + Remove unnecessary method stubs from proxy class. + + * src/IDBTransactionBackendProxy.cpp: + * src/IDBTransactionBackendProxy.h: + (IDBTransactionBackendProxy): + +2012-07-20 Scott Graham <scottmg@chromium.org> + + Add windows native versions of bison, flex and gperf. + + Reviewed by Tony Chang. + + * DEPS: + +2012-07-20 David Grogan <dgrogan@chromium.org> + + IndexedDB: Include intVersion when converting between WebCore and WebKit IDBMetadata types + https://bugs.webkit.org/show_bug.cgi?id=91414 + + Reviewed by Adam Barth. + + * src/AssertMatchingEnums.cpp: + * src/WebIDBMetadata.cpp: + (WebKit::WebIDBMetadata::WebIDBMetadata): + (WebKit::WebIDBMetadata::operator IDBDatabaseMetadata): + +2012-07-20 Robert Sesek <rsesek@chromium.org> + + [chromium][Mac] Switch the MACOSX_DEPLOYMENT_TARGET to 10.6 + https://bugs.webkit.org/show_bug.cgi?id=91752 + + Reviewed by Eric Seidel. + + Use 10.6 NSScreen/NSColorSpace APIs to determine if the screen is + monochrome rather than comparing against deprecated colorspace names. + + * src/mac/WebScreenInfoFactory.mm: + (WebKit::WebScreenInfoFactory::screenInfo): + +2012-07-20 Daniel Murphy <dmurph@chromium.org> + + Introduce WebViewBenchmarkSupport for performance experiments on a real WebView + https://bugs.webkit.org/show_bug.cgi?id=88271 + + Reviewed by Darin Fisher. + + * WebKit.gyp: + * public/WebView.h: + (WebKit): + (WebView): + (WebKit::WebView::benchmarkSupport): + * public/WebViewBenchmarkSupport.h: Added. + (WebKit): + (WebViewBenchmarkSupport): + (PaintClient): + (WebKit::WebViewBenchmarkSupport::PaintClient::willPaint): + (WebKit::WebViewBenchmarkSupport::PaintClient::didPaint): + (WebKit::WebViewBenchmarkSupport::PaintClient::~PaintClient): + (WebKit::WebViewBenchmarkSupport::~WebViewBenchmarkSupport): + * src/WebViewBenchmarkSupportImpl.cpp: Added. + (WebKit): + (WebKit::WebViewBenchmarkSupportImpl::paintLayer): + (WebKit::WebViewBenchmarkSupportImpl::acceleratedPaintUnclipped): + (WebKit::WebViewBenchmarkSupportImpl::softwarePaint): + (WebKit::WebViewBenchmarkSupportImpl::paint): + * src/WebViewBenchmarkSupportImpl.h: Added. + (WebCore): + (WebKit): + (WebViewBenchmarkSupportImpl): + (WebKit::WebViewBenchmarkSupportImpl::WebViewBenchmarkSupportImpl): + (WebKit::WebViewBenchmarkSupportImpl::~WebViewBenchmarkSupportImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + (WebKit::WebViewImpl::benchmarkSupport): + (WebKit): + (WebKit::WebViewImpl::rootGraphicsLayer): + * src/WebViewImpl.h: + (WebKit): + (WebViewImpl): + +2012-07-20 Han Shen <shenhan@google.com> + + [Chromium] Compilation fails under gcc 4.7 + https://bugs.webkit.org/show_bug.cgi?id=90227 + + Reviewed by Tony Chang. + + Disable warnings about c++0x compatibility in gcc newer than 4.6. + + * WebKit.gyp: + * WebKitUnitTests.gyp: + +2012-07-20 Adam Barth <abarth@webkit.org> + + [Chromium] Add WebView::zoomToFindInPageRect for Android + https://bugs.webkit.org/show_bug.cgi?id=91801 + + Reviewed by Tony Chang. + + On Android, when you find in page, we scale the viewport to reveal what + you've found (because the screen is small). This function instructs the + WebView to zoom to display a given rect. + + * public/WebView.h: + (WebView): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::animateZoomAroundPoint): + - This function is a bit more general than necessary for this patch + because it is also used in other cases for animating a zoom + around a given point (e.g., double-tap to zoom). These uses will + be upstreamed in later patches. + (WebKit::WebViewImpl::zoomToFindInPageRect): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-07-19 Luke Macpherson <macpherson@chromium.org> + + Enable CSS variables compile time flag in Chrome. + https://bugs.webkit.org/show_bug.cgi?id=91708 + + Reviewed by Dimitri Glazkov. + + Flips the ENABLE_CSS_VARIABLES compile flag on for Chrome. There is also a run-time flag that is off by default, + so this should not have a user visible effect other than making the variables runtime flag visible at chrome://flags/ + + * features.gypi: + +2012-07-19 Wei James <james.wei@intel.com> + + enable Web Audio for chromium android port + https://bugs.webkit.org/show_bug.cgi?id=89428 + + Reviewed by Kenneth Russell. + + * features.gypi: + +2012-07-19 Adam Barth <abarth@webkit.org> + + [Chromium] Support external autofill popups + https://bugs.webkit.org/show_bug.cgi?id=91651 + + Reviewed by Darin Fisher. + + This looks like the last piece needed to support external autofill + popups. This function just lets the embedder select an index + (presumably because the user picked an index from the external autofill + popup). + + * public/WebView.h: + (WebView): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::selectAutofillSuggestionAtIndex): + (WebKit): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-07-19 Zeev Lieber <zlieber@chromium.org> + + [Chromium] Textures drawn during occlusion are incorrectly re-used when unoccluded. + https://bugs.webkit.org/show_bug.cgi?id=91537 + + Reviewed by Adrienne Walker. + + Added unit tests to test texture caching with clipping and + occlusion. Removed some minor code duplication when initializing + layers for various scenarios. + + MockCCQuadCuller can now implement CCQuadSink. + + * tests/CCLayerTreeHostImplTest.cpp: + * tests/CCQuadCullerTest.cpp: + * tests/MockCCQuadCuller.h: + (WebCore::MockCCQuadCuller::MockCCQuadCuller): + +2012-07-19 Adam Barth <abarth@webkit.org> + + [Chromium] WebView is missing isSelectionEditable and backgroundColor which are used by chromium-android + https://bugs.webkit.org/show_bug.cgi?id=91671 + + Reviewed by Darin Fisher. + + I haven't studied what these APIs are used for downstream, but they + seem harmless enough. + + * public/WebView.h: + (WebView): + * public/WebWidget.h: + (WebWidget): + (WebKit::WebWidget::backgroundColor): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::isSelectionEditable): + (WebKit): + (WebKit::WebViewImpl::backgroundColor): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-07-19 Andrew Scherkus <scherkus@chromium.org> + + [chromium] Move WebAudioSourceProvider destructor from public to protected + https://bugs.webkit.org/show_bug.cgi?id=91669 + + Reviewed by Darin Fisher. + + The lifetime of a WebAudioSourceProvider is managed by the implementor + and should never be deallocted by WebKit. + + * public/WebAudioSourceProvider.h: + (WebAudioSourceProvider): + +2012-07-19 Tony Chang <tony@chromium.org> + + Unreviewed, rolling out r123036. + http://trac.webkit.org/changeset/123036 + https://bugs.webkit.org/show_bug.cgi?id=91555 + + Triggers some DCHECKs in Chromium browser_tests + + * public/WebTextInputType.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::textInputType): + +2012-07-19 Joshua Bell <jsbell@chromium.org> + + Roll out r121610 and r122487 which may have been causing flaky crashes + https://bugs.webkit.org/show_bug.cgi?id=91637 + + Reviewed by Kentaro Hara. + + Flaky crashes started in random tests following r121610. It's not clear + that r121610 is to blame, but we'd like to prove or disprove it. + If this doesn't resolve the crashes, this patch should be rolled out. + + * src/WebBindings.cpp: + (WebKit::getRangeImpl): + (WebKit::getElementImpl): + (WebKit::getArrayBufferImpl): + (WebKit::getArrayBufferViewImpl): + (WebKit::WebBindings::toV8Value): + +2012-07-19 Sami Kyostila <skyostil@chromium.org> + + [chromium] Remove duplicate mock CCLayerTreeHostClient + https://bugs.webkit.org/show_bug.cgi?id=89457 + + Reviewed by Adrienne Walker. + + This test can reuse the existing CCFakeLayerTreeHostClient. + + * tests/GraphicsLayerChromiumTest.cpp: + (WebKitTests::MockLayerTreeHost::create): + +2012-07-19 Peter Beverloo <peter@chromium.org> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-07-18 Ryosuke Niwa <rniwa@webkit.org> + + Chromium build fix attempt. Don't use anonymous namespace. + + * tests/TextureCopierTest.cpp: + +2012-07-18 Antoine Labour <piman@chromium.org> + + [chromium] Introduce CCResourceProvider, replacing TextureAllocator and hiding textures from clients to allow transport + https://bugs.webkit.org/show_bug.cgi?id=91044 + + Reviewed by Adrienne Walker. + + This does several things: + - Add a CCResourceProvider class, that hides textures and the 3D context + from layers (except those that need it). Instead layers manage + "resources". In the future, resources are expected to be transportable + to a "parent" CCResourceProvider to allow flattening of nested + compositors. + - Replace texture ids by resource ids in DrawQuads (allowing them to be + serializable). + - Replace TextureAllocator uses by the CCResourceProvider class. + - Upload of data is done through the CCResourceProvider instead of + explicit GL calls. + - External textures are wrapped into a resource at draw time (see + caveat/FIXME in CCTextureLayerImpl). + - Rendering with the resources is done through an explicit + beginRenderFrom/endRenderFrom that exposes the texture only between that + pair. + - Merge all the LayerTextureSubImage instances (one per layer), into a + single instance on the CCResourceProvider. + + Added CCResourceProviderTest, the refactoring is covered by existing tests. + + * WebKit.gypi: + * tests/CCLayerTreeHostImplTest.cpp: + * tests/CCPrioritizedTextureTest.cpp: + (WTF::CCPrioritizedTextureTest::CCPrioritizedTextureTest): + (WTF::CCPrioritizedTextureTest::createManager): + (WTF::CCPrioritizedTextureTest::validateTexture): + (WTF::CCPrioritizedTextureTest::resourceProvider): + (CCPrioritizedTextureTest): + (WTF::TEST_F): + * tests/CCQuadCullerTest.cpp: + * tests/CCResourceProviderTest.cpp: Added. + (WebKit): + (ResourceProviderContext): + (WebKit::ResourceProviderContext::create): + (WebKit::ResourceProviderContext::bindTexture): + (WebKit::ResourceProviderContext::createTexture): + (WebKit::ResourceProviderContext::deleteTexture): + (WebKit::ResourceProviderContext::texStorage2DEXT): + (WebKit::ResourceProviderContext::texImage2D): + (WebKit::ResourceProviderContext::texSubImage2D): + (WebKit::ResourceProviderContext::getPixels): + (WebKit::ResourceProviderContext::textureCount): + (WebKit::ResourceProviderContext::textureSize): + (WebKit::ResourceProviderContext::ResourceProviderContext): + (WebKit::ResourceProviderContext::Texture::Texture): + (Texture): + (WebKit::ResourceProviderContext::allocateTexture): + (WebKit::ResourceProviderContext::setPixels): + (CCResourceProviderTest): + (WebKit::CCResourceProviderTest::CCResourceProviderTest): + (WebKit::CCResourceProviderTest::context): + (WebKit::CCResourceProviderTest::getResourcePixels): + (WebKit::TEST_F): + * tests/CCScopedTextureTest.cpp: + (WebKitTests::TEST): + * tests/CCTiledLayerImplTest.cpp: + (CCLayerTestCommon::createLayer): + (CCLayerTestCommon::TEST): + * tests/CCTiledLayerTestCommon.cpp: + (WebKitTests::FakeLayerTextureUpdater::Texture::updateRect): + * tests/CCTiledLayerTestCommon.h: + (Texture): + (WebKitTests::FakeTextureCopier::copyTexture): + (WebKitTests::FakeTextureCopier::flush): + (WebKitTests::FakeTextureUploader::uploadTexture): + * tests/ContentLayerChromiumTest.cpp: + (WebKit::TEST): + * tests/FakeCCGraphicsContext.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTexture.h. + (WebKit): + (WebKit::createFakeCCGraphicsContext): + * tests/LayerRendererChromiumTest.cpp: + (FakeLayerRendererChromium::FakeLayerRendererChromium): + (LayerRendererChromiumTest::LayerRendererChromiumTest): + (LayerRendererChromiumTest::context): + (LayerRendererChromiumTest): + (TEST_F): + (TEST): + * tests/TextureCopierTest.cpp: + * tests/TextureManagerTest.cpp: + (WTF::TextureManagerTest::TextureManagerTest): + (WTF::TextureManagerTest::createTextureManager): + (WTF::TextureManagerTest::requestTexture): + (TextureManagerTest): + * tests/TiledLayerChromiumTest.cpp: + +2012-07-18 David Grogan <dgrogan@chromium.org> + + IndexedDB: Add intVersion to chromium/public/WebIDBMetadata.h + https://bugs.webkit.org/show_bug.cgi?id=91408 + + Reviewed by Adam Barth. + + This is in support of the new upgradeneeded versioning api. + intVersion will eventually replace the WebString version member. + + * public/WebIDBMetadata.h: + (WebKit::WebIDBMetadata::WebIDBMetadata): + The spec uses unsigned long long for version numbers but we use signed + long long so that we can use -1 as a sentinel. It indicates that a + database still uses a string version. + +2012-07-18 Adam Barth <abarth@webkit.org> + + Disable printing on chromium-android + https://bugs.webkit.org/show_bug.cgi?id=91550 + + Reviewed by Tony Chang. + + We don't implement printing on Android. + + * features.gypi: + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::printPage): + +2012-07-18 Alexandre Elias <aelias@google.com> + + [chromium] Ubercomp: add id to SharedQuadState + https://bugs.webkit.org/show_bug.cgi?id=91670 + + Reviewed by Adrienne Walker. + + This assigns an integer ID to SharedQuadState objects and a + corresponding ID to quads. This ID is unique only within a + RenderPass and currently is just set to the index in the shared quad + state list. This is redundant with the pointer and exists to + simplify serialization. + + I found out that pointer rewriting within a pickler is blocked by + pointers to memory being const there, so the reassignment will have to + be performed in the application layer anyway. In that case, it's + simplest to add some ID integers. + + * tests/CCLayerTreeHostImplTest.cpp: + * tests/CCQuadCullerTest.cpp: + * tests/CCRenderSurfaceTest.cpp: + * tests/CCSolidColorLayerImplTest.cpp: + (CCLayerTestCommon::TEST): + * tests/CCTiledLayerImplTest.cpp: + (CCLayerTestCommon::TEST): + (CCLayerTestCommon::getQuads): + +2012-07-18 Nate Chapin <japhet@chromium.org> + + Add WebTextInputType enum values for text areas and + content-editable. + https://bugs.webkit.org/show_bug.cgi?id=91654 + + Reviewed by Adam Barth. + + No new tests, no behavior change without corresponding chromium.org changes. + + * public/WebTextInputType.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::textInputType): + +2012-07-18 Alexandre Elias <aelias@google.com> + + [chromium] Ubercomp: clean up CCRenderer interface + https://bugs.webkit.org/show_bug.cgi?id=91555 + + Reviewed by Adrienne Walker. + + I replaced the one-by-one RenderPass calls with a new drawFrame() + method that directly takes a CCRenderPassList, and moved a small + amount of code from CCLayerTreeHostImpl to implement it. In ubercomp + mode, we will produce a frame bundle rather than a command-stream, so + the full list is easier to work with. + + Also, give empty default implementations for the methods that don't + need to do anything in a non-GL context, and make private + setScissorToRect. + + * tests/LayerRendererChromiumTest.cpp: + (FakeCCRendererClient::FakeCCRendererClient): + (FakeCCRendererClient::renderPasses): + (FakeCCRendererClient): + (TEST_F): + (TEST): + +2012-07-18 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Fix some coding style violations + https://bugs.webkit.org/show_bug.cgi?id=91565 + + Reviewed by Tony Chang. + + * tests/IDBLevelDBCodingTest.cpp: + (IDBLevelDBCoding::TEST): + +2012-07-18 Tony Chang <tony@chromium.org> + + [chromium] Unreviewed, fix some MSVC compile warnings. + + * tests/CCDamageTrackerTest.cpp: + (WebKitTests::TEST_F): + * tests/CCLayerTreeHostCommonTest.cpp: + * tests/TiledLayerChromiumTest.cpp: + +2012-07-18 Mark Pilgrim <pilgrim@chromium.org> + + [Chromium] Call SQLiteFileSystem-related functions directly + https://bugs.webkit.org/show_bug.cgi?id=91631 + + Reviewed by Adam Barth. + + Part of a refactoring series. See tracking bug 82948. + + * public/platform/WebKitPlatformSupport.h: + (WebKitPlatformSupport): + * src/PlatformSupport.cpp: + (WebCore): + +2012-07-18 Tony Chang <tony@chromium.org> + + [chromium] Unreviewed, more compile fixes on Chromium Win. + + * tests/WebTransformationMatrixTest.cpp: + (WebKit::TEST): + +2012-07-18 Tony Chang <tony@chromium.org> + + [chromium] Fix compile on Windows. + + 148>tests\LayerChromiumTest.cpp(510): warning C4305: 'argument' : truncation from 'double' to 'float' + + * tests/LayerChromiumTest.cpp: + +2012-07-18 Alec Flett <alecflett@chromium.org> + + Implement putIndexKeys in WebIDBObjectStoreImpl + https://bugs.webkit.org/show_bug.cgi?id=91546 + + Reviewed by Darin Fisher. + + Implement putIndexKeys in the chromium API, so it is callable + from chromium. + + * src/WebIDBObjectStoreImpl.cpp: + (WebKit::WebIDBObjectStoreImpl::putWithIndexKeys): + (WebKit): + * src/WebIDBObjectStoreImpl.h: + (WebIDBObjectStoreImpl): + +2012-07-18 Tony Chang <tony@chromium.org> + + [chromium] Unreviewed compile fix for Android. + + More sqrt fixes. + + * tests/CCLayerTreeHostCommonTest.cpp: + +2012-07-18 Tony Chang <tony@chromium.org> + + [chromium] Unreviewed compile fix for Android. + + Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp: In member function 'virtual void<unnamed>::CCDamageTrackerTest_verifyDamageForTransformedLayer_Test::TestBody()': + Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp:332: error: call of overloaded 'sqrt(int)' is ambiguous + + * tests/CCDamageTrackerTest.cpp: + (WebKitTests::TEST_F): + +2012-07-18 Varun Jain <varunjain@chromium.org> + + [chromium] Drag image for image elements should be scaled with device scale factor. + https://bugs.webkit.org/show_bug.cgi?id=89688 + + Reviewed by Adam Barth. + + * src/DragClientImpl.cpp: + (WebKit::DragClientImpl::startDrag): + * tests/DragImageTest.cpp: + (WebCore::TEST): + +2012-07-18 Shawn Singh <shawnsingh@chromium.org> + + [chromium] Fix style for numeric literals in chromium unit test code + https://bugs.webkit.org/show_bug.cgi?id=91635 + + Reviewed by Adrienne Walker. + + Where possible, removed ".0" and "f" suffixes on numeric literals, + to be more consistent with WebKit style rules. + + * tests/CCDamageTrackerTest.cpp: + (WebKitTests::TEST_F): + * tests/CCLayerQuadTest.cpp: + (WebCore::TEST): + * tests/CCLayerTreeHostCommonTest.cpp: + * tests/CCQuadCullerTest.cpp: + * tests/LayerChromiumTest.cpp: + * tests/WebTransformationMatrixTest.cpp: + (WebKit::TEST): + +2012-07-17 Shawn Singh <shawnsingh@chromium.org> + + [chromium] Remove awkward anchorPoint usage that implicity affects layer position + https://bugs.webkit.org/show_bug.cgi?id=91472 + + Reviewed by Adrienne Walker. + + Unit tests were updated to account for the fact that anchorPoint + and position are now separated. + + * tests/CCDamageTrackerTest.cpp: + (WebKitTests::TEST_F): + * tests/CCLayerTreeHostCommonTest.cpp: + * tests/CCLayerTreeHostImplTest.cpp: + * tests/TiledLayerChromiumTest.cpp: + 2012-07-18 Yoshifumi Inoue <yosin@chromium.org> Decimal::toString should not round integer value. diff --git a/Source/WebKit/chromium/DEPS b/Source/WebKit/chromium/DEPS index 6194e131a..90b7caed8 100644 --- a/Source/WebKit/chromium/DEPS +++ b/Source/WebKit/chromium/DEPS @@ -32,7 +32,7 @@ vars = { 'chromium_svn': 'http://src.chromium.org/svn/trunk/src', - 'chromium_rev': '146999' + 'chromium_rev': '147759' } deps = { @@ -143,12 +143,18 @@ deps = { deps_os = { 'win': { + 'third_party/bison': + From('chromium_deps', 'src/third_party/bison'), 'third_party/cygwin': From('chromium_deps', 'src/third_party/cygwin'), + 'third_party/gperf': + From('chromium_deps', 'src/third_party/gperf'), 'third_party/lighttpd': From('chromium_deps', 'src/third_party/lighttpd'), 'third_party/nss': From('chromium_deps', 'src/third_party/nss'), + 'third_party/perl': + From('chromium_deps', 'src/third_party/perl'), # Dependencies used by libjpeg-turbo 'third_party/yasm/binaries': From('chromium_deps', 'src/third_party/yasm/binaries'), @@ -156,6 +162,8 @@ deps_os = { 'mac': { 'third_party/nss': From('chromium_deps', 'src/third_party/nss'), + 'third_party/GTM': + From('chromium_deps', 'src/third_party/GTM'), }, 'unix': { # Linux, actually. diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index f6868201c..45b949866 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -279,6 +279,7 @@ 'public/WebUserMediaClient.h', 'public/WebUserMediaRequest.h', 'public/WebView.h', + 'public/WebViewBenchmarkSupport.h', 'public/WebViewClient.h', 'public/WebWidget.h', 'public/WebWidgetClient.h', @@ -661,6 +662,8 @@ 'src/WebTextFieldDecoratorClient.cpp', 'src/WebUserMediaRequest.cpp', 'src/WebVideoLayer.cpp', + 'src/WebViewBenchmarkSupportImpl.cpp', + 'src/WebViewBenchmarkSupportImpl.h', 'src/WebViewImpl.cpp', 'src/WebViewImpl.h', 'src/WebWorkerBase.cpp', @@ -1048,7 +1051,7 @@ }, ], # targets 'conditions': [ - ['os_posix==1 and OS!="mac" and gcc_version==46', { + ['os_posix==1 and OS!="mac" and gcc_version>=46', { 'target_defaults': { # Disable warnings about c++0x compatibility, as some names (such # as nullptr) conflict with upcoming c++0x types. diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi index 40b23be49..831241de4 100644 --- a/Source/WebKit/chromium/WebKit.gypi +++ b/Source/WebKit/chromium/WebKit.gypi @@ -78,6 +78,7 @@ 'tests/CCOcclusionTrackerTestCommon.h', 'tests/CCQuadCullerTest.cpp', 'tests/CCRenderSurfaceTest.cpp', + 'tests/CCResourceProviderTest.cpp', 'tests/CCSchedulerStateMachineTest.cpp', 'tests/CCSchedulerTestCommon.h', 'tests/CCSchedulerTest.cpp', diff --git a/Source/WebKit/chromium/WebKitUnitTests.gyp b/Source/WebKit/chromium/WebKitUnitTests.gyp index 051c13524..81be90a0d 100644 --- a/Source/WebKit/chromium/WebKitUnitTests.gyp +++ b/Source/WebKit/chromium/WebKitUnitTests.gyp @@ -126,7 +126,7 @@ } ], # targets 'conditions': [ - ['os_posix==1 and OS!="mac" and gcc_version==46', { + ['os_posix==1 and OS!="mac" and gcc_version>=46', { 'target_defaults': { # Disable warnings about c++0x compatibility, as some names (such # as nullptr) conflict with upcoming c++0x types. diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index 35f86cf24..8df09639c 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -46,12 +46,12 @@ 'ENABLE_CSS_IMAGE_RESOLUTION=0', 'ENABLE_CSS_REGIONS=1', 'ENABLE_CSS_SHADERS=1', - 'ENABLE_CSS_VARIABLES=0', + 'ENABLE_CSS_VARIABLES=1', 'ENABLE_CUSTOM_SCHEME_HANDLER=0', - 'ENABLE_DATALIST=1', + 'ENABLE_DATALIST_ELEMENT=1', 'ENABLE_DASHBOARD_SUPPORT=0', 'ENABLE_DATA_TRANSFER_ITEMS=1', - 'ENABLE_DETAILS=1', + 'ENABLE_DETAILS_ELEMENT=1', 'ENABLE_DEVICE_ORIENTATION=1', 'ENABLE_DIALOG_ELEMENT=1', 'ENABLE_DIRECTORY_UPLOAD=1', @@ -75,13 +75,13 @@ 'ENABLE_LINK_PRERENDER=1', 'ENABLE_MEDIA_SOURCE=1', 'ENABLE_MEDIA_STATISTICS=1', - 'ENABLE_METER_TAG=1', + 'ENABLE_METER_ELEMENT=1', 'ENABLE_MHTML=1', 'ENABLE_MICRODATA=0', 'ENABLE_MUTATION_OBSERVERS=<(enable_mutation_observers)', 'ENABLE_PAGE_VISIBILITY_API=1', 'ENABLE_POINTER_LOCK=1', - 'ENABLE_PROGRESS_TAG=1', + 'ENABLE_PROGRESS_ELEMENT=1', 'ENABLE_QUOTA=1', 'ENABLE_REGISTER_PROTOCOL_HANDLER=1', 'ENABLE_REQUEST_ANIMATION_FRAME=1', @@ -155,6 +155,7 @@ 'ENABLE_ORIENTATION_EVENTS=1', 'ENABLE_OVERFLOW_SCROLLING=1', 'ENABLE_PAGE_POPUP=0', + 'ENABLE_PRINTING=0', # FIXME: Disable once the linking error has been resolved. # https://bugs.webkit.org/show_bug.cgi?id=88636 'ENABLE_SHARED_WORKERS=1', @@ -175,6 +176,7 @@ 'ENABLE_ORIENTATION_EVENTS=0', 'ENABLE_OVERFLOW_SCROLLING=0', 'ENABLE_PAGE_POPUP=1', + 'ENABLE_PRINTING=1', 'ENABLE_SHARED_WORKERS=1', 'ENABLE_WEB_AUDIO=1', ], @@ -187,7 +189,7 @@ ], }], # Mac OS X uses Accelerate.framework FFT by default instead of FFmpeg. - ['OS!="mac"', { + ['OS!="mac" and OS!="android"', { 'feature_defines': [ 'WTF_USE_WEBAUDIO_FFMPEG=1', ], diff --git a/Source/WebKit/chromium/public/WebAudioSourceProvider.h b/Source/WebKit/chromium/public/WebAudioSourceProvider.h index c0010f806..98c762284 100644 --- a/Source/WebKit/chromium/public/WebAudioSourceProvider.h +++ b/Source/WebKit/chromium/public/WebAudioSourceProvider.h @@ -40,6 +40,7 @@ public: // If a client is set, we call it back when the audio format is available. virtual void setClient(WebAudioSourceProviderClient*) { }; +protected: virtual ~WebAudioSourceProvider() { } }; diff --git a/Source/WebKit/chromium/public/WebIDBMetadata.h b/Source/WebKit/chromium/public/WebIDBMetadata.h index 1c33d1b08..1f2e9ead4 100644 --- a/Source/WebKit/chromium/public/WebIDBMetadata.h +++ b/Source/WebKit/chromium/public/WebIDBMetadata.h @@ -38,13 +38,21 @@ struct IDBDatabaseMetadata; namespace WebKit { struct WebIDBMetadata { + enum { + NoIntVersion = -1 + }; struct Index; struct ObjectStore; WebString name; + // FIXME: Both version members need to be present while we support both the + // old setVersion and new upgradeneeded API. Once we no longer support + // setVersion, WebString version can be removed. WebString version; + long long intVersion; WebVector<ObjectStore> objectStores; - WebIDBMetadata() { } + WebIDBMetadata() + : intVersion(NoIntVersion) { } struct ObjectStore { WebString name; diff --git a/Source/WebKit/chromium/public/WebView.h b/Source/WebKit/chromium/public/WebView.h index 3ba5da24f..0085ba51a 100644 --- a/Source/WebKit/chromium/public/WebView.h +++ b/Source/WebKit/chromium/public/WebView.h @@ -52,6 +52,7 @@ class WebNode; class WebPageOverlay; class WebPermissionClient; class WebPrerendererClient; +class WebViewBenchmarkSupport; class WebRange; class WebSettings; class WebSpellCheckClient; @@ -196,6 +197,9 @@ public: // previous element in the tab sequence (if reverse is true). virtual void advanceFocus(bool reverse) { } + // Animate a scale into the specified find-in-page rect. + virtual void zoomToFindInPageRect(const WebRect&) = 0; + // Zoom ---------------------------------------------------------------- @@ -382,6 +386,8 @@ public: // Hides any popup (suggestions, selects...) that might be showing. virtual void hidePopups() = 0; + virtual void selectAutofillSuggestionAtIndex(unsigned listIndex) = 0; + // Context menu -------------------------------------------------------- @@ -446,10 +452,16 @@ public: virtual bool setEditableSelectionOffsets(int start, int end) = 0; + virtual bool isSelectionEditable() const = 0; + // Fills in a WebRenderingStats struct containing information about the state of the compositor. // This call is relatively expensive in threaded mode as it blocks on the compositor thread. virtual void renderingStats(WebRenderingStats&) const { } + // Benchmarking support -------------------------------------------- + + virtual WebViewBenchmarkSupport* benchmarkSupport() { return 0; } + // Visibility ----------------------------------------------------------- // Sets the visibility of the WebView. diff --git a/Source/WebKit/chromium/public/WebViewBenchmarkSupport.h b/Source/WebKit/chromium/public/WebViewBenchmarkSupport.h new file mode 100644 index 000000000..c8ace3622 --- /dev/null +++ b/Source/WebKit/chromium/public/WebViewBenchmarkSupport.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef WebViewBenchmarkSupport_h +#define WebViewBenchmarkSupport_h + +#include "platform/WebCanvas.h" +#include "platform/WebSize.h" + +namespace WebKit { + +// Support for benchmarks accessing the WebView. +class WebViewBenchmarkSupport { +public: + enum PaintMode { + // Paint the entire page. + PaintModeEverything + }; + + // Client for creating canvases where multiple canvases + // may be used for layered rendering and sizes defined by the benchmark. + // Also contains reporting methods called by the WebViewBenchmarkSupport + // when painting is about to occur and when painting is complete. + class PaintClient { + public: + virtual WebCanvas* createCanvas(const WebSize&) = 0; + + // Called by the WebViewBenchmarkSupport when painting is about to + // occur. + virtual void willPaint(const WebCanvas&) { } + + // Called by the WebViewBenchmarkSupport when painting is complete. + virtual void didPaint(const WebCanvas&) { } + protected: + virtual ~PaintClient() { } + }; + + // Paints the web view on canvases created from the client, using the given + // paint mode. + virtual void paint(PaintClient*, PaintMode) = 0; + +protected: + virtual ~WebViewBenchmarkSupport() { } +}; +} // namespace WebKit + +#endif // WebViewBenchmarkSupport_h diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h index 08b2cd05a..600c523f8 100644 --- a/Source/WebKit/chromium/public/WebWidget.h +++ b/Source/WebKit/chromium/public/WebWidget.h @@ -221,6 +221,10 @@ public: // following the call to instrumentBeginFrame(). virtual void instrumentCancelFrame() { } + // The page background color. Can be used for filling in areas without + // content. + virtual WebColor backgroundColor() const { return 0xFFFFFFFF; /* SK_ColorWHITE */ } + protected: ~WebWidget() { } }; diff --git a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h index 3bb7ebeb4..70ad85228 100644 --- a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h +++ b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h @@ -57,31 +57,6 @@ class WebSharedWorkerRepository; // FIXME: Does this belong in platform? // FIXME: Eventually all these API will need to move to WebKit::Platform. class WebKitPlatformSupport : public Platform { public: - // HTML5 Database ------------------------------------------------------ - -#ifdef WIN32 - typedef HANDLE FileHandle; -#else - typedef int FileHandle; -#endif - - // Opens a database file; dirHandle should be 0 if the caller does not need - // a handle to the directory containing this file - virtual FileHandle databaseOpenFile( - const WebString& vfsFileName, int desiredFlags) { return FileHandle(); } - - // Deletes a database file and returns the error code - virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; } - - // Returns the attributes of the given database file - virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; } - - // Returns the size of the given database file - virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; } - - // Returns the space available for the given origin - virtual long long databaseGetSpaceAvailableForOrigin(const WebKit::WebString& originIdentifier) { return 0; } - // Indexed Database ---------------------------------------------------- virtual WebIDBFactory* idbFactory() { return 0; } diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index 0f8442a76..789d1b623 100644 --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -53,6 +53,7 @@ #include "IDBFactoryBackendInterface.h" #include "IDBKey.h" #include "IDBKeyPath.h" +#include "IDBMetadata.h" #include "IceOptions.h" #include "IconURL.h" #include "MediaPlayer.h" @@ -87,6 +88,7 @@ #include "WebIDBFactory.h" #include "WebIDBKey.h" #include "WebIDBKeyPath.h" +#include "WebIDBMetadata.h" #include "WebIconURL.h" #include "WebInputElement.h" #include "WebMediaPlayer.h" @@ -461,6 +463,8 @@ COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NumberType, IDBKey::NumberType); COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::NullType, IDBKeyPath::NullType); COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::StringType, IDBKeyPath::StringType); COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::ArrayType, IDBKeyPath::ArrayType); + +COMPILE_ASSERT_MATCHING_ENUM(WebIDBMetadata::NoIntVersion, IDBDatabaseMetadata::NoIntVersion); #endif #if ENABLE(FILE_SYSTEM) diff --git a/Source/WebKit/chromium/src/DragClientImpl.cpp b/Source/WebKit/chromium/src/DragClientImpl.cpp index a6fb0bd33..3974e7ad3 100644 --- a/Source/WebKit/chromium/src/DragClientImpl.cpp +++ b/Source/WebKit/chromium/src/DragClientImpl.cpp @@ -87,7 +87,13 @@ void DragClientImpl::startDrag(DragImageRef dragImage, IntSize offsetSize(eventPos - dragImageOrigin); WebPoint offsetPoint(offsetSize.width(), offsetSize.height()); - m_webView->startDragging(frame, dragData, static_cast<WebDragOperationsMask>(dragOperationMask), dragImage ? WebImage(*dragImage) : WebImage(), offsetPoint); + + if (dragImage && dragImage->bitmap && m_webView->deviceScaleFactor() != dragImage->resolutionScale) { + ASSERT(dragImage->resolutionScale > 0); + float scale = m_webView->deviceScaleFactor() / dragImage->resolutionScale; + dragImage = scaleDragImage(dragImage, WebCore::FloatSize(scale, scale)); + } + m_webView->startDragging(frame, dragData, static_cast<WebDragOperationsMask>(dragOperationMask), (dragImage && dragImage->bitmap) ? WebImage(*dragImage->bitmap) : WebImage(), offsetPoint); } void DragClientImpl::dragControllerDestroyed() diff --git a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp index 3a21a781b..88f9852ac 100644 --- a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp @@ -72,24 +72,6 @@ void IDBTransactionBackendProxy::abort() m_webIDBTransaction->abort(); } -void IDBTransactionBackendProxy::registerOpenCursor(WebCore::IDBCursorBackendImpl*) -{ - ASSERT_NOT_REACHED(); -} - -void IDBTransactionBackendProxy::unregisterOpenCursor(WebCore::IDBCursorBackendImpl*) -{ - ASSERT_NOT_REACHED(); -} - -bool IDBTransactionBackendProxy::scheduleTask(PassOwnPtr<ScriptExecutionContext::Task>, PassOwnPtr<ScriptExecutionContext::Task>) -{ - // This should never be reached as it's the impl objects who get to - // execute tasks in the browser process. - ASSERT_NOT_REACHED(); - return false; -} - void IDBTransactionBackendProxy::didCompleteTaskEvents() { m_webIDBTransaction->didCompleteTaskEvents(); diff --git a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h index 58918f68c..7e7486bd7 100644 --- a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h +++ b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h @@ -42,19 +42,10 @@ public: virtual ~IDBTransactionBackendProxy(); virtual PassRefPtr<WebCore::IDBObjectStoreBackendInterface> objectStore(const String& name, WebCore::ExceptionCode&); - virtual unsigned short mode() const - { - ASSERT_NOT_REACHED(); - return 0; - } virtual void commit(); virtual void abort(); - virtual bool scheduleTask(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>); virtual void didCompleteTaskEvents(); virtual void setCallbacks(WebCore::IDBTransactionCallbacks*); - virtual void registerOpenCursor(WebCore::IDBCursorBackendImpl*); - virtual void unregisterOpenCursor(WebCore::IDBCursorBackendImpl*); - virtual void addPendingEvents(int) { ASSERT_NOT_REACHED(); } WebIDBTransaction* getWebIDBTransaction() const { return m_webIDBTransaction.get(); } diff --git a/Source/WebKit/chromium/src/PlatformSupport.cpp b/Source/WebKit/chromium/src/PlatformSupport.cpp index 193b68b3a..0afb807e0 100644 --- a/Source/WebKit/chromium/src/PlatformSupport.cpp +++ b/Source/WebKit/chromium/src/PlatformSupport.cpp @@ -276,33 +276,6 @@ void PlatformSupport::getRenderStyleForStrike(const char* font, int sizeAndStyle } #endif -// Databases ------------------------------------------------------------------ - -PlatformFileHandle PlatformSupport::databaseOpenFile(const String& vfsFileName, int desiredFlags) -{ - return webKitPlatformSupport()->databaseOpenFile(WebString(vfsFileName), desiredFlags); -} - -int PlatformSupport::databaseDeleteFile(const String& vfsFileName, bool syncDir) -{ - return webKitPlatformSupport()->databaseDeleteFile(WebString(vfsFileName), syncDir); -} - -long PlatformSupport::databaseGetFileAttributes(const String& vfsFileName) -{ - return webKitPlatformSupport()->databaseGetFileAttributes(WebString(vfsFileName)); -} - -long long PlatformSupport::databaseGetFileSize(const String& vfsFileName) -{ - return webKitPlatformSupport()->databaseGetFileSize(WebString(vfsFileName)); -} - -long long PlatformSupport::databaseGetSpaceAvailableForOrigin(const String& originIdentifier) -{ - return webKitPlatformSupport()->databaseGetSpaceAvailableForOrigin(originIdentifier); -} - // Indexed Database ----------------------------------------------------------- PassRefPtr<IDBFactoryBackendInterface> PlatformSupport::idbFactory() diff --git a/Source/WebKit/chromium/src/WebBindings.cpp b/Source/WebKit/chromium/src/WebBindings.cpp index b9bbd5d37..926db3b11 100644 --- a/Source/WebKit/chromium/src/WebBindings.cpp +++ b/Source/WebKit/chromium/src/WebBindings.cpp @@ -210,8 +210,6 @@ static bool getRangeImpl(NPObject* object, WebRange* webRange) V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object); v8::Handle<v8::Object> v8Object(v8NPObject->v8Object); - if (v8Object.IsEmpty()) - return false; if (!V8Range::info.equals(V8DOMWrapper::domWrapperType(v8Object))) return false; @@ -245,8 +243,6 @@ static bool getElementImpl(NPObject* object, WebElement* webElement) V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object); v8::Handle<v8::Object> v8Object(v8NPObject->v8Object); - if (v8Object.IsEmpty()) - return false; Element* native = V8Element::HasInstance(v8Object) ? V8Element::toNative(v8Object) : 0; if (!native) return false; @@ -262,8 +258,6 @@ static bool getArrayBufferImpl(NPObject* object, WebArrayBuffer* arrayBuffer) V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object); v8::Handle<v8::Object> v8Object(v8NPObject->v8Object); - if (v8Object.IsEmpty()) - return false; ArrayBuffer* native = V8ArrayBuffer::HasInstance(v8Object) ? V8ArrayBuffer::toNative(v8Object) : 0; if (!native) return false; @@ -279,8 +273,6 @@ static bool getArrayBufferViewImpl(NPObject* object, WebArrayBufferView* arrayBu V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object); v8::Handle<v8::Object> v8Object(v8NPObject->v8Object); - if (v8Object.IsEmpty()) - return false; ArrayBufferView* native = V8ArrayBufferView::HasInstance(v8Object) ? V8ArrayBufferView::toNative(v8Object) : 0; if (!native) return false; @@ -406,8 +398,6 @@ v8::Handle<v8::Value> WebBindings::toV8Value(const NPVariant* variant) if (object->_class != npScriptObjectClass) return v8::Undefined(); V8NPObject* v8Object = reinterpret_cast<V8NPObject*>(object); - if (v8Object->v8Object.IsEmpty()) - return v8::Undefined(); return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()->script()->windowScriptNPObject()); } // Safe to pass 0 since we have checked the script object class to make sure the diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index 89189eea2..0cfbac209 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -1529,6 +1529,7 @@ float WebFrameImpl::getPrintPageShrink(int page) float WebFrameImpl::printPage(int page, WebCanvas* canvas) { +#if ENABLE(PRINTING) // Ensure correct state. if (!m_printContext || page < 0 || !frame() || !frame()->document()) { ASSERT_NOT_REACHED(); @@ -1540,6 +1541,9 @@ float WebFrameImpl::printPage(int page, WebCanvas* canvas) gc.platformContext()->setPrinting(true); return m_printContext->spoolPage(gc, page); +#else + return 0; +#endif } void WebFrameImpl::printEnd() diff --git a/Source/WebKit/chromium/src/WebIDBMetadata.cpp b/Source/WebKit/chromium/src/WebIDBMetadata.cpp index 735063ef0..01d878a0a 100644 --- a/Source/WebKit/chromium/src/WebIDBMetadata.cpp +++ b/Source/WebKit/chromium/src/WebIDBMetadata.cpp @@ -41,6 +41,7 @@ WebIDBMetadata::WebIDBMetadata(const WebCore::IDBDatabaseMetadata& metadata) { name = metadata.name; version = metadata.version; + intVersion = metadata.intVersion; objectStores = WebVector<ObjectStore>(static_cast<size_t>(metadata.objectStores.size())); size_t i = 0; @@ -68,7 +69,7 @@ WebIDBMetadata::WebIDBMetadata(const WebCore::IDBDatabaseMetadata& metadata) WebIDBMetadata::operator IDBDatabaseMetadata() const { - IDBDatabaseMetadata db(name, version); + IDBDatabaseMetadata db(name, version, intVersion); for (size_t i = 0; i < objectStores.size(); ++i) { const ObjectStore webObjectStore = objectStores[i]; IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.keyPath, webObjectStore.autoIncrement); diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp index 9bac6d3c3..53d140f42 100755 --- a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp +++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp @@ -63,6 +63,23 @@ void WebIDBObjectStoreImpl::put(const WebSerializedScriptValue& value, const Web m_objectStore->put(value, key, static_cast<IDBObjectStoreBackendInterface::PutMode>(putMode), IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), ec); } +void WebIDBObjectStoreImpl::putWithIndexKeys(const WebSerializedScriptValue& value, const WebIDBKey& key, PutMode putMode, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, const WebVector<WebString>& webIndexNames, const WebVector<WebIndexKeys>& webIndexKeys, WebExceptionCode& ec) +{ + ASSERT(webIndexNames.size() == webIndexKeys.size()); + Vector<String> indexNames(webIndexNames.size()); + Vector<IDBObjectStoreBackendInterface::IndexKeys> indexKeys(webIndexKeys.size()); + + for (size_t i = 0; i < webIndexNames.size(); ++i) { + indexNames[i] = webIndexNames[i]; + Vector<RefPtr<IDBKey> > indexKeyList(webIndexKeys[i].size()); + for (size_t j = 0; j < webIndexKeys[i].size(); ++j) + indexKeyList[j] = webIndexKeys[i][j]; + indexKeys[i] = indexKeyList; + } + + m_objectStore->putWithIndexKeys(value, key, static_cast<IDBObjectStoreBackendInterface::PutMode>(putMode), IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), indexNames, indexKeys, ec); +} + void WebIDBObjectStoreImpl::deleteFunction(const WebIDBKeyRange& keyRange, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec) { m_objectStore->deleteFunction(keyRange, IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), ec); diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h index 5a881b592..e6dc88f54 100644 --- a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h +++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h @@ -47,6 +47,7 @@ public: void get(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); void put(const WebSerializedScriptValue&, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); + void putWithIndexKeys(const WebSerializedScriptValue&, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebIDBTransaction&, const WebVector<WebString>& indexNames, const WebVector<WebIndexKeys>&, WebExceptionCode&); void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); diff --git a/Source/WebKit/chromium/src/WebInputElement.cpp b/Source/WebKit/chromium/src/WebInputElement.cpp index c1453de66..791b2ebff 100644 --- a/Source/WebKit/chromium/src/WebInputElement.cpp +++ b/Source/WebKit/chromium/src/WebInputElement.cpp @@ -175,7 +175,7 @@ bool WebInputElement::isMultiple() const WebNodeCollection WebInputElement::dataListOptions() const { -#if ENABLE(DATALIST) +#if ENABLE(DATALIST_ELEMENT) HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(constUnwrap<HTMLInputElement>()->list()); if (dataList) return WebNodeCollection(dataList->options()); diff --git a/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.cpp b/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.cpp new file mode 100644 index 000000000..2b11f6eb6 --- /dev/null +++ b/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "config.h" +#include "WebViewBenchmarkSupportImpl.h" + +#include "FloatSize.h" +#include "FrameView.h" +#include "GraphicsLayer.h" +#include "IntRect.h" +#include "IntSize.h" +#include "WebViewImpl.h" +#include "painting/GraphicsContextBuilder.h" + +#include <public/WebCanvas.h> +#include <wtf/CurrentTime.h> +#include <wtf/OwnPtr.h> +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace WebKit { + +void WebViewBenchmarkSupportImpl::paintLayer(PaintClient* paintClient, GraphicsLayer& layer, const IntRect& clip) +{ + WebSize canvasSize(clip.width(), clip.height()); + OwnPtr<WebCanvas> canvas = adoptPtr(paintClient->createCanvas(canvasSize)); + GraphicsContextBuilder builder(canvas.get()); + + paintClient->willPaint(*canvas.get()); + layer.paintGraphicsLayerContents(builder.context(), clip); + paintClient->didPaint(*canvas.get()); +} + +void WebViewBenchmarkSupportImpl::acceleratedPaintUnclipped(PaintClient* paintClient, GraphicsLayer& layer) +{ + FloatSize layerSize = layer.size(); + IntRect clip(0, 0, layerSize.width(), layerSize.height()); + + paintLayer(paintClient, layer, clip); + + const Vector<GraphicsLayer*>& children = layer.children(); + Vector<GraphicsLayer*>::const_iterator it; + for (it = children.begin(); it != children.end(); ++it) + acceleratedPaintUnclipped(paintClient, **it); +} + +void WebViewBenchmarkSupportImpl::softwarePaint(PaintClient* paintClient, PaintMode paintMode) +{ + WebSize size = m_webViewImpl->size(); + WebRect paintSize; + switch (paintMode) { + case PaintModeEverything: + if (m_webViewImpl->page() && m_webViewImpl->page()->mainFrame()) { + FrameView* view = m_webViewImpl->page()->mainFrame()->view(); + IntSize contentsSize = view->contentsSize(); + paintSize = WebRect(0, 0, contentsSize.width(), contentsSize.height()); + } else + paintSize = WebRect(0, 0, size.width, size.height); + break; + } + + WebSize canvasSize(paintSize.width, paintSize.height); + OwnPtr<WebCanvas> canvas = adoptPtr(paintClient->createCanvas(canvasSize)); + paintClient->willPaint(*canvas.get()); + m_webViewImpl->paint(canvas.get(), paintSize); + paintClient->didPaint(*canvas.get()); +} + +void WebViewBenchmarkSupportImpl::paint(PaintClient* paintClient, PaintMode paintMode) +{ + m_webViewImpl->layout(); + if (!m_webViewImpl->isAcceleratedCompositingActive()) + return softwarePaint(paintClient, paintMode); + GraphicsLayer* layer = m_webViewImpl->rootGraphicsLayer(); + switch (paintMode) { + case PaintModeEverything: + acceleratedPaintUnclipped(paintClient, *layer); + break; + } +} +} diff --git a/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.h b/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.h new file mode 100644 index 000000000..9a612cd64 --- /dev/null +++ b/Source/WebKit/chromium/src/WebViewBenchmarkSupportImpl.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebViewBenchmarkSupportImpl_h +#define WebViewBenchmarkSupportImpl_h + +#include "WebViewBenchmarkSupport.h" + +namespace WebCore { +class IntRect; +class GraphicsLayer; +} + +namespace WebKit { +class WebViewImpl; + +class WebViewBenchmarkSupportImpl : public WebViewBenchmarkSupport { +public: + explicit WebViewBenchmarkSupportImpl(WebViewImpl* webViewImpl) : m_webViewImpl(webViewImpl) { } + virtual ~WebViewBenchmarkSupportImpl() { } + + // Paints the WebViewImpl onto canvases created from the PaintClient. + // If we're in accelerated mode, a new canvas is created for each graphics + // layer. Layout() will be called on the web view prior to painting. + virtual void paint(PaintClient*, PaintMode) OVERRIDE; + +private: + void paintLayer(PaintClient*, WebCore::GraphicsLayer&, const WebCore::IntRect& clip); + + // Paints the given graphics layer hierarchy to canvases created by the + // canvas factory. + void acceleratedPaintUnclipped(PaintClient*, WebCore::GraphicsLayer&); + void softwarePaint(PaintClient*, PaintMode); + + WebViewImpl* m_webViewImpl; +}; +} + +#endif // WebViewBenchmarkSupportImpl_h diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index e349151fa..0d5f25a51 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -195,6 +195,8 @@ static const int touchPointPadding = 32; static const float minScaleDifference = 0.01f; static const float doubleTapZoomContentDefaultMargin = 5; static const float doubleTapZoomContentMinimumMargin = 2; +static const double doubleTabZoomAnimationDurationInSeconds = 0.25; + namespace WebKit { @@ -405,6 +407,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_tabsToLinks(false) , m_dragScrollTimer(adoptPtr(new DragScrollTimer)) , m_isCancelingFullScreen(false) + , m_benchmarkSupport(this) #if USE(ACCELERATED_COMPOSITING) , m_rootGraphicsLayer(0) , m_isAcceleratedCompositingActive(false) @@ -745,13 +748,18 @@ void WebViewImpl::renderingStats(WebRenderingStats& stats) const m_layerTreeView.renderingStats(stats); } -void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec) +void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationInSeconds) { if (!m_layerTreeView.isNull()) - m_layerTreeView.startPageScaleAnimation(scroll, useAnchor, newScale, durationSec); + m_layerTreeView.startPageScaleAnimation(scroll, useAnchor, newScale, durationInSeconds); } #endif +WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport() +{ + return &m_benchmarkSupport; +} + bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) { ASSERT((event.type == WebInputEvent::RawKeyDown) @@ -1073,6 +1081,27 @@ void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo } #endif +void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoomType) +{ +#if ENABLE(GESTURE_EVENTS) + if (!mainFrameImpl()) + return; + + float scale; + WebPoint scroll; + computeScaleAndScrollForHitRect(WebRect(point.x(), point.y(), 0, 0), zoomType, scale, scroll); + + bool isDoubleTap = (zoomType == DoubleTap); + double durationInSeconds = isDoubleTap ? doubleTabZoomAnimationDurationInSeconds : 0; + startPageScaleAnimation(scroll, isDoubleTap, scale, durationInSeconds); +#endif +} + +void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) +{ + animateZoomAroundPoint(IntRect(rect).center(), FindInPage); +} + void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers) { if (m_client) @@ -2148,6 +2177,25 @@ bool WebViewImpl::setEditableSelectionOffsets(int start, int end) return editor->setSelectionOffsets(start, end); } +bool WebViewImpl::isSelectionEditable() const +{ + const Frame* frame = focusedWebCoreFrame(); + if (!frame) + return false; + return frame->selection()->isContentEditable(); +} + +WebColor WebViewImpl::backgroundColor() const +{ + if (!m_page) + return Color::white; + FrameView* view = m_page->mainFrame()->view(); + Color backgroundColor = view->documentBackgroundColor(); + if (!backgroundColor.isValid()) + return Color::white; + return backgroundColor.rgb(); +} + bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) { const Frame* focused = focusedWebCoreFrame(); @@ -3459,6 +3507,11 @@ void WebViewImpl::setBackgroundColor(const WebCore::Color& color) m_layerTreeView.setBackgroundColor(webDocumentBackgroundColor); } +WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer() +{ + return m_rootGraphicsLayer; +} + #if ENABLE(REQUEST_ANIMATION_FRAME) void WebViewImpl::scheduleAnimation() { @@ -3697,6 +3750,12 @@ WebGraphicsContext3D* WebViewImpl::sharedGraphicsContext3D() return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::get().get()); } +void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex) +{ + if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestionsCount()) + m_autofillPopupClient->valueChanged(listIndex); +} + void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, bool isInitialState) { if (!page()) diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 8f6bdf40b..c2f36bf45 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -56,6 +56,7 @@ #include "PageWidgetDelegate.h" #include "PlatformGestureCurveTarget.h" #include "UserMediaClientImpl.h" +#include "WebViewBenchmarkSupportImpl.h" #include <wtf/OwnPtr.h> #include <wtf/RefCounted.h> @@ -106,6 +107,7 @@ class WebFrameImpl; class WebGestureEvent; class WebPagePopupImpl; class WebPrerendererClient; +class WebViewBenchmarkSupport; class WebImage; class WebKeyboardEvent; class WebMouseEvent; @@ -159,6 +161,8 @@ public: virtual WebTextInputInfo textInputInfo(); virtual WebTextInputType textInputType(); virtual bool setEditableSelectionOffsets(int start, int end); + virtual bool isSelectionEditable() const; + virtual WebColor backgroundColor() const; virtual bool selectionBounds(WebRect& start, WebRect& end) const; virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const; virtual bool caretOrSelectionRange(size_t* location, size_t* length); @@ -203,6 +207,7 @@ public: virtual void clearFocusedNode(); virtual void scrollFocusedNodeIntoView(); virtual void scrollFocusedNodeIntoRect(const WebRect&); + virtual void zoomToFindInPageRect(const WebRect&); virtual void advanceFocus(bool reverse); virtual double zoomLevel(); virtual double setZoomLevel(bool textOnly, double zoomLevel); @@ -276,6 +281,7 @@ public: const WebVector<int>& itemIDs, int separatorIndex); virtual void hidePopups(); + virtual void selectAutofillSuggestionAtIndex(unsigned listIndex); virtual void setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor); @@ -291,6 +297,7 @@ public: #endif virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&); virtual void renderingStats(WebRenderingStats&) const; + virtual WebViewBenchmarkSupport* benchmarkSupport(); // WebLayerTreeViewClient virtual void willBeginFrame(); @@ -373,7 +380,7 @@ public: // Event related methods: void mouseContextMenu(const WebMouseEvent&); void mouseDoubleClick(const WebMouseEvent&); - void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationSec); + void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds); void numberOfWheelEventHandlersChanged(unsigned); void numberOfTouchEventHandlersChanged(unsigned); @@ -503,6 +510,7 @@ public: return m_currentInputEvent; } + WebCore::GraphicsLayer* rootGraphicsLayer(); #if USE(ACCELERATED_COMPOSITING) bool allowsAcceleratedCompositing(); void setRootGraphicsLayer(WebCore::GraphicsLayer*); @@ -544,6 +552,7 @@ public: #if ENABLE(GESTURE_EVENTS) void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll); #endif + void animateZoomAroundPoint(const WebCore::IntPoint&, AutoZoomType); void loseCompositorContext(int numTimes); @@ -784,6 +793,8 @@ private: RefPtr<WebCore::Frame> m_fullScreenFrame; bool m_isCancelingFullScreen; + WebViewBenchmarkSupportImpl m_benchmarkSupport; + #if USE(ACCELERATED_COMPOSITING) WebCore::IntRect m_rootLayerScrollDamage; OwnPtr<NonCompositedContentHost> m_nonCompositedContentHost; diff --git a/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm index 88c3b72e5..f246bcf2c 100644 --- a/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm +++ b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm @@ -91,7 +91,7 @@ static float deviceScaleFactor(NSView* view) WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view) { - NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]); + NSScreen* screen = [NSScreen deepestScreen]; WebScreenInfo results; @@ -99,14 +99,10 @@ WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view) results.horizontalDPI = deviceDPI; results.verticalDPI = deviceDPI; - results.depth = - NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]); - results.depthPerComponent = - NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]); - results.isMonochrome = colorSpace == NSCalibratedWhiteColorSpace - || colorSpace == NSCalibratedBlackColorSpace - || colorSpace == NSDeviceWhiteColorSpace - || colorSpace == NSDeviceBlackColorSpace; + results.depth = NSBitsPerPixelFromDepth([screen depth]); + results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]); + results.isMonochrome = + [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; results.rect = convertRect([screenForWindow([view window]) frame], [view window]); results.availableRect = convertRect([screenForWindow([view window]) visibleFrame], [view window]); diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp index 9433d89da..9aa412090 100644 --- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp +++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp @@ -311,11 +311,9 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) WebTransformationMatrix rotation; rotation.rotate(45); - // Note carefully, the anchor is actually part of layer->position(). By setting anchor - // to (0.5, 0.5), the layer's position (100, 100) now refers to the center of the - // layer, not the corner. This means the layer has actually changed position. clearDamageForAllSurfaces(root.get()); child->setAnchorPoint(FloatPoint(0.5, 0.5)); + child->setPosition(FloatPoint(85, 85)); emulateDrawingOneFrame(root.get()); // Sanity check that the layer actually moved to (85, 85), damaging its old location and new location. @@ -331,8 +329,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) // Since the child layer is square, rotation by 45 degrees about the center should // increase the size of the expected rect by sqrt(2), centered around (100, 100). The // old exposed region should be fully contained in the new region. - double expectedWidth = 30.0 * sqrt(2.0); - double expectedPosition = 100.0 - 0.5 * expectedWidth; + double expectedWidth = 30 * sqrt(2.0); + double expectedPosition = 100 - 0.5 * expectedWidth; FloatRect expectedRect(expectedPosition, expectedPosition, expectedWidth, expectedWidth); rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect(); EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); @@ -828,7 +826,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica) grandChild1Replica->setPosition(FloatPoint::zero()); grandChild1Replica->setAnchorPoint(FloatPoint::zero()); WebTransformationMatrix reflection; - reflection.scale3d(-1.0, 1.0, 1.0); + reflection.scale3d(-1, 1, 1); grandChild1Replica->setTransform(reflection); grandChild1->setReplicaLayer(grandChild1Replica.release()); } @@ -848,7 +846,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica) // areas to be damaged on the target. clearDamageForAllSurfaces(root.get()); IntRect oldContentRect = child1->renderSurface()->contentRect(); - grandChild1->setPosition(FloatPoint(195.0, 205.0)); + grandChild1->setPosition(FloatPoint(195, 205)); emulateDrawingOneFrame(root.get()); ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->contentRect().width()); ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->contentRect().height()); @@ -904,7 +902,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask) child->setOpacity(0.5); { OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4); - grandChild->setPosition(FloatPoint(2.0, 2.0)); + grandChild->setPosition(FloatPoint(2, 2)); grandChild->setAnchorPoint(FloatPoint::zero()); grandChild->setBounds(IntSize(2, 2)); grandChild->setDrawsContent(true); @@ -979,7 +977,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) grandChild1Replica->setPosition(FloatPoint::zero()); grandChild1Replica->setAnchorPoint(FloatPoint::zero()); WebTransformationMatrix reflection; - reflection.scale3d(-1.0, 1.0, 1.0); + reflection.scale3d(-1, 1, 1); grandChild1Replica->setTransform(reflection); grandChild1->setReplicaLayer(grandChild1Replica.release()); } @@ -1030,20 +1028,17 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) CCLayerImpl* child1 = root->children()[0].get(); CCLayerImpl* grandChild1 = child1->children()[0].get(); - // Verify that the correct replicaOriginTransform is used for the replicaMask; the - // incorrect old code incorrectly accounted for the anchor for the replica. A - // non-zero anchor point should not affect the replica reflection. - + // Verify that the correct replicaOriginTransform is used for the replicaMask; clearDamageForAllSurfaces(root.get()); - grandChild1->setAnchorPoint(FloatPoint(1.0, 0.0)); // This is the anchor being tested. + grandChild1->setAnchorPoint(FloatPoint(1, 0)); // This is not exactly the anchor being tested, but by convention its expected to be the same as the replica's anchor point. { OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); grandChild1Replica->setPosition(FloatPoint::zero()); - grandChild1Replica->setAnchorPoint(FloatPoint::zero()); // note, this is not the anchor being tested. + grandChild1Replica->setAnchorPoint(FloatPoint(1, 0)); // This is the anchor being tested. WebTransformationMatrix reflection; - reflection.scale3d(-1.0, 1.0, 1.0); + reflection.scale3d(-1, 1, 1); grandChild1Replica->setTransform(reflection); grandChild1->setReplicaLayer(grandChild1Replica.release()); } @@ -1071,7 +1066,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) emulateDrawingOneFrame(root.get()); FloatRect childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRect(); - EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); + EXPECT_FLOAT_RECT_EQ(FloatRect(206, 200, 6, 8), childDamageRect); } TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage) diff --git a/Source/WebKit/chromium/tests/CCLayerQuadTest.cpp b/Source/WebKit/chromium/tests/CCLayerQuadTest.cpp index 2ab4ec4bc..ece2420e4 100644 --- a/Source/WebKit/chromium/tests/CCLayerQuadTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerQuadTest.cpp @@ -57,7 +57,7 @@ TEST(CCLayerQuadTest, Inflate) FloatQuad quad(p1, p2, p3, p4); CCLayerQuad layerQuad(quad); - quad.scale(2.0, 2.0); + quad.scale(2, 2); layerQuad.inflate(0.5); EXPECT_TRUE(layerQuad.floatQuad() == quad); } diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp index 0fa742548..26ae6ca47 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp @@ -154,9 +154,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForNoOpLayer) child->addChild(grandChild); WebTransformationMatrix identityMatrix; - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false); + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); executeCalculateDrawTransformsAndVisibility(parent.get()); @@ -170,19 +170,14 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForNoOpLayer) TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer) { - // NOTE CAREFULLY: - // LayerChromium::position is actually the sum of anchorPoint (in pixel space) and actual position. Because of this, the - // value of LayerChromium::position() changes if the anchor changes, even though the layer is not actually located in a - // different position. When we initialize layers for testing here, we need to initialize that unintutive position value. - WebTransformationMatrix identityMatrix; RefPtr<LayerChromium> layer = LayerChromium::create(); layer->createRenderSurface(); // Case 1: setting the sublayer transform should not affect this layer's draw transform or screen-space transform. WebTransformationMatrix arbitraryTranslation; - arbitraryTranslation.translate(10.0, 20.0); - setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslation, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false); + arbitraryTranslation.translate(10, 20); + setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslation, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform()); @@ -190,22 +185,22 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer) // Case 2: setting the bounds of the layer should result in a draw transform that translates to half the width and height. // The screen-space transform should remain as the identity, because it does not deal with transforming to/from the center of the layer. WebTransformationMatrix translationToCenter; - translationToCenter.translate(5.0, 6.0); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(10, 12), false); + translationToCenter.translate(5, 6); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform()); // Case 3: The anchor point by itself (without a layer transform) should have no effect on the transforms. - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform()); - // Case 4: A change in "actual" position affects both the draw transform and screen space transform. + // Case 4: A change in actual position affects both the draw transform and screen space transform. WebTransformationMatrix positionTransform; - positionTransform.translate(0.0, 1.2); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 4.2f), IntSize(10, 12), false); + positionTransform.translate(0, 1.2); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 1.2f), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform * translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransform()); @@ -213,17 +208,17 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer) // Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by // using a scale transform, because scale and translation are not commutative. WebTransformationMatrix layerTransform; - layerTransform.scale3d(2.0, 2.0, 1.0); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(10, 12), false); + layerTransform.scale3d(2, 2, 1); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform * translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform()); // Case 6: The layer transform should occur with respect to the anchor point. WebTransformationMatrix translationToAnchor; - translationToAnchor.translate(5.0, 0.0); + translationToAnchor.translate(5, 0); WebTransformationMatrix expectedResult = translationToAnchor * layerTransform * translationToAnchor.inverse(); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5f, 0.0f), FloatPoint(5.0f, 0.0f), IntSize(10, 12), false); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5, 0), FloatPoint(0, 0), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult * translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform()); @@ -232,7 +227,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer) // The current implementation of calculateDrawTransforms does this implicitly, but it is // still worth testing to detect accidental regressions. expectedResult = positionTransform * translationToAnchor * layerTransform * translationToAnchor.inverse(); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5f, 0.0f), FloatPoint(5.0f, 1.2f), IntSize(10, 12), false); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5, 0), FloatPoint(0, 1.2f), IntSize(10, 12), false); executeCalculateDrawTransformsAndVisibility(layer.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult * translationToCenter, layer->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform()); @@ -250,11 +245,11 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) // Case 1: parent's anchorPoint should not affect child or grandChild. WebTransformationMatrix childTranslationToCenter, grandChildTranslationToCenter; - childTranslationToCenter.translate(8.0, 9.0); - grandChildTranslationToCenter.translate(38.0, 39.0); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false); + childTranslationToCenter.translate(8, 9); + grandChildTranslationToCenter.translate(38, 39); + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); executeCalculateDrawTransformsAndVisibility(parent.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(childTranslationToCenter, child->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform()); @@ -263,10 +258,10 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) // Case 2: parent's position affects child and grandChild. WebTransformationMatrix parentPositionTransform; - parentPositionTransform.translate(0.0, 1.2); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 4.2f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false); + parentPositionTransform.translate(0, 1.2); + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 1.2f), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); executeCalculateDrawTransformsAndVisibility(parent.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform * childTranslationToCenter, child->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceTransform()); @@ -275,13 +270,13 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) // Case 3: parent's local transform affects child and grandchild WebTransformationMatrix parentLayerTransform; - parentLayerTransform.scale3d(2.0, 2.0, 1.0); + parentLayerTransform.scale3d(2, 2, 1); WebTransformationMatrix parentTranslationToAnchor; - parentTranslationToAnchor.translate(2.5, 3.0); + parentTranslationToAnchor.translate(2.5, 3); WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse(); - setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false); + setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); executeCalculateDrawTransformsAndVisibility(parent.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform()); @@ -293,16 +288,16 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) // Note that preserves3D is false, but the sublayer matrix should retain its 3D properties when given to child. // But then, the child also does not preserve3D. When it gives its hierarchy to the grandChild, it should be flattened to 2D. WebTransformationMatrix parentSublayerMatrix; - parentSublayerMatrix.scale3d(10.0, 10.0, 3.3); + parentSublayerMatrix.scale3d(10, 10, 3.3); WebTransformationMatrix parentTranslationToCenter; - parentTranslationToCenter.translate(5.0, 6.0); + parentTranslationToCenter.translate(5, 6); // Sublayer matrix is applied to the center of the parent layer. parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse(); WebTransformationMatrix flattenedCompositeTransform = remove3DComponentOfMatrix(parentCompositeTransform); - setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false); + setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); executeCalculateDrawTransformsAndVisibility(parent.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform()); @@ -311,9 +306,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) // Case 5: same as Case 4, except that child does preserve 3D, so the grandChild should receive the non-flattened composite transform. // - setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), true); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false); + setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), true); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); executeCalculateDrawTransformsAndVisibility(parent.get()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform()); @@ -331,28 +326,28 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) child->addChild(grandChild); // Child is set up so that a new render surface should be created. - child->setOpacity(0.5f); + child->setOpacity(0.5); WebTransformationMatrix identityMatrix; WebTransformationMatrix parentLayerTransform; - parentLayerTransform.scale3d(2.0, 2.0, 1.0); + parentLayerTransform.scale3d(2, 2, 1); WebTransformationMatrix parentTranslationToAnchor; - parentTranslationToAnchor.translate(2.5, 3.0); + parentTranslationToAnchor.translate(2.5, 3); WebTransformationMatrix parentSublayerMatrix; - parentSublayerMatrix.scale3d(10.0, 10.0, 3.3); + parentSublayerMatrix.scale3d(10, 10, 3.3); WebTransformationMatrix parentTranslationToCenter; - parentTranslationToCenter.translate(5.0, 6.0); + parentTranslationToCenter.translate(5, 6); WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse(); WebTransformationMatrix childTranslationToCenter; - childTranslationToCenter.translate(8.0, 9.0); + childTranslationToCenter.translate(8, 9); // Child's render surface should not exist yet. ASSERT_FALSE(child->renderSurface()); - setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(-0.5f, -0.5f), IntSize(1, 1), false); + setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-0.5, -0.5), IntSize(1, 1), false); executeCalculateDrawTransformsAndVisibility(parent.get()); // Render surface should have been created now. @@ -411,7 +406,7 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) child->setAnchorPoint(FloatPoint(0, 0)); child->setPosition(FloatPoint(childRect.x(), childRect.y())); - child->setOpacity(0.5f); + child->setOpacity(0.5); child->setBounds(IntSize(childRect.width(), childRect.height())); child->setDrawsContent(true); @@ -590,7 +585,7 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) child->setAnchorPoint(FloatPoint(0, 0)); child->setPosition(FloatPoint(childRect.x(), childRect.y())); - child->setOpacity(0.5f); + child->setOpacity(0.5); child->setBounds(IntSize(childRect.width(), childRect.height())); child->setDrawsContent(true); @@ -772,19 +767,19 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) child->setAnchorPoint(FloatPoint(0, 0)); child->setPosition(FloatPoint(childRect.x(), childRect.y())); - child->setOpacity(0.5f); + child->setOpacity(0.5); child->setBounds(IntSize(childRect.width(), childRect.height())); child->setDrawsContent(true); grandChild->setAnchorPoint(FloatPoint(0, 0)); grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); - grandChild->setOpacity(0.5f); + grandChild->setOpacity(0.5); grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height())); grandChild->setDrawsContent(true); grandChild2->setAnchorPoint(FloatPoint(0, 0)); grandChild2->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); - grandChild2->setOpacity(0.5f); + grandChild2->setOpacity(0.5); grandChild2->setBounds(IntSize(grandChildRect.width(), grandChildRect.height())); grandChild2->setDrawsContent(true); @@ -936,32 +931,32 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica) child->setReplicaLayer(childReplica.get()); // Child is set up so that a new render surface should be created. - child->setOpacity(0.5f); + child->setOpacity(0.5); WebTransformationMatrix identityMatrix; WebTransformationMatrix parentLayerTransform; - parentLayerTransform.scale3d(2.0, 2.0, 1.0); + parentLayerTransform.scale3d(2, 2, 1); WebTransformationMatrix parentTranslationToAnchor; - parentTranslationToAnchor.translate(2.5, 3.0); + parentTranslationToAnchor.translate(2.5, 3); WebTransformationMatrix parentSublayerMatrix; - parentSublayerMatrix.scale3d(10.0, 10.0, 3.3); + parentSublayerMatrix.scale3d(10, 10, 3.3); WebTransformationMatrix parentTranslationToCenter; - parentTranslationToCenter.translate(5.0, 6.0); + parentTranslationToCenter.translate(5, 6); WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse(); WebTransformationMatrix childTranslationToCenter; - childTranslationToCenter.translate(8.0, 9.0); + childTranslationToCenter.translate(8, 9); WebTransformationMatrix replicaLayerTransform; - replicaLayerTransform.scale3d(3.0, 3.0, 1.0); + replicaLayerTransform.scale3d(3, 3, 1); WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform; // Child's render surface should not exist yet. ASSERT_FALSE(child->renderSurface()); - setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false); - setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false); - setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(-0.5f, -0.5f), IntSize(1, 1), false); - setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false); + setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); + setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); + setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-0.5, -0.5), IntSize(1, 1), false); + setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); executeCalculateDrawTransformsAndVisibility(parent.get()); // Render surface should have been created now. @@ -1005,42 +1000,42 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) renderSurface2->setReplicaLayer(replicaOfRS2.get()); // In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface. - renderSurface1->setOpacity(0.5f); + renderSurface1->setOpacity(0.5); renderSurface2->setOpacity(0.33f); - // All layers in the tree are initialized with an anchor at 2.5 and a size of (10,10). + // All layers in the tree are initialized with an anchor at .25 and a size of (10,10). // matrix "A" is the composite layer transform used in all layers, centered about the anchor point // matrix "B" is the sublayer transform used in all layers, centered about the center position of the layer. // matrix "R" is the composite replica transform used in all replica layers. // // x component tests that layerTransform and sublayerTransform are done in the right order (translation and scale are noncommutative). - // y component has a translation by 1.0 for every ancestor, which indicates the "depth" of the layer in the hierarchy. + // y component has a translation by 1 for every ancestor, which indicates the "depth" of the layer in the hierarchy. WebTransformationMatrix translationToAnchor; - translationToAnchor.translate(2.5, 0.0); + translationToAnchor.translate(2.5, 0); WebTransformationMatrix translationToCenter; - translationToCenter.translate(5.0, 5.0); + translationToCenter.translate(5, 5); WebTransformationMatrix layerTransform; - layerTransform.translate(1.0, 1.0); + layerTransform.translate(1, 1); WebTransformationMatrix sublayerTransform; - sublayerTransform.scale3d(10.0, 1.0, 1.0); + sublayerTransform.scale3d(10, 1, 1); WebTransformationMatrix replicaLayerTransform; - replicaLayerTransform.scale3d(-2.0, 5.0, 1.0); + replicaLayerTransform.scale3d(-2, 5, 1); WebTransformationMatrix A = translationToAnchor * layerTransform * translationToAnchor.inverse(); WebTransformationMatrix B = translationToCenter * sublayerTransform * translationToCenter.inverse(); WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse(); - setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, sublayerTransform, FloatPoint(), FloatPoint(2.5f, 0.0f), IntSize(), false); - setLayerPropertiesForTesting(replicaOfRS2.get(), replicaLayerTransform, sublayerTransform, FloatPoint(), FloatPoint(2.5f, 0.0f), IntSize(), false); + setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(), false); + setLayerPropertiesForTesting(replicaOfRS2.get(), replicaLayerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(), false); executeCalculateDrawTransformsAndVisibility(parent.get()); @@ -1118,17 +1113,17 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) // Sanity check. If these fail there is probably a bug in the test itself. // It is expected that we correctly set up transforms so that the y-component of the screen-space transform // encodes the "depth" of the layer in the tree. - EXPECT_FLOAT_EQ(1.0, parent->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(2.0, childOfRoot->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, grandChildOfRoot->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(2.0, renderSurface1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, childOfRS1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(4.0, grandChildOfRS1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, renderSurface2->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(4.0, childOfRS2->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(5.0, grandChildOfRS2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); } TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForClipLayer) @@ -1860,7 +1855,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) child->setMasksToBounds(true); child->setOpacity(0.4f); - grandChild->setOpacity(0.5f); + grandChild->setOpacity(0.5); greatGrandChild->setOpacity(0.4f); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; @@ -1913,7 +1908,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfacesCrashRepro) child->setMasksToBounds(true); child->setOpacity(0.4f); - grandChild->setOpacity(0.5f); + grandChild->setOpacity(0.5); greatGrandChild->setOpacity(0.4f); // Contaminate the grandChild and greatGrandChild's clipRect to reproduce the crash @@ -2053,10 +2048,10 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToLayers) // Force everyone to be a render surface. child->setOpacity(0.4f); - grandChild1->setOpacity(0.5f); - grandChild2->setOpacity(0.5f); - grandChild3->setOpacity(0.5f); - grandChild4->setOpacity(0.5f); + grandChild1->setOpacity(0.5); + grandChild2->setOpacity(0.5); + grandChild3->setOpacity(0.5); + grandChild4->setOpacity(0.5); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > dummyLayerList; @@ -2128,10 +2123,10 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) // Force everyone to be a render surface. child->setOpacity(0.4f); - grandChild1->setOpacity(0.5f); - grandChild2->setOpacity(0.5f); - grandChild3->setOpacity(0.5f); - grandChild4->setOpacity(0.5f); + grandChild1->setOpacity(0.5); + grandChild2->setOpacity(0.5); + grandChild3->setOpacity(0.5); + grandChild4->setOpacity(0.5); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > dummyLayerList; @@ -2194,9 +2189,9 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController(), 10, 1, 0, false); WebTransformationMatrix layerTransform; - layerTransform.translate(1.0, 1.0); + layerTransform.translate(1, 1); WebTransformationMatrix sublayerTransform; - sublayerTransform.scale3d(10.0, 1.0, 1.0); + sublayerTransform.scale3d(10, 1, 1); // Put a transform animation on the render surface. addAnimatedTransformToController(*renderSurface2->layerAnimationController(), 10, 30, 0); @@ -2205,15 +2200,15 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController(), 10, 30, 0); addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(), 10, 30, 0); - setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); - setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false); + setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); + setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(2.5, 0), IntSize(10, 10), false); executeCalculateDrawTransformsAndVisibility(parent.get()); @@ -2291,17 +2286,17 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) // Sanity check. If these fail there is probably a bug in the test itself. // It is expected that we correctly set up transforms so that the y-component of the screen-space transform // encodes the "depth" of the layer in the tree. - EXPECT_FLOAT_EQ(1.0, parent->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(2.0, childOfRoot->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, grandChildOfRoot->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(2.0, renderSurface1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, childOfRS1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(4.0, grandChildOfRS1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(3.0, renderSurface2->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(4.0, childOfRS2->screenSpaceTransform().m42()); - EXPECT_FLOAT_EQ(5.0, grandChildOfRS2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); + EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); } TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) @@ -2424,7 +2419,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) // Case 2: Orthographic projection of a layer rotated about y-axis by 45 degrees, but // shifted to the side so only the right-half the layer would be visible on // the surface. - double halfWidthOfRotatedLayer = (100.0 / sqrt(2.0)) * 0.5; // 100.0 is the un-rotated layer width; divided by sqrt(2.0) is the rotated width. + double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width. layerToSurfaceTransform.makeIdentity(); layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge of the layer @@ -2605,8 +2600,8 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) backfaceMatrix.translate(-50, -50); // Having a descendant and opacity will force these to have render surfaces. - frontFacingSurface->setOpacity(0.5f); - backFacingSurface->setOpacity(0.5f); + frontFacingSurface->setOpacity(0.5); + backFacingSurface->setOpacity(0.5); // Nothing preserves 3d. According to current W3C CSS Transforms spec, these layers // should blindly use their own local transforms to determine back-face culling. diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp index e9b9f0281..dd525fcbf 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp @@ -28,6 +28,7 @@ #include "CCAnimationTestCommon.h" #include "CCLayerTestCommon.h" +#include "CCLayerTreeTestCommon.h" #include "CCTestCommon.h" #include "FakeWebGraphicsContext3D.h" #include "LayerRendererChromium.h" @@ -134,6 +135,8 @@ public: root->setScrollable(true); root->setScrollPosition(IntPoint(0, 0)); root->setMaxScrollPosition(contentSize); + root->setBounds(contentSize); + root->setContentBounds(contentSize); OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2); contents->setDrawsContent(true); contents->setBounds(contentSize); @@ -598,12 +601,12 @@ class DidDrawCheckLayer : public CCTiledLayerImpl { public: static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new DidDrawCheckLayer(id)); } - virtual void didDraw() + virtual void didDraw(CCResourceProvider*) OVERRIDE { m_didDrawCalled = true; } - virtual void willDraw(CCRenderer*, CCGraphicsContext*) + virtual void willDraw(CCResourceProvider*) OVERRIDE { m_willDrawCalled = true; } @@ -753,18 +756,20 @@ TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) class MissingTextureAnimatingLayer : public DidDrawCheckLayer { public: - static PassOwnPtr<MissingTextureAnimatingLayer> create(int id, bool tileMissing, bool skipsDraw, bool animating) { return adoptPtr(new MissingTextureAnimatingLayer(id, tileMissing, skipsDraw, animating)); } + static PassOwnPtr<MissingTextureAnimatingLayer> create(int id, bool tileMissing, bool skipsDraw, bool animating, CCResourceProvider* resourceProvider) { return adoptPtr(new MissingTextureAnimatingLayer(id, tileMissing, skipsDraw, animating, resourceProvider)); } private: - explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDraw, bool animating) + explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDraw, bool animating, CCResourceProvider* resourceProvider) : DidDrawCheckLayer(id) { OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::NoBorderTexels); tilingData->setBounds(bounds()); setTilingData(*tilingData.get()); setSkipsDraw(skipsDraw); - if (!tileMissing) - pushTileProperties(0, 0, 1, IntRect()); + if (!tileMissing) { + CCResourceProvider::ResourceId resource = resourceProvider->createResource(CCRenderer::ContentPool, IntSize(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny); + pushTileProperties(0, 0, resource, IntRect()); + } if (animating) addAnimatedTransformToLayer(*this, 10, 3, 0); } @@ -775,7 +780,7 @@ TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) // When the texture is not missing, we draw as usual. m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); - root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true)); + root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m_hostImpl->resourceProvider())); CCLayerTreeHostImpl::FrameData frame; @@ -786,7 +791,7 @@ TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) // When a texture is missing and we're not animating, we draw as usual with checkerboarding. m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); - root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false)); + root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false, m_hostImpl->resourceProvider())); EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); m_hostImpl->drawLayers(frame); @@ -795,7 +800,7 @@ TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) // When a texture is missing and we're animating, we don't want to draw anything. m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); - root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true)); + root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true, m_hostImpl->resourceProvider())); EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); m_hostImpl->drawLayers(frame); @@ -804,7 +809,7 @@ TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) // When the layer skips draw and we're animating, we still draw the frame. m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); - root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true)); + root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_hostImpl->resourceProvider())); EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); m_hostImpl->drawLayers(frame); @@ -857,7 +862,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) { IntSize surfaceSize(10, 10); OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); - root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); + root->addChild(createScrollableLayer(2, FloatPoint(0, 0), surfaceSize)); m_hostImpl->setRootLayer(root.release()); m_hostImpl->setViewportSize(surfaceSize); initializeLayerRendererAndDrawFrame(); @@ -873,7 +878,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) { IntSize surfaceSize(10, 10); OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); - root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); + root->addChild(createScrollableLayer(2, FloatPoint(0, 0), surfaceSize)); m_hostImpl->setRootLayer(root.release()); m_hostImpl->setViewportSize(surfaceSize); initializeLayerRendererAndDrawFrame(); @@ -888,7 +893,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) { IntSize surfaceSize(10, 10); OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); - OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(0, 0), surfaceSize); m_hostImpl->setViewportSize(surfaceSize); WebTransformationMatrix matrix; @@ -910,11 +915,11 @@ TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) { IntSize surfaceSize(10, 10); - OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize); contentLayer->setShouldScrollOnMainThread(true); contentLayer->setScrollable(false); - OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, FloatPoint(0, 0), surfaceSize); scrollLayer->addChild(contentLayer.release()); m_hostImpl->setRootLayer(scrollLayer.release()); @@ -929,7 +934,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) { IntSize surfaceSize(10, 10); float pageScale = 2; - OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize); m_hostImpl->setRootLayer(root.release()); m_hostImpl->setViewportSize(surfaceSize); initializeLayerRendererAndDrawFrame(); @@ -960,7 +965,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) { IntSize surfaceSize(10, 10); float pageScale = 2; - OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize); m_hostImpl->setRootLayer(root.release()); m_hostImpl->setViewportSize(surfaceSize); m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); @@ -1000,7 +1005,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) CCLayerImpl* root = m_hostImpl->rootLayer(); CCLayerImpl* child = root->children()[0].get(); - OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, FloatPoint(0, 0), surfaceSize); child->addChild(scrollableChild.release()); CCLayerImpl* grandChild = child->children()[0].get(); @@ -1023,6 +1028,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) WebTransformationMatrix pageScaleTransform; pageScaleTransform.scale(newPageScale); + pageScaleTransform.translate(0.5 * surfaceSize.width(), 0.5 * surfaceSize.height()); EXPECT_EQ(root->drawTransform(), pageScaleTransform); EXPECT_EQ(child->drawTransform(), pageScaleTransform); EXPECT_EQ(grandChild->drawTransform(), pageScaleTransform); @@ -1035,7 +1041,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) // Also mark the root scrollable so it becomes the root scroll layer. root->setScrollable(true); int scrollLayerId = 2; - root->addChild(createScrollableLayer(scrollLayerId, FloatPoint(5, 5), surfaceSize)); + root->addChild(createScrollableLayer(scrollLayerId, FloatPoint(0, 0), surfaceSize)); m_hostImpl->setRootLayer(root.release()); m_hostImpl->setViewportSize(surfaceSize); initializeLayerRendererAndDrawFrame(); @@ -1070,12 +1076,12 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) // parent layer is scrolled on the axis on which the child was unable to // scroll. IntSize surfaceSize(10, 10); - OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize); - OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, FloatPoint(0, 0), surfaceSize); grandChild->setScrollPosition(IntPoint(0, 5)); - OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(0, 0), surfaceSize); child->setScrollPosition(IntPoint(3, 0)); child->addChild(grandChild.release()); @@ -1106,8 +1112,8 @@ TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) // When we try to scroll a non-scrollable child layer, the scroll delta // should be applied to one of its ancestors if possible. IntSize surfaceSize(10, 10); - OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize); - OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize); + OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize); + OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(0, 0), surfaceSize); child->setScrollable(false); root->addChild(child.release()); @@ -1132,13 +1138,13 @@ TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) TEST_F(CCLayerTreeHostImplTest, scrollBeforeRedraw) { IntSize surfaceSize(10, 10); - m_hostImpl->setRootLayer(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize)); + m_hostImpl->setRootLayer(createScrollableLayer(1, FloatPoint(0, 0), surfaceSize)); m_hostImpl->setViewportSize(surfaceSize); // Draw one frame and then immediately rebuild the layer tree to mimic a tree synchronization. initializeLayerRendererAndDrawFrame(); m_hostImpl->detachLayerTree(); - m_hostImpl->setRootLayer(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize)); + m_hostImpl->setRootLayer(createScrollableLayer(2, FloatPoint(0, 0), surfaceSize)); // Scrolling should still work even though we did not draw yet. EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted); @@ -1168,9 +1174,9 @@ private: class BlendStateCheckLayer : public CCLayerImpl { public: - static PassOwnPtr<BlendStateCheckLayer> create(int id) { return adoptPtr(new BlendStateCheckLayer(id)); } + static PassOwnPtr<BlendStateCheckLayer> create(int id, CCResourceProvider* resourceProvider) { return adoptPtr(new BlendStateCheckLayer(id, resourceProvider)); } - virtual void appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&) OVERRIDE + virtual void appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&) OVERRIDE { m_quadsAppended = true; @@ -1179,7 +1185,7 @@ public: opaqueRect = m_quadRect; else opaqueRect = m_opaqueContentRect; - OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCTileDrawQuad::create(sharedQuadState, m_quadRect, opaqueRect, 0, IntPoint(), IntSize(1, 1), 0, false, false, false, false, false); + OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCTileDrawQuad::create(sharedQuadState, m_quadRect, opaqueRect, m_resourceId, IntPoint(), IntSize(1, 1), 0, false, false, false, false, false); testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); @@ -1201,7 +1207,7 @@ public: void setOpaqueContentRect(const IntRect& rect) { m_opaqueContentRect = rect; } private: - explicit BlendStateCheckLayer(int id) + explicit BlendStateCheckLayer(int id, CCResourceProvider* resourceProvider) : CCLayerImpl(id) , m_blend(false) , m_hasRenderSurface(false) @@ -1209,6 +1215,7 @@ private: , m_opaqueContents(false) , m_quadRect(5, 5, 5, 5) , m_quadVisibleRect(5, 5, 5, 5) + , m_resourceId(resourceProvider->createResource(CCRenderer::ContentPool, IntSize(1, 1), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny)) { setAnchorPoint(FloatPoint(0, 0)); setBounds(IntSize(10, 10)); @@ -1223,6 +1230,7 @@ private: IntRect m_quadRect; IntRect m_opaqueContentRect; IntRect m_quadVisibleRect; + CCResourceProvider::ResourceId m_resourceId; }; TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) @@ -1237,7 +1245,7 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) } CCLayerImpl* root = m_hostImpl->rootLayer(); - root->addChild(BlendStateCheckLayer::create(2)); + root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider())); BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->children()[0].get()); layer1->setPosition(FloatPoint(2, 2)); @@ -1290,7 +1298,7 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) EXPECT_TRUE(layer1->quadsAppended()); m_hostImpl->didDrawAllLayers(frame); - layer1->addChild(BlendStateCheckLayer::create(3)); + layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvider())); BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->children()[0].get()); layer2->setPosition(FloatPoint(4, 4)); @@ -1451,7 +1459,7 @@ TEST_F(CCLayerTreeHostImplTest, viewportCovered) IntSize viewportSize(1000, 1000); m_hostImpl->setViewportSize(viewportSize); - m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1)); + m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourceProvider())); BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->rootLayer()); root->setExpectation(false, true); root->setOpaque(true); @@ -1695,10 +1703,10 @@ class FakeLayerWithQuads : public CCLayerImpl { public: static PassOwnPtr<FakeLayerWithQuads> create(int id) { return adoptPtr(new FakeLayerWithQuads(id)); } - virtual void appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&) OVERRIDE + virtual void appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&) OVERRIDE { SkColor gray = SkColorSetRGB(100, 100, 100); - IntRect quadRect(0, 0, 5, 5); + IntRect quadRect(IntPoint(0, 0), contentBounds()); OwnPtr<CCDrawQuad> myQuad = CCSolidColorDrawQuad::create(sharedQuadState, quadRect, gray); quadList.append(myQuad.release()); } @@ -2469,6 +2477,21 @@ TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground) Mock::VerifyAndClearExpectations(&mockContext); } +static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerRect, CCLayerImpl** result) +{ + OwnPtr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); + CCLayerImpl* layerPtr = layer.get(); + layerPtr->setAnchorPoint(FloatPoint(0, 0)); + layerPtr->setPosition(FloatPoint(layerRect.location())); + layerPtr->setBounds(layerRect.size()); + layerPtr->setContentBounds(layerRect.size()); + layerPtr->setDrawsContent(true); // only children draw content + layerPtr->setOpaque(true); + parent->addChild(layer.release()); + if (result) + *result = layerPtr; +} + static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfaceLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) { OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); @@ -2483,50 +2506,20 @@ static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, root->setPosition(FloatPoint(0, 0)); root->setBounds(rootSize); root->setContentBounds(rootSize); - root->setVisibleContentRect(IntRect(IntPoint(0, 0), rootSize)); root->setDrawsContent(true); layerTreeHostImpl->setRootLayer(root.release()); - // Intermediate layer does not own a surface, and does not draw content. - OwnPtr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(2); - intermediateLayerPtr = intermediateLayer.get(); - - intermediateLayerPtr->setAnchorPoint(FloatPoint(0, 0)); - intermediateLayerPtr->setPosition(FloatPoint(10, 10)); - intermediateLayerPtr->setBounds(rootSize); - intermediateLayerPtr->setContentBounds(rootSize); - intermediateLayerPtr->setVisibleContentRect(IntRect(IntPoint(0, 0), rootSize)); + addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.height()), &intermediateLayerPtr); intermediateLayerPtr->setDrawsContent(false); // only children draw content - rootPtr->addChild(intermediateLayer.release()); - - OwnPtr<CCLayerImpl> surfaceLayer = CCLayerImpl::create(3); - surfaceLayerPtr = surfaceLayer.get(); // Surface layer is the layer that changes its opacity // It will contain other layers that draw content. - IntSize surfaceSize(rootSize.width(), rootSize.height()); - surfaceLayerPtr->setAnchorPoint(FloatPoint(0, 0)); - surfaceLayerPtr->setPosition(FloatPoint(10, 10)); - surfaceLayerPtr->setBounds(surfaceSize); - surfaceLayerPtr->setContentBounds(surfaceSize); - surfaceLayerPtr->setVisibleContentRect(IntRect(IntPoint(0, 0), surfaceSize)); + addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr); surfaceLayerPtr->setDrawsContent(false); // only children draw content surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface - intermediateLayerPtr->addChild(surfaceLayer.release()); // Child of the surface layer will produce some quads - OwnPtr<FakeLayerWithQuads> child = FakeLayerWithQuads::create(4); - childPtr = child.get(); - - IntSize childSize(rootSize.width(), rootSize.height()); - childPtr->setAnchorPoint(FloatPoint(0, 0)); - childPtr->setPosition(FloatPoint(5, 5)); - childPtr->setBounds(childSize); - childPtr->setContentBounds(childSize); - childPtr->setVisibleContentRect(IntRect(IntPoint(0, 0), childSize)); - childPtr->setDrawsContent(true); - - surfaceLayerPtr->addChild(child.release()); + addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width(), rootSize.height()), &childPtr); } class LayerRendererChromiumWithReleaseTextures : public LayerRendererChromium { @@ -2534,6 +2527,612 @@ public: using LayerRendererChromium::releaseRenderPassTextures; }; +TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping) +{ + CCSettings::setPartialSwapEnabled(true); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + CCLayerImpl* rootPtr; + CCLayerImpl* surfaceLayerPtr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(100, 100); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.height()), &surfaceLayerPtr); + surfaceLayerPtr->setDrawsContent(false); + + // Surface layer is the layer that changes its opacity + // It will contain other layers that draw content. + surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface + + addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); + addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); + + // Rotation will put part of the child ouside the bounds of the root layer. + // Nevertheless, the child layers should be drawn. + WebTransformationMatrix transform = surfaceLayerPtr->transform(); + transform.translate(50, 50); + transform.rotate(35); + transform.translate(-50, -50); + surfaceLayerPtr->setTransform(transform); + + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive two render passes, each with one quad + ASSERT_EQ(2U, frame.renderPasses.size()); + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); + + // Verify that the child layers have been drawn entirely. + IntRect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVisibleRect(); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 3), quadVisibleRect); + + quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect(); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 3), quadVisibleRect); + + EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material()); + CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get()); + EXPECT_FALSE(quad->contentsChangedSinceLastFrame().isEmpty()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + transform = surfaceLayerPtr->transform(); + transform.translate(50, 50); + transform.rotate(-35); + transform.translate(-50, -50); + surfaceLayerPtr->setTransform(transform); + + // The surface is now aligned again, and the clipped parts are exposed. + // That should be OK, as we've already verified that the quads are drawn in full. + // Verify that the render pass is removed. + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive a single render pass using a cached texture. + ASSERT_EQ(1U, frame.renderPasses.size()); + EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } +} + +TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion) +{ + CCSettings::setPartialSwapEnabled(false); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + // Layers are structure as follows: + // + // R +-- S1 +- L10 (owning) + // | +- L11 + // | +- L12 + // | + // +-- S2 +- L20 (owning) + // +- L21 + // + // Occlusion: + // L12 occludes L11 (internal) + // L20 occludes L10 (external) + // L21 occludes L20 (internal) + + CCLayerImpl* rootPtr; + CCLayerImpl* layerS1Ptr; + CCLayerImpl* layerS2Ptr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(1000, 1000); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); + layerS1Ptr->setForceRenderSurface(true); + + addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 + addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 + + addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); + layerS2Ptr->setForceRenderSurface(true); + + addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 + + // Initial draw - must receive all quads + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 3 render passes. + // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. + ASSERT_EQ(3U, frame.renderPasses.size()); + + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size()); + EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Unocclude" surface S1 and repeat draw. + // Must remove S2's render pass since it's cached; + // Must keep S1 quads because texture contained external occlusion. + WebTransformationMatrix transform = layerS2Ptr->transform(); + transform.translate(150, 150); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 2 render passes. + // For Root, there are 2 quads + // For S1, the number of quads depends on what got unoccluded, so not asserted beyond being positive. + // For S2, there is no render pass + ASSERT_EQ(2U, frame.renderPasses.size()); + + EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); + EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Re-occlude" surface S1 and repeat draw. + // Must remove S1's render pass since it is now available in full. + // S2 has no change so must also be removed. + transform = layerS2Ptr->transform(); + transform.translate(-15, -15); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 1 render pass - for the root. + ASSERT_EQ(1U, frame.renderPasses.size()); + + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + +} + +TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) +{ + CCSettings::setPartialSwapEnabled(false); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + // Layers are structure as follows: + // + // R +-- S1 +- L10 (owning, non drawing) + // | +- L11 (corner, unoccluded) + // | +- L12 (corner, unoccluded) + // | +- L13 (corner, unoccluded) + // | +- L14 (corner, entirely occluded) + // | + // +-- S2 +- L20 (owning, drawing) + // + + CCLayerImpl* rootPtr; + CCLayerImpl* layerS1Ptr; + CCLayerImpl* layerS2Ptr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(1000, 1000); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); + layerS1Ptr->setForceRenderSurface(true); + layerS1Ptr->setDrawsContent(false); + + addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 + addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 + addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 + addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 + addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 + + addDrawingLayerTo(rootPtr, 7, IntRect(450, 450, 450, 450), &layerS2Ptr); + layerS2Ptr->setForceRenderSurface(true); + + // Initial draw - must receive all quads + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 3 render passes. + // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. + ASSERT_EQ(3U, frame.renderPasses.size()); + + EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); + + // L14 is culled, so only 3 quads. + EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size()); + EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Unocclude" surface S1 and repeat draw. + // Must remove S2's render pass since it's cached; + // Must keep S1 quads because texture contained external occlusion. + WebTransformationMatrix transform = layerS2Ptr->transform(); + transform.translate(100, 100); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 2 render passes. + // For Root, there are 2 quads + // For S1, the number of quads depends on what got unoccluded, so not asserted beyond being positive. + // For S2, there is no render pass + ASSERT_EQ(2U, frame.renderPasses.size()); + + EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); + EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Re-occlude" surface S1 and repeat draw. + // Must remove S1's render pass since it is now available in full. + // S2 has no change so must also be removed. + transform = layerS2Ptr->transform(); + transform.translate(-15, -15); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 1 render pass - for the root. + ASSERT_EQ(1U, frame.renderPasses.size()); + + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } +} + +TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) +{ + CCSettings::setPartialSwapEnabled(false); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + // Layers are structured as follows: + // + // R +-- S1 +- L10 (owning, drawing) + // | +- L11 (corner, occluded by L12) + // | +- L12 (opposite corner) + // | + // +-- S2 +- L20 (owning, drawing) + // + + CCLayerImpl* rootPtr; + CCLayerImpl* layerS1Ptr; + CCLayerImpl* layerS2Ptr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(1000, 1000); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); + layerS1Ptr->setForceRenderSurface(true); + + addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 + addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 + + addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); + layerS2Ptr->setForceRenderSurface(true); + + // Initial draw - must receive all quads + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 3 render passes. + // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. + ASSERT_EQ(3U, frame.renderPasses.size()); + + EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); + EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size()); + EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Unocclude" surface S1 and repeat draw. + // Must remove S2's render pass since it's cached; + // Must keep S1 quads because texture contained external occlusion. + WebTransformationMatrix transform = layerS2Ptr->transform(); + transform.translate(300, 0); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 2 render passes. + // For Root, there are 2 quads + // For S1, the number of quads depends on what got unoccluded, so not asserted beyond being positive. + // For S2, there is no render pass + ASSERT_EQ(2U, frame.renderPasses.size()); + + EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); + EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } +} + +TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) +{ + CCSettings::setPartialSwapEnabled(false); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + // Layers are structured as follows: + // + // R +-- S1 +- L10 (rotated, drawing) + // +- L11 (occupies half surface) + + CCLayerImpl* rootPtr; + CCLayerImpl* layerS1Ptr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(1000, 1000); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); + layerS1Ptr->setForceRenderSurface(true); + WebTransformationMatrix transform = layerS1Ptr->transform(); + transform.translate(200, 200); + transform.rotate(45); + transform.translate(-200, -200); + layerS1Ptr->setTransform(transform); + + addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 + + // Initial draw - must receive all quads + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 2 render passes. + ASSERT_EQ(2U, frame.renderPasses.size()); + + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // Change opacity and draw. Verify we used cached texture. + layerS1Ptr->setOpacity(0.2f); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // One render pass must be gone due to cached texture. + ASSERT_EQ(1U, frame.renderPasses.size()); + + EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } +} + +TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) +{ + CCSettings::setPartialSwapEnabled(true); + + CCLayerTreeSettings settings; + OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this); + + // Layers are structure as follows: + // + // R +-- S1 +- L10 (owning) + // | +- L11 + // | +- L12 + // | + // +-- S2 +- L20 (owning) + // +- L21 + // + // Occlusion: + // L12 occludes L11 (internal) + // L20 occludes L10 (external) + // L21 occludes L20 (internal) + + CCLayerImpl* rootPtr; + CCLayerImpl* layerS1Ptr; + CCLayerImpl* layerS2Ptr; + + OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext)); + + IntSize rootSize(1000, 1000); + + myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); + myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height())); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + rootPtr = root.get(); + + root->setAnchorPoint(FloatPoint(0, 0)); + root->setPosition(FloatPoint(0, 0)); + root->setBounds(rootSize); + root->setContentBounds(rootSize); + root->setDrawsContent(true); + root->setMasksToBounds(true); + myHostImpl->setRootLayer(root.release()); + + addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); + layerS1Ptr->setForceRenderSurface(true); + + addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 + addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 + + addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); + layerS2Ptr->setForceRenderSurface(true); + + addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 + + // Initial draw - must receive all quads + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 3 render passes. + // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. + ASSERT_EQ(3U, frame.renderPasses.size()); + + EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); + EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size()); + EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Unocclude" surface S1 and repeat draw. + // Must remove S2's render pass since it's cached; + // Must keep S1 quads because texture contained external occlusion. + WebTransformationMatrix transform = layerS2Ptr->transform(); + transform.translate(150, 150); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // Must receive 2 render passes. + // For Root, there are 2 quads + // For S1, the number of quads depends on what got unoccluded, so not asserted beyond being positive. + // For S2, there is no render pass + ASSERT_EQ(2U, frame.renderPasses.size()); + + EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); + EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + + // "Re-occlude" surface S1 and repeat draw. + // Must remove S1's render pass since it is now available in full. + // S2 has no change so must also be removed. + // FIXME: Due to partial swap, the scissor rect will cause OcclusionTracker + // to think there is an external occlusion in the previous step. Therefore, + // S1's render pass will not be removed. + transform = layerS2Ptr->transform(); + transform.translate(-15, -15); + layerS2Ptr->setTransform(transform); + { + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); + + // 2 Render passes - Root and S1. + ASSERT_EQ(2U, frame.renderPasses.size()); + + // Render pass for S1 contains no quads as the scissor rect is now occluded. + EXPECT_EQ(0U, frame.renderPasses[0]->quadList().size()); + + // Root contains S2 only, as S1 doesn't have any damage. + EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); + + myHostImpl->drawLayers(frame); + myHostImpl->didDrawAllLayers(frame); + } + +} + TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching) { CCSettings::setPartialSwapEnabled(true); @@ -2969,9 +3568,9 @@ protected: class CCTestRenderer : public LayerRendererChromium, public CCRendererClient { public: - static PassOwnPtr<CCTestRenderer> create(WebKit::WebGraphicsContext3D* context) + static PassOwnPtr<CCTestRenderer> create(CCResourceProvider* resourceProvider) { - OwnPtr<CCTestRenderer> renderer(adoptPtr(new CCTestRenderer(context))); + OwnPtr<CCTestRenderer> renderer(adoptPtr(new CCTestRenderer(resourceProvider))); if (!renderer->initialize()) return nullptr; @@ -2993,7 +3592,7 @@ public: virtual void setMemoryAllocationLimitBytes(size_t) OVERRIDE { } protected: - CCTestRenderer(WebKit::WebGraphicsContext3D* context) : LayerRendererChromium(this, context, UnthrottledUploader) { } + CCTestRenderer(CCResourceProvider* resourceProvider) : LayerRendererChromium(this, resourceProvider, UnthrottledUploader) { } private: CCLayerTreeSettings m_settings; @@ -3017,7 +3616,7 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova renderer->clearCachedTextures(); // One shared state for all quads - we don't need the correct details - testData.sharedQuadState = CCSharedQuadState::create(WebTransformationMatrix(), IntRect(), IntRect(), 1.0, true); + testData.sharedQuadState = CCSharedQuadState::create(0, WebTransformationMatrix(), IntRect(), IntRect(), 1.0, true); const char* currentChar = testScript; @@ -3276,9 +3875,10 @@ static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses) { OwnPtr<CCGraphicsContext> context(createContext()); - WebKit::WebGraphicsContext3D* context3d = context->context3D(); - ASSERT_TRUE(context3d); - OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(context3d)); + ASSERT_TRUE(context->context3D()); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + + OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(resourceProvider.get())); int testCaseIndex = 0; while (removeRenderPassesCases[testCaseIndex].name) { diff --git a/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp b/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp index 21e0a717c..97027095e 100644 --- a/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp +++ b/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp @@ -27,7 +27,9 @@ #include "cc/CCPrioritizedTexture.h" #include "CCTiledLayerTestCommon.h" +#include "FakeCCGraphicsContext.h" #include "cc/CCPrioritizedTextureManager.h" +#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread #include "cc/CCTexture.h" #include <gtest/gtest.h> @@ -42,11 +44,16 @@ public: CCPrioritizedTextureTest() : m_textureSize(256, 256) , m_textureFormat(GraphicsContext3D::RGBA) + , m_context(WebKit::createFakeCCGraphicsContext()) { + DebugScopedSetImplThread implThread; + m_resourceProvider = CCResourceProvider::create(m_context.get()); } virtual ~CCPrioritizedTextureTest() { + DebugScopedSetImplThread implThread; + m_resourceProvider.clear(); } size_t texturesMemorySize(size_t textureCount) @@ -56,11 +63,12 @@ public: PassOwnPtr<CCPrioritizedTextureManager> createManager(size_t maxTextures) { - return CCPrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024); + return CCPrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0); } bool validateTexture(OwnPtr<CCPrioritizedTexture>& texture, bool requestLate) { + DebugScopedSetImplThread implThread; #if !ASSERT_DISABLED texture->textureManager()->assertInvariants(); #endif @@ -68,19 +76,20 @@ public: texture->requestLate(); bool success = texture->canAcquireBackingTexture(); if (success) - texture->acquireBackingTexture(allocator()); + texture->acquireBackingTexture(resourceProvider()); return success; } - FakeTextureAllocator* allocator() + CCResourceProvider* resourceProvider() { - return &m_fakeTextureAllocator; + return m_resourceProvider.get(); } protected: - FakeTextureAllocator m_fakeTextureAllocator; const IntSize m_textureSize; const GC3Denum m_textureFormat; + OwnPtr<CCGraphicsContext> m_context; + OwnPtr<CCResourceProvider> m_resourceProvider; }; TEST_F(CCPrioritizedTextureTest, requestTextureExceedingMaxLimit) @@ -119,7 +128,8 @@ TEST_F(CCPrioritizedTextureTest, requestTextureExceedingMaxLimit) EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoffBytes()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, changeMemoryLimits) @@ -138,7 +148,10 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits) textureManager->prioritizeTextures(); for (size_t i = 0; i < maxTextures; ++i) validateTexture(textures[i], false); - textureManager->reduceMemory(allocator()); + { + DebugScopedSetImplThread implThread; + textureManager->reduceMemory(resourceProvider()); + } EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); @@ -148,7 +161,10 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits) textureManager->prioritizeTextures(); for (size_t i = 0; i < maxTextures; ++i) EXPECT_EQ(validateTexture(textures[i], false), i < 5); - textureManager->reduceMemory(allocator()); + { + DebugScopedSetImplThread implThread; + textureManager->reduceMemory(resourceProvider()); + } EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); @@ -158,12 +174,16 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits) textureManager->prioritizeTextures(); for (size_t i = 0; i < maxTextures; ++i) EXPECT_EQ(validateTexture(textures[i], false), i < 4); - textureManager->reduceMemory(allocator()); + { + DebugScopedSetImplThread implThread; + textureManager->reduceMemory(resourceProvider()); + } EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures) @@ -222,7 +242,8 @@ TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures) EXPECT_FALSE(textures[2]->haveBackingTexture()); EXPECT_FALSE(textures[3]->haveBackingTexture()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, textureManagerPrioritiesAreEqual) @@ -261,7 +282,8 @@ TEST_F(CCPrioritizedTextureTest, textureManagerPrioritiesAreEqual) EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, textureManagerDestroyedFirst) @@ -279,7 +301,10 @@ TEST_F(CCPrioritizedTextureTest, textureManagerDestroyedFirst) EXPECT_TRUE(texture->canAcquireBackingTexture()); EXPECT_TRUE(texture->haveBackingTexture()); - textureManager->clearAllMemory(allocator()); + { + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); + } textureManager.clear(); EXPECT_FALSE(texture->canAcquireBackingTexture()); @@ -304,7 +329,10 @@ TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager) texture->setTextureManager(0); - textureManagerOne->clearAllMemory(allocator()); + { + DebugScopedSetImplThread implThread; + textureManagerOne->clearAllMemory(resourceProvider()); + } textureManagerOne.clear(); EXPECT_FALSE(texture->canAcquireBackingTexture()); @@ -318,7 +346,8 @@ TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager) EXPECT_TRUE(texture->canAcquireBackingTexture()); EXPECT_TRUE(texture->haveBackingTexture()); - textureManagerTwo->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManagerTwo->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSurface) @@ -363,7 +392,8 @@ TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootS EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate) @@ -399,7 +429,8 @@ TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLa EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvailable) @@ -438,7 +469,8 @@ TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAva EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTextures()); EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); - textureManager->clearAllMemory(allocator()); + DebugScopedSetImplThread implThread; + textureManager->clearAllMemory(resourceProvider()); } } // namespace diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp index e1d9fb367..526ab4e59 100644 --- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp +++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp @@ -75,11 +75,11 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const We layer->setBounds(layerRect.size()); layer->setContentBounds(layerRect.size()); - int textureId = 1; + CCResourceProvider::ResourceId resourceId = 1; for (int i = 0; i < tiler->numTilesX(); ++i) for (int j = 0; j < tiler->numTilesY(); ++j) { IntRect tileOpaqueRect = opaque ? tiler->tileBounds(i, j) : intersection(tiler->tileBounds(i, j), layerOpaqueRect); - layer->pushTileProperties(i, j, static_cast<Platform3DObject>(textureId++), tileOpaqueRect); + layer->pushTileProperties(i, j, resourceId++, tileOpaqueRect); } if (!parent) { @@ -97,8 +97,8 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const We static void appendQuads(CCQuadList& quadList, Vector<OwnPtr<CCSharedQuadState> >& sharedStateList, CCTiledLayerImpl* layer, CCLayerIteratorType& it, CCOcclusionTrackerImpl& occlusionTracker) { occlusionTracker.enterLayer(it); - CCQuadCuller quadCuller(quadList, layer, &occlusionTracker, false); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + CCQuadCuller quadCuller(quadList, layer, &occlusionTracker, false, false); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); sharedStateList.append(sharedQuadState.release()); @@ -121,8 +121,8 @@ TEST(CCQuadCullerTest, verifyNoCulling) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, false, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, false, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -138,8 +138,8 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -172,8 +172,8 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -191,8 +191,8 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) childTransform.translate(50, 50); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -234,8 +234,8 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1) rootRect = childRect = IntRect(0, 0, 100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -262,8 +262,8 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2) rootRect = childRect = IntRect(0, 0, 100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -282,8 +282,8 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight) childTransform.translate(100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -301,9 +301,9 @@ TEST(CCQuadCullerTest, verifyCullSubRegion) childTransform.translate(50, 50); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -321,9 +321,9 @@ TEST(CCQuadCullerTest, verifyCullSubRegion2) childTransform.translate(50, 10); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -341,9 +341,9 @@ TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull) childTransform.translate(50, 49); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -362,8 +362,8 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude) // Use a small rotation so as to not disturb the geometry significantly. childTransform.rotate(1); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -388,8 +388,8 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled) WebTransformationMatrix parentTransform; parentTransform.rotate(1); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -405,8 +405,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverTile) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(200, 100, 100, 100)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -422,8 +422,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverCulledTile) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(100, 100, 100, 100)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -439,8 +439,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverPartialTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -456,8 +456,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverNoTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(500, 500, 100, 100)); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); @@ -473,8 +473,8 @@ TEST(CCQuadCullerTest, verifyWithoutMetrics) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, IntRect(), renderSurfaceLayerList); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200), false); CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); diff --git a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp index e9e041749..a989cd602 100644 --- a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp +++ b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp @@ -112,7 +112,7 @@ TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) renderSurface->setScissorRect(clipRect); renderSurface->setDrawOpacity(1); - OwnPtr<CCSharedQuadState> sharedQuadState = renderSurface->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = renderSurface->createSharedQuadState(0); EXPECT_EQ(30, sharedQuadState->quadTransform.m41()); EXPECT_EQ(40, sharedQuadState->quadTransform.m42()); diff --git a/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp b/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp new file mode 100644 index 000000000..57165e6ca --- /dev/null +++ b/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp @@ -0,0 +1,306 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "cc/CCResourceProvider.h" + +#include "CompositorFakeWebGraphicsContext3D.h" +#include "Extensions3DChromium.h" +#include "cc/CCGraphicsContext.h" +#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread +#include <gtest/gtest.h> +#include <public/WebGraphicsContext3D.h> +#include <wtf/HashMap.h> +#include <wtf/OwnArrayPtr.h> +#include <wtf/OwnPtr.h> + +using namespace WebCore; +using namespace WebKit; + +namespace { + +class ResourceProviderContext : public CompositorFakeWebGraphicsContext3D { +public: + static PassOwnPtr<ResourceProviderContext> create() { return adoptPtr(new ResourceProviderContext(Attributes())); } + + virtual void bindTexture(WGC3Denum target, WebGLId texture) + { + ASSERT(target == GraphicsContext3D::TEXTURE_2D); + ASSERT(!texture || m_textures.find(texture) != m_textures.end()); + m_currentTexture = texture; + } + + virtual WebGLId createTexture() + { + WebGLId id = CompositorFakeWebGraphicsContext3D::createTexture(); + m_textures.add(id, nullptr); + return id; + } + + virtual void deleteTexture(WebGLId id) + { + TextureMap::iterator it = m_textures.find(id); + ASSERT(it != m_textures.end()); + m_textures.remove(it); + if (m_currentTexture == id) + m_currentTexture = 0; + } + + virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, + WGC3Dint width, WGC3Dint height) + { + ASSERT(m_currentTexture); + ASSERT(target == GraphicsContext3D::TEXTURE_2D); + ASSERT(levels == 1); + WGC3Denum format = GraphicsContext3D::RGBA; + switch (internalformat) { + case Extensions3D::RGBA8_OES: + break; + case Extensions3DChromium::BGRA8_EXT: + format = Extensions3D::BGRA_EXT; + break; + default: + ASSERT_NOT_REACHED(); + } + allocateTexture(IntSize(width, height), format); + } + + virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) + { + ASSERT(m_currentTexture); + ASSERT(target == GraphicsContext3D::TEXTURE_2D); + ASSERT(!level); + ASSERT(internalformat == format); + ASSERT(!border); + ASSERT(type == GraphicsContext3D::UNSIGNED_BYTE); + allocateTexture(IntSize(width, height), format); + if (pixels) + setPixels(0, 0, width, height, pixels); + } + + virtual void texSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, const void* pixels) + { + ASSERT(m_currentTexture); + ASSERT(target == GraphicsContext3D::TEXTURE_2D); + ASSERT(!level); + ASSERT(m_textures.get(m_currentTexture)); + ASSERT(m_textures.get(m_currentTexture)->format == format); + ASSERT(type == GraphicsContext3D::UNSIGNED_BYTE); + ASSERT(pixels); + setPixels(xoffset, yoffset, width, height, pixels); + } + + void getPixels(const IntSize& size, WGC3Denum format, uint8_t* pixels) + { + ASSERT(m_currentTexture); + Texture* texture = m_textures.get(m_currentTexture); + ASSERT(texture); + ASSERT(texture->size == size); + ASSERT(texture->format == format); + memcpy(pixels, texture->data.get(), textureSize(size, format)); + } + + int textureCount() + { + return m_textures.size(); + } + + static size_t textureSize(const IntSize& size, WGC3Denum format) + { + unsigned int componentsPerPixel = 4; + unsigned int bytesPerComponent = 1; + GraphicsContext3D::computeFormatAndTypeParameters(format, GraphicsContext3D::UNSIGNED_BYTE, &componentsPerPixel, &bytesPerComponent); + return size.width() * size.height() * componentsPerPixel * bytesPerComponent; + } + +protected: + explicit ResourceProviderContext(const Attributes& attrs) + : CompositorFakeWebGraphicsContext3D(attrs) + , m_currentTexture(0) + { } + +private: + struct Texture { + Texture(const IntSize& size_, WGC3Denum format_) + : size(size_) + , format(format_) + , data(adoptArrayPtr(new uint8_t[textureSize(size, format)])) + { + } + + IntSize size; + WGC3Denum format; + OwnArrayPtr<uint8_t> data; + }; + + void allocateTexture(const IntSize& size, WGC3Denum format) + { + ASSERT(m_currentTexture); + m_textures.set(m_currentTexture, adoptPtr(new Texture(size, format))); + } + + void setPixels(int xoffset, int yoffset, int width, int height, const void* pixels) + { + ASSERT(m_currentTexture); + Texture* texture = m_textures.get(m_currentTexture); + ASSERT(texture); + ASSERT(xoffset >= 0 && xoffset+width <= texture->size.width()); + ASSERT(yoffset >= 0 && yoffset+height <= texture->size.height()); + ASSERT(pixels); + size_t inPitch = textureSize(IntSize(width, 1), texture->format); + size_t outPitch = textureSize(IntSize(texture->size.width(), 1), texture->format); + uint8_t* dest = texture->data.get() + yoffset * outPitch + textureSize(IntSize(xoffset, 1), texture->format); + const uint8_t* src = static_cast<const uint8_t*>(pixels); + for (int i = 0; i < height; ++i) { + memcpy(dest, src, inPitch); + dest += outPitch; + src += inPitch; + } + } + + typedef HashMap<WebGLId, OwnPtr<Texture> > TextureMap; + WebGLId m_currentTexture; + TextureMap m_textures; +}; + +class CCResourceProviderTest : public testing::Test { +public: + CCResourceProviderTest() + : m_context(CCGraphicsContext::create3D(ResourceProviderContext::create())) + , m_resourceProvider(CCResourceProvider::create(m_context.get())) + { + } + + ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_context->context3D()); } + + void getResourcePixels(CCResourceProvider::ResourceId id, const IntSize& size, WGC3Denum format, uint8_t* pixels) + { + CCScopedLockResourceForRead lock(m_resourceProvider.get(), id); + ASSERT_NE(0U, lock.textureId()); + context()->bindTexture(GraphicsContext3D::TEXTURE_2D, lock.textureId()); + context()->getPixels(size, format, pixels); + } + +protected: + DebugScopedSetImplThread implThread; + OwnPtr<CCGraphicsContext> m_context; + OwnPtr<CCResourceProvider> m_resourceProvider; +}; + +TEST_F(CCResourceProviderTest, Basic) +{ + IntSize size(1, 1); + WGC3Denum format = GraphicsContext3D::RGBA; + int pool = 1; + size_t pixelSize = ResourceProviderContext::textureSize(size, format); + ASSERT_EQ(4U, pixelSize); + + CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny); + EXPECT_EQ(1, context()->textureCount()); + + uint8_t data[4] = {1, 2, 3, 4}; + IntRect rect(IntPoint(), size); + m_resourceProvider->upload(id, data, rect, rect, rect); + + uint8_t result[4] = {0}; + getResourcePixels(id, size, format, result); + EXPECT_EQ(0, memcmp(data, result, pixelSize)); + + m_resourceProvider->deleteResource(id); + EXPECT_EQ(0, context()->textureCount()); +} + +TEST_F(CCResourceProviderTest, DeleteOwnedResources) +{ + IntSize size(1, 1); + WGC3Denum format = GraphicsContext3D::RGBA; + int pool = 1; + + const int count = 3; + CCResourceProvider::ResourceId ids[count] = {0}; + for (int i = 0; i < count; ++i) + ids[i] = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny); + EXPECT_EQ(3, context()->textureCount()); + + m_resourceProvider->deleteOwnedResources(pool+1); + EXPECT_EQ(3, context()->textureCount()); + + m_resourceProvider->deleteOwnedResources(pool); + EXPECT_EQ(0, context()->textureCount()); +} + +TEST_F(CCResourceProviderTest, Upload) +{ + IntSize size(2, 2); + WGC3Denum format = GraphicsContext3D::RGBA; + int pool = 1; + size_t pixelSize = ResourceProviderContext::textureSize(size, format); + ASSERT_EQ(16U, pixelSize); + + CCResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, CCResourceProvider::TextureUsageAny); + + uint8_t image[16] = {0}; + IntRect imageRect(IntPoint(), size); + m_resourceProvider->upload(id, image, imageRect, imageRect, imageRect); + + for (uint8_t i = 0 ; i < pixelSize; ++i) + image[i] = i; + + uint8_t result[16] = {0}; + { + IntRect sourceRect(0, 0, 1, 1); + IntRect destRect(0, 0, 1, 1); + m_resourceProvider->upload(id, image, imageRect, sourceRect, destRect); + + uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}; + getResourcePixels(id, size, format, result); + EXPECT_EQ(0, memcmp(expected, result, pixelSize)); + } + { + IntRect sourceRect(0, 0, 1, 1); + IntRect destRect(1, 1, 1, 1); + m_resourceProvider->upload(id, image, imageRect, sourceRect, destRect); + + uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 3}; + getResourcePixels(id, size, format, result); + EXPECT_EQ(0, memcmp(expected, result, pixelSize)); + } + { + IntRect sourceRect(1, 0, 1, 1); + IntRect destRect(0, 1, 1, 1); + m_resourceProvider->upload(id, image, imageRect, sourceRect, destRect); + + uint8_t expected[16] = {0, 1, 2, 3, 0, 0, 0, 0, + 4, 5, 6, 7, 0, 1, 2, 3}; + getResourcePixels(id, size, format, result); + EXPECT_EQ(0, memcmp(expected, result, pixelSize)); + } + + m_resourceProvider->deleteResource(id); +} + +} // namespace diff --git a/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp b/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp index 4d464ea51..505ae9625 100644 --- a/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp +++ b/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp @@ -27,7 +27,10 @@ #include "cc/CCScopedTexture.h" #include "CCTiledLayerTestCommon.h" +#include "FakeCCGraphicsContext.h" #include "GraphicsContext3D.h" +#include "cc/CCRenderer.h" +#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread #include <gtest/gtest.h> @@ -39,8 +42,10 @@ namespace { TEST(CCScopedTextureTest, NewScopedTexture) { - FakeTextureAllocator allocator; - OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator); + OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); + DebugScopedSetImplThread implThread; + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get()); // New scoped textures do not hold a texture yet. EXPECT_EQ(0u, texture->id()); @@ -52,9 +57,11 @@ TEST(CCScopedTextureTest, NewScopedTexture) TEST(CCScopedTextureTest, CreateScopedTexture) { - FakeTextureAllocator allocator; - OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator); - texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA); + OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); + DebugScopedSetImplThread implThread; + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get()); + texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny); // The texture has an allocated byte-size now. size_t expectedBytes = 30 * 30 * 4; @@ -65,95 +72,58 @@ TEST(CCScopedTextureTest, CreateScopedTexture) EXPECT_EQ(IntSize(30, 30), texture->size()); } -// Fake TextureAllocator that tracks the number of textures in use. -class TrackingTextureAllocator : public TextureAllocator { -public: - TrackingTextureAllocator() - : m_nextTextureId(1) - , m_numTextures(0) - { } - - virtual unsigned createTexture(const WebCore::IntSize&, GC3Denum) OVERRIDE - { - unsigned id = m_nextTextureId; - ++m_nextTextureId; - - m_textures.set(id, true); - ++m_numTextures; - return id; - } - - virtual void deleteTexture(unsigned id, const WebCore::IntSize&, GC3Denum) OVERRIDE - { - if (!m_textures.get(id)) - return; - - m_textures.set(id, false); - --m_numTextures; - } - - virtual void deleteAllTextures() OVERRIDE - { - m_textures.clear(); - m_numTextures = 0; - } - - unsigned numTextures() const { return m_numTextures; } - -private: - unsigned m_nextTextureId; - HashMap<unsigned, bool> m_textures; - unsigned m_numTextures; -}; - TEST(CCScopedTextureTest, ScopedTextureIsDeleted) { - TrackingTextureAllocator allocator; + OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); + DebugScopedSetImplThread implThread; + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); { - OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator); + OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get()); - EXPECT_EQ(0u, allocator.numTextures()); - texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA); + EXPECT_EQ(0u, resourceProvider->numResources()); + texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny); EXPECT_LT(0u, texture->id()); - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); } - EXPECT_EQ(0u, allocator.numTextures()); + EXPECT_EQ(0u, resourceProvider->numResources()); { - OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator); - EXPECT_EQ(0u, allocator.numTextures()); - texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA); + OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get()); + EXPECT_EQ(0u, resourceProvider->numResources()); + texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny); EXPECT_LT(0u, texture->id()); - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); texture->free(); - EXPECT_EQ(0u, allocator.numTextures()); + EXPECT_EQ(0u, resourceProvider->numResources()); } } TEST(CCScopedTextureTest, LeakScopedTexture) { - TrackingTextureAllocator allocator; + OwnPtr<CCGraphicsContext> context(createFakeCCGraphicsContext()); + DebugScopedSetImplThread implThread; + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); { - OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator); + OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get()); - EXPECT_EQ(0u, allocator.numTextures()); - texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA); + EXPECT_EQ(0u, resourceProvider->numResources()); + texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny); EXPECT_LT(0u, texture->id()); - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); texture->leak(); EXPECT_EQ(0u, texture->id()); - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); texture->free(); EXPECT_EQ(0u, texture->id()); - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); } - EXPECT_EQ(1u, allocator.numTextures()); + EXPECT_EQ(1u, resourceProvider->numResources()); } } diff --git a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp index f9a9292b7..1754a5b12 100644 --- a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp @@ -52,7 +52,7 @@ TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) layer->setBounds(layerSize); layer->setContentBounds(layerSize); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); @@ -75,7 +75,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) layer->setContentBounds(layerSize); layer->setBackgroundColor(testColor); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); @@ -99,7 +99,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectOpacityInQuad) layer->setContentBounds(layerSize); layer->setDrawOpacity(opacity); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); diff --git a/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp b/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp index d0bbd36f4..b7a26df2f 100644 --- a/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp +++ b/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp @@ -30,6 +30,7 @@ #include "FakeWebGraphicsContext3D.h" #include "GraphicsContext3DPrivate.h" #include "WebCompositor.h" +#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread #include "platform/WebThread.h" #include <gtest/gtest.h> @@ -63,13 +64,12 @@ class TextureUploaderForUploadTest : public FakeTextureUploader { public: TextureUploaderForUploadTest(CCTextureUpdaterTest *test) : m_test(test) { } - virtual void beginUploads(); - virtual void endUploads(); - virtual void uploadTexture(WebCore::CCGraphicsContext*, - WebCore::LayerTextureUpdater::Texture*, - WebCore::TextureAllocator*, + virtual void beginUploads() OVERRIDE; + virtual void endUploads() OVERRIDE; + virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture*, + WebCore::CCResourceProvider*, const WebCore::IntRect sourceRect, - const WebCore::IntRect destRect); + const WebCore::IntRect destRect) OVERRIDE; private: CCTextureUpdaterTest* m_test; @@ -79,7 +79,7 @@ private: class TextureForUploadTest : public LayerTextureUpdater::Texture { public: TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { } - virtual void updateRect(CCGraphicsContext*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect) { } + virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, const IntRect& destRect) { } }; @@ -165,6 +165,8 @@ protected: m_context = CCGraphicsContext::create3D( adoptPtr(new WebGraphicsContext3DForUploadTest(this))); + DebugScopedSetImplThread implThread; + m_resourceProvider = CCResourceProvider::create(m_context.get()); } virtual void TearDown() @@ -200,9 +202,9 @@ protected: protected: // Classes required to interact and test the CCTextureUpdater OwnPtr<CCGraphicsContext> m_context; + OwnPtr<CCResourceProvider> m_resourceProvider; CCTextureUpdater m_updater; TextureForUploadTest m_texture; - FakeTextureAllocator m_allocator; FakeTextureCopier m_copier; TextureUploaderForUploadTest m_uploader; @@ -239,11 +241,10 @@ void TextureUploaderForUploadTest::endUploads() m_test->onEndUploads(); } -void TextureUploaderForUploadTest::uploadTexture(WebCore::CCGraphicsContext* context, - WebCore::LayerTextureUpdater::Texture* texture, - WebCore::TextureAllocator* allocator, - const WebCore::IntRect sourceRect, - const WebCore::IntRect destRect) +void TextureUploaderForUploadTest::uploadTexture(WebCore::LayerTextureUpdater::Texture* texture, + WebCore::CCResourceProvider*, + const WebCore::IntRect sourceRect, + const WebCore::IntRect destRect) { m_test->onUpload(); } @@ -254,7 +255,7 @@ TEST_F(CCTextureUpdaterTest, ZeroUploads) { appendFullUploadsToUpdater(0); appendPartialUploadsToUpdater(0); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(0, m_numBeginUploads); EXPECT_EQ(0, m_numEndUploads); @@ -268,7 +269,8 @@ TEST_F(CCTextureUpdaterTest, OneFullUpload) { appendFullUploadsToUpdater(1); appendPartialUploadsToUpdater(0); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -280,7 +282,8 @@ TEST_F(CCTextureUpdaterTest, OnePartialUpload) { appendFullUploadsToUpdater(0); appendPartialUploadsToUpdater(1); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -292,7 +295,8 @@ TEST_F(CCTextureUpdaterTest, OneFullOnePartialUpload) { appendFullUploadsToUpdater(1); appendPartialUploadsToUpdater(1); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); // We expect the full uploads to be followed by a flush // before the partial uploads begin. @@ -315,7 +319,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullUploadsNoRemainder) { appendFullUploadsToUpdater(fullNoRemainderCount); appendPartialUploadsToUpdater(0); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -327,7 +332,8 @@ TEST_F(CCTextureUpdaterTest, ManyPartialUploadsNoRemainder) { appendFullUploadsToUpdater(0); appendPartialUploadsToUpdater(partialNoRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -339,7 +345,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullManyPartialUploadsNoRemainder) { appendFullUploadsToUpdater(fullNoRemainderCount); appendPartialUploadsToUpdater(partialNoRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -361,7 +368,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialMinRemainder) { appendFullUploadsToUpdater(fullMinRemainderCount); appendPartialUploadsToUpdater(partialMinRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -373,7 +381,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialUploadsMaxRemainder) { appendFullUploadsToUpdater(fullMaxRemainderCount); appendPartialUploadsToUpdater(partialMaxRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -385,7 +394,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullMinRemainderManyPartialMaxRemainder) { appendFullUploadsToUpdater(fullMinRemainderCount); appendPartialUploadsToUpdater(partialMaxRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -397,7 +407,8 @@ TEST_F(CCTextureUpdaterTest, ManyFullMaxRemainderManyPartialMinRemainder) { appendFullUploadsToUpdater(fullMaxRemainderCount); appendPartialUploadsToUpdater(partialMinRemainderCount); - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, m_totalUploadCountExpected); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -429,7 +440,8 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial) appendPartialUploadsToUpdater(kPartialUploads); // First update (40 full) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -441,7 +453,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial) EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads); // Second update (40 full) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(2, m_numBeginUploads); EXPECT_EQ(2, m_numEndUploads); @@ -453,7 +465,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial) EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads); // Third update (20 full, 20 partial) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(3, m_numBeginUploads); EXPECT_EQ(3, m_numEndUploads); @@ -483,7 +495,8 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial) appendPartialUploadsToUpdater(kPartialUploads); // First update (40 full) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + DebugScopedSetImplThread implThread; + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); @@ -495,7 +508,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial) EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads); // Second update (30 full, optionally 10 partial) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(2, m_numBeginUploads); EXPECT_EQ(2, m_numEndUploads); @@ -505,7 +518,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial) // onFlush(), onUpload(), and onEndUpload() will do basic flush checks for us anyway. // Third update (30 partial OR 20 partial if 10 partial uploaded in second update) - m_updater.update(m_context.get(), &m_allocator, &m_copier, &m_uploader, kMaxUploadsPerUpdate); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate); EXPECT_EQ(3, m_numBeginUploads); EXPECT_EQ(3, m_numEndUploads); diff --git a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp index 00d38a7ec..a0850b251 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp @@ -53,10 +53,10 @@ static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const I layer->setBounds(layerSize); layer->setContentBounds(layerSize); - int textureId = 1; + CCResourceProvider::ResourceId resourceId = 1; for (int i = 0; i < tiler->numTilesX(); ++i) for (int j = 0; j < tiler->numTilesY(); ++j) - layer->pushTileProperties(i, j, static_cast<Platform3DObject>(textureId++), IntRect(0, 0, 1, 1)); + layer->pushTileProperties(i, j, resourceId++, IntRect(0, 0, 1, 1)); return layer.release(); } @@ -74,7 +74,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) { OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); MockCCQuadCuller quadCuller; - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); const unsigned numTiles = numTilesX * numTilesY; @@ -87,7 +87,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) layer->setVisibleContentRect(IntRect()); MockCCQuadCuller quadCuller; - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); EXPECT_EQ(quadCuller.quadList().size(), 0u); @@ -101,7 +101,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) layer->setVisibleContentRect(outsideBounds); MockCCQuadCuller quadCuller; - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); EXPECT_EQ(quadCuller.quadList().size(), 0u); @@ -113,7 +113,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) layer->setSkipsDraw(true); MockCCQuadCuller quadCuller; - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); EXPECT_EQ(quadCuller.quadList().size(), 0u); @@ -130,7 +130,7 @@ TEST(CCTiledLayerImplTest, checkerboarding) const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY); OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); // No checkerboarding { @@ -146,7 +146,7 @@ TEST(CCTiledLayerImplTest, checkerboarding) for (int i = 0; i < numTilesX; ++i) for (int j = 0; j < numTilesY; ++j) - layer->pushTileProperties(i, j, static_cast<Platform3DObject>(0), IntRect()); + layer->pushTileProperties(i, j, 0, IntRect()); // All checkerboarding { @@ -167,7 +167,7 @@ static PassOwnPtr<CCSharedQuadState> getQuads(CCQuadList& quads, IntSize tileSiz layer->setBounds(layerSize); MockCCQuadCuller quadCuller(quads); - OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); + OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0); bool hadMissingTiles = false; layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles); return sharedQuadState.release(); // The shared data must be owned as long as the quad list exists. @@ -240,7 +240,7 @@ TEST(CCTiledLayerImplTest, textureInfoForLayerNoBorders) ASSERT_EQ(quads[i]->material(), CCDrawQuad::TiledContent) << quadString << i; CCTileDrawQuad* quad = static_cast<CCTileDrawQuad*>(quads[i].get()); - EXPECT_NE(quad->textureId(), 0u) << quadString << i; + EXPECT_NE(quad->resourceId(), 0u) << quadString << i; EXPECT_EQ(quad->textureOffset(), IntPoint()) << quadString << i; EXPECT_EQ(quad->textureSize(), tileSize) << quadString << i; EXPECT_EQ(IntRect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; diff --git a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp index 26ffd9079..7778549b6 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp +++ b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp @@ -40,10 +40,9 @@ FakeLayerTextureUpdater::Texture::~Texture() { } -void FakeLayerTextureUpdater::Texture::updateRect(CCGraphicsContext*, TextureAllocator* allocator, const IntRect&, const IntRect&) +void FakeLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect&, const IntRect&) { - if (allocator) - texture()->acquireBackingTexture(allocator); + texture()->acquireBackingTexture(resourceProvider); m_layer->updateRect(); } diff --git a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h index 9501caba9..be681d71c 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h +++ b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h @@ -29,12 +29,12 @@ #include "IntSize.h" #include "LayerTextureUpdater.h" #include "Region.h" -#include "TextureAllocator.h" #include "TextureCopier.h" #include "TextureUploader.h" #include "TiledLayerChromium.h" #include "cc/CCGraphicsContext.h" #include "cc/CCPrioritizedTexture.h" +#include "cc/CCResourceProvider.h" #include "cc/CCTextureUpdater.h" #include "cc/CCTiledLayerImpl.h" @@ -49,7 +49,7 @@ public: Texture(FakeLayerTextureUpdater*, PassOwnPtr<WebCore::CCPrioritizedTexture>); virtual ~Texture(); - virtual void updateRect(WebCore::CCGraphicsContext*, WebCore::TextureAllocator* , const WebCore::IntRect&, const WebCore::IntRect&) OVERRIDE; + virtual void updateRect(WebCore::CCResourceProvider* , const WebCore::IntRect&, const WebCore::IntRect&) OVERRIDE; virtual void prepareRect(const WebCore::IntRect&) OVERRIDE; private: @@ -151,17 +151,10 @@ protected: WebCore::IntSize m_forcedContentBounds; }; -class FakeTextureAllocator : public WebCore::TextureAllocator { -public: - virtual unsigned createTexture(const WebCore::IntSize&, GC3Denum) OVERRIDE { return 1; } - virtual void deleteTexture(unsigned, const WebCore::IntSize&, GC3Denum) OVERRIDE { } - virtual void deleteAllTextures() OVERRIDE { } -}; - class FakeTextureCopier : public WebCore::TextureCopier { public: - virtual void copyTexture(WebCore::CCGraphicsContext*, unsigned, unsigned, const WebCore::IntSize&) { } - virtual void copyToTexture(WebCore::CCGraphicsContext*, const void*, unsigned, const WebCore::IntSize&, GC3Denum) { } + virtual void copyTexture(unsigned, unsigned, const WebCore::IntSize&) { } + virtual void flush() { } }; class FakeTextureUploader : public WebCore::TextureUploader { @@ -169,7 +162,7 @@ public: virtual bool isBusy() { return false; } virtual void beginUploads() { } virtual void endUploads() { } - virtual void uploadTexture(WebCore::CCGraphicsContext* context, WebCore::LayerTextureUpdater::Texture* texture, WebCore::TextureAllocator* allocator, const WebCore::IntRect sourceRect, const WebCore::IntRect destRect) { texture->updateRect(context, allocator, sourceRect, destRect); } + virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture* texture, WebCore::CCResourceProvider* resourceProvider, const WebCore::IntRect sourceRect, const WebCore::IntRect destRect) { texture->updateRect(resourceProvider, sourceRect, destRect); } }; } diff --git a/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp index 750418535..fcfcce114 100644 --- a/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp @@ -99,7 +99,7 @@ TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale) OpaqueRectDrawingGraphicsContextPainter painter(opaqueRectInLayerSpace, contentRect); OpaqueRectTrackingContentLayerDelegate opaqueRectTrackingContentLayerDelegate(&painter); MockContentLayerDelegate delegate(&opaqueRectTrackingContentLayerDelegate); - RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&delegate), false); + RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&delegate)); IntRect resultingOpaqueRect; updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, contentsScale, resultingOpaqueRect); diff --git a/Source/WebKit/chromium/tests/DragImageTest.cpp b/Source/WebKit/chromium/tests/DragImageTest.cpp index 080607cd7..f75e85c6f 100644 --- a/Source/WebKit/chromium/tests/DragImageTest.cpp +++ b/Source/WebKit/chromium/tests/DragImageTest.cpp @@ -139,8 +139,8 @@ TEST(DragImageTest, CreateDragImage) RefPtr<TestImage> testImage(TestImage::create(IntSize(1, 1))); DragImageRef dragImage = createDragImageFromImage(testImage.get()); ASSERT_TRUE(dragImage); - SkAutoLockPixels lock1(*dragImage), lock2(testImage->nativeImageForCurrentFrame()->bitmap()); - EXPECT_NE(dragImage->getPixels(), testImage->nativeImageForCurrentFrame()->bitmap().getPixels()); + SkAutoLockPixels lock1(*dragImage->bitmap), lock2(testImage->nativeImageForCurrentFrame()->bitmap()); + EXPECT_NE(dragImage->bitmap->getPixels(), testImage->nativeImageForCurrentFrame()->bitmap().getPixels()); } } diff --git a/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h b/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h new file mode 100644 index 000000000..beb4ef366 --- /dev/null +++ b/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FakeCCGraphicsContext_h +#define FakeCCGraphicsContext_h + +#include "CompositorFakeWebGraphicsContext3D.h" +#include "cc/CCGraphicsContext.h" + +namespace WebKit { + +static inline PassOwnPtr<WebCore::CCGraphicsContext> createFakeCCGraphicsContext() +{ + return WebCore::CCGraphicsContext::create3D(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes())); +} + +} // namespace WebKit + +#endif // FakeCCGraphicsContext_h diff --git a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp index 4fb15d1eb..91aeb7ca5 100644 --- a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp @@ -28,6 +28,7 @@ #include "CCAnimationTestCommon.h" #include "CompositorFakeWebGraphicsContext3D.h" +#include "FakeCCLayerTreeHostClient.h" #include "GraphicsContext3D.h" #include "GraphicsContext3DPrivate.h" #include "GraphicsLayer.h" @@ -61,31 +62,12 @@ class MockGraphicsLayerClient : public GraphicsLayerClient { virtual float deviceScaleFactor() const OVERRIDE { return 2; } }; -class MockLayerTreeHostClient : public CCLayerTreeHostClient { -public: - virtual void willBeginFrame() OVERRIDE { } - virtual void didBeginFrame() OVERRIDE { } - virtual void updateAnimations(double frameBeginTime) OVERRIDE { } - virtual void layout() OVERRIDE { } - virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { } - virtual PassOwnPtr<WebGraphicsContext3D> createContext3D() OVERRIDE - { - return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()); - } - virtual void didRecreateContext(bool success) OVERRIDE { } - virtual void willCommit() OVERRIDE { } - virtual void didCommit() OVERRIDE { } - virtual void didCommitAndDrawFrame() OVERRIDE { } - virtual void didCompleteSwapBuffers() OVERRIDE { } - virtual void scheduleComposite() OVERRIDE { } -}; - class MockLayerTreeHost : public CCLayerTreeHost { public: static PassOwnPtr<MockLayerTreeHost> create() { CCLayerTreeSettings settings; - OwnPtr<MockLayerTreeHost> layerTreeHost(adoptPtr(new MockLayerTreeHost(new MockLayerTreeHostClient(), settings))); + OwnPtr<MockLayerTreeHost> layerTreeHost(adoptPtr(new MockLayerTreeHost(new FakeCCLayerTreeHostClient(), settings))); bool success = layerTreeHost->initialize(); EXPECT_TRUE(success); layerTreeHost->setRootLayer(LayerChromium::create()); diff --git a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp index a34b436bd..137699c30 100644 --- a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp +++ b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp @@ -630,7 +630,7 @@ TEST(IDBLevelDBCodingTest, ComparisonTest) keys.append(DatabaseNameKey::encode("", "")); keys.append(DatabaseNameKey::encode("", "a")); keys.append(DatabaseNameKey::encode("a", "a")); - keys.append(DatabaseMetaDataKey::encode(1, DatabaseMetaDataKey::kOriginName)); + keys.append(DatabaseMetaDataKey::encode(1, DatabaseMetaDataKey::OriginName)); keys.append(ObjectStoreMetaDataKey::encode(1, 1, 0)); keys.append(ObjectStoreMetaDataKey::encode(1, 1, 1)); keys.append(ObjectStoreMetaDataKey::encodeMaxKey(1, 1)); @@ -645,9 +645,9 @@ TEST(IDBLevelDBCodingTest, ComparisonTest) keys.append(IndexMetaDataKey::encodeMaxKey(1, 2)); keys.append(ObjectStoreFreeListKey::encode(1, 1)); keys.append(ObjectStoreFreeListKey::encodeMaxKey(1)); - keys.append(IndexFreeListKey::encode(1, 1, kMinimumIndexId)); + keys.append(IndexFreeListKey::encode(1, 1, MinimumIndexId)); keys.append(IndexFreeListKey::encodeMaxKey(1, 1)); - keys.append(IndexFreeListKey::encode(1, 2, kMinimumIndexId)); + keys.append(IndexFreeListKey::encode(1, 2, MinimumIndexId)); keys.append(IndexFreeListKey::encodeMaxKey(1, 2)); keys.append(ObjectStoreNamesKey::encode(1, "")); keys.append(ObjectStoreNamesKey::encode(1, "a")); diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index a794a2846..004022b66 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -440,10 +440,10 @@ TEST_F(LayerChromiumTest, checkSetNeedsDisplayCausesCorrectBehavior) IntSize testBounds = IntSize(501, 508); - FloatRect dirty1 = FloatRect(10.0f, 15.0f, 1.0f, 2.0f); - FloatRect dirty2 = FloatRect(20.0f, 25.0f, 3.0f, 4.0f); - FloatRect emptyDirtyRect = FloatRect(40.0f, 45.0f, 0, 0); - FloatRect outOfBoundsDirtyRect = FloatRect(400.0f, 405.0f, 500.0f, 502.0f); + FloatRect dirty1 = FloatRect(10, 15, 1, 2); + FloatRect dirty2 = FloatRect(20, 25, 3, 4); + FloatRect emptyDirtyRect = FloatRect(40, 45, 0, 0); + FloatRect outOfBoundsDirtyRect = FloatRect(400, 405, 500, 502); // Before anything, testLayer should not be dirty. EXPECT_FALSE(testLayer->needsDisplay()); @@ -497,7 +497,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContentRect(IntRect(0, 0, 40, 50))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUsesLayerClipping(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true)); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix())); @@ -512,9 +512,9 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(SK_ColorLTGRAY)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dummyLayer.get())); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5f)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpaque(true)); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4.0f, 9.0f))); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4, 9))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true)); diff --git a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp index 7cdba809c..1b6b8028b 100644 --- a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp @@ -81,6 +81,7 @@ public: { m_rootLayer->createRenderSurface(); m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id()); + m_renderPasses.append(m_rootRenderPass.get()); } // CCRendererClient methods. @@ -96,6 +97,7 @@ public: int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCount; } CCRenderPass* rootRenderPass() { return m_rootRenderPass.get(); } + const CCRenderPassList& renderPasses() { return m_renderPasses; } size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; } @@ -104,12 +106,13 @@ private: DebugScopedSetImplThread m_implThread; OwnPtr<CCLayerImpl> m_rootLayer; OwnPtr<CCRenderPass> m_rootRenderPass; + CCRenderPassList m_renderPasses; size_t m_memoryAllocationLimitBytes; }; class FakeLayerRendererChromium : public LayerRendererChromium { public: - FakeLayerRendererChromium(CCRendererClient* client, WebGraphicsContext3D* context) : LayerRendererChromium(client, context, UnthrottledUploader) { } + FakeLayerRendererChromium(CCRendererClient* client, CCResourceProvider* resourceProvider) : LayerRendererChromium(client, resourceProvider, UnthrottledUploader) { } // LayerRendererChromium methods. @@ -123,8 +126,9 @@ protected: LayerRendererChromiumTest() : m_suggestHaveBackbufferYes(1, true) , m_suggestHaveBackbufferNo(1, false) - , m_context(adoptPtr(new FrameCountingMemoryAllocationSettingContext)) - , m_layerRendererChromium(&m_mockClient, m_context.get()) + , m_context(CCGraphicsContext::create3D(adoptPtr(new FrameCountingMemoryAllocationSettingContext()))) + , m_resourceProvider(CCResourceProvider::create(m_context.get())) + , m_layerRendererChromium(&m_mockClient, m_resourceProvider.get()) { } @@ -144,11 +148,14 @@ protected: m_layerRendererChromium.swapBuffers(IntRect()); } + FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } + WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; - OwnPtr<FrameCountingMemoryAllocationSettingContext> m_context; + OwnPtr<CCGraphicsContext> m_context; FakeCCRendererClient m_mockClient; + OwnPtr<CCResourceProvider> m_resourceProvider; FakeLayerRendererChromium m_layerRendererChromium; CCScopedSettings m_scopedSettings; }; @@ -158,12 +165,12 @@ protected: // Expected: it does nothing. TEST_F(LayerRendererChromiumTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) { - m_context->setMemoryAllocation(m_suggestHaveBackbufferYes); + context()->setMemoryAllocation(m_suggestHaveBackbufferYes); EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount()); EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); swapBuffers(); - EXPECT_EQ(1, m_context->frameCount()); + EXPECT_EQ(1, context()->frameCount()); } // Test LayerRendererChromium discardFramebuffer functionality: @@ -172,7 +179,7 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferYesWhenItAlreadyExistsShouldD TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerWhileNotVisible) { m_layerRendererChromium.setVisible(false); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); } @@ -183,7 +190,7 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndD TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible) { m_layerRendererChromium.setVisible(true); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount()); EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); } @@ -195,11 +202,11 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible) TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) { m_layerRendererChromium.setVisible(false); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); } @@ -210,27 +217,27 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNo TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration) { m_layerRendererChromium.setVisible(false); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); m_layerRendererChromium.setVisible(true); - m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass()); + m_layerRendererChromium.drawFrame(m_mockClient.renderPasses(), FloatRect()); EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); swapBuffers(); - EXPECT_EQ(1, m_context->frameCount()); + EXPECT_EQ(1, context()->frameCount()); } TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { m_layerRendererChromium.setVisible(false); - m_context->setMemoryAllocation(m_suggestHaveBackbufferNo); + context()->setMemoryAllocation(m_suggestHaveBackbufferNo); EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); char pixels[4]; - m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass()); + m_layerRendererChromium.drawFrame(m_mockClient.renderPasses(), FloatRect()); EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1)); @@ -309,8 +316,9 @@ TEST(LayerRendererChromiumTest2, initializationDoesNotMakeSynchronousCalls) { CCScopedSettings scopedSettings; FakeCCRendererClient mockClient; - OwnPtr<WebGraphicsContext3D> context(adoptPtr(new ForbidSynchronousCallContext)); - FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get()); + OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new ForbidSynchronousCallContext))); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get()); EXPECT_TRUE(layerRendererChromium.initialize()); } @@ -352,8 +360,9 @@ TEST(LayerRendererChromiumTest2, initializationWithQuicklyLostContextDoesNotAsse { CCScopedSettings scopedSettings; FakeCCRendererClient mockClient; - OwnPtr<WebGraphicsContext3D> context(adoptPtr(new LoseContextOnFirstGetContext)); - FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get()); + OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new LoseContextOnFirstGetContext))); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get()); layerRendererChromium.initialize(); } @@ -373,8 +382,9 @@ public: TEST(LayerRendererChromiumTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation) { FakeCCRendererClient mockClient; - OwnPtr<WebGraphicsContext3D> context(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions)); - FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get()); + OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions))); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get())); + FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get()); layerRendererChromium.initialize(); @@ -399,15 +409,16 @@ private: TEST(LayerRendererChromiumTest2, opaqueBackground) { FakeCCRendererClient mockClient; - OwnPtr<ClearCountingContext> context(adoptPtr(new ClearCountingContext)); - FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get()); + OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new ClearCountingContext))); + ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext->context3D()); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccContext.get())); + FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get()); mockClient.rootRenderPass()->setHasTransparentBackground(false); EXPECT_TRUE(layerRendererChromium.initialize()); - layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass()); - layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect()); + layerRendererChromium.drawFrame(mockClient.renderPasses(), FloatRect()); layerRendererChromium.finishDrawingFrame(); // On DEBUG builds, render passes with opaque background clear to blue to @@ -422,15 +433,16 @@ TEST(LayerRendererChromiumTest2, opaqueBackground) TEST(LayerRendererChromiumTest2, transparentBackground) { FakeCCRendererClient mockClient; - OwnPtr<ClearCountingContext> context(adoptPtr(new ClearCountingContext)); - FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get()); + OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new ClearCountingContext))); + ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext->context3D()); + OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccContext.get())); + FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get()); mockClient.rootRenderPass()->setHasTransparentBackground(true); EXPECT_TRUE(layerRendererChromium.initialize()); - layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass()); - layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect()); + layerRendererChromium.drawFrame(mockClient.renderPasses(), FloatRect()); layerRendererChromium.finishDrawingFrame(); EXPECT_EQ(1, context->clearCount()); diff --git a/Source/WebKit/chromium/tests/MockCCQuadCuller.h b/Source/WebKit/chromium/tests/MockCCQuadCuller.h index 385507e2c..15cb19d6c 100644 --- a/Source/WebKit/chromium/tests/MockCCQuadCuller.h +++ b/Source/WebKit/chromium/tests/MockCCQuadCuller.h @@ -27,21 +27,19 @@ #include "IntRect.h" #include "cc/CCDrawQuad.h" -#include "cc/CCQuadCuller.h" +#include "cc/CCQuadSink.h" #include <wtf/PassOwnPtr.h> namespace WebCore { -class MockCCQuadCuller : public WebCore::CCQuadCuller { +class MockCCQuadCuller : public WebCore::CCQuadSink { public: MockCCQuadCuller() - : CCQuadCuller(m_quadListStorage, 0, 0, false) - , m_activeQuadList(m_quadListStorage) + : m_activeQuadList(m_quadListStorage) { } explicit MockCCQuadCuller(CCQuadList& externalQuadList) - : CCQuadCuller(externalQuadList, 0, 0, false) - , m_activeQuadList(externalQuadList) + : m_activeQuadList(externalQuadList) { } virtual bool append(WTF::PassOwnPtr<WebCore::CCDrawQuad> newQuad) diff --git a/Source/WebKit/chromium/tests/TextureCopierTest.cpp b/Source/WebKit/chromium/tests/TextureCopierTest.cpp index b3ef4c2eb..776e23bfd 100644 --- a/Source/WebKit/chromium/tests/TextureCopierTest.cpp +++ b/Source/WebKit/chromium/tests/TextureCopierTest.cpp @@ -39,8 +39,6 @@ using testing::InSequence; using testing::Test; using testing::_; -namespace { - class MockContext : public FakeWebGraphicsContext3D { public: MOCK_METHOD2(bindFramebuffer, void(WGC3Denum, WebGLId)); @@ -52,34 +50,31 @@ public: TEST(TextureCopierTest, testDrawArraysCopy) { GraphicsContext3D::Attributes attrs; - OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new MockContext)); - MockContext& mockContext = *static_cast<MockContext*>(ccContext->context3D()); + OwnPtr<MockContext> mockContext = adoptPtr(new MockContext); { InSequence sequence; // Here we check just some essential properties of copyTexture() to avoid mirroring the full implementation. - EXPECT_CALL(mockContext, bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, _)); + EXPECT_CALL(*mockContext, bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, _)); // Make sure linear filtering is disabled during the copy. - EXPECT_CALL(mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST)); - EXPECT_CALL(mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST)); + EXPECT_CALL(*mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST)); + EXPECT_CALL(*mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST)); - EXPECT_CALL(mockContext, drawArrays(_, _, _)); + EXPECT_CALL(*mockContext, drawArrays(_, _, _)); // Linear filtering should be restored. - EXPECT_CALL(mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); - EXPECT_CALL(mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); + EXPECT_CALL(*mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); + EXPECT_CALL(*mockContext, texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); // Default framebuffer should be restored - EXPECT_CALL(mockContext, bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); + EXPECT_CALL(*mockContext, bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); } int sourceTextureId = 1; int destTextureId = 2; IntSize size(256, 128); - OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(ccContext->context3D(), false)); - copier->copyTexture(ccContext.get(), sourceTextureId, destTextureId, size); + OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(mockContext.get(), false)); + copier->copyTexture(sourceTextureId, destTextureId, size); } - -} // namespace diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index f152ab4fb..11bf115b5 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -30,6 +30,7 @@ #include "CCAnimationTestCommon.h" #include "CCLayerTreeTestCommon.h" #include "CCTiledLayerTestCommon.h" +#include "FakeCCGraphicsContext.h" #include "FakeCCLayerTreeHostClient.h" #include "LayerPainterChromium.h" #include "WebCompositor.h" @@ -72,29 +73,37 @@ private: class TiledLayerChromiumTest : public testing::Test { public: - TiledLayerChromiumTest() : ccContext(CCGraphicsContext::create3D(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes()))) { } - virtual ~TiledLayerChromiumTest() { } + TiledLayerChromiumTest() + : m_context(WebKit::createFakeCCGraphicsContext()) + { + DebugScopedSetImplThread implThread; + m_resourceProvider = CCResourceProvider::create(m_context.get()); + } + + virtual ~TiledLayerChromiumTest() + { + DebugScopedSetImplThread implThread; + m_resourceProvider.clear(); + } void updateTextures(int count = 500) { - updater.update(ccContext.get(), &allocator, &copier, &uploader, count); + m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, count); } public: - // FIXME: Rename these to add "m_". - OwnPtr<CCGraphicsContext> ccContext; - CCTextureUpdater updater; - FakeTextureAllocator allocator; - FakeTextureCopier copier; - FakeTextureUploader uploader; - CCPriorityCalculator priorityCalculator; + OwnPtr<CCGraphicsContext> m_context; + OwnPtr<CCResourceProvider> m_resourceProvider; + CCTextureUpdater m_updater; + FakeTextureCopier m_copier; + FakeTextureUploader m_uploader; + CCPriorityCalculator m_priorityCalculator; }; TEST_F(TiledLayerChromiumTest, pushDirtyTiles) { - CCPriorityCalculator priorityCalculator; - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -104,10 +113,10 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles) layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -118,9 +127,9 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles) // Invalidates both tiles... layer->invalidateContentRect(IntRect(0, 0, 100, 200)); // ....but then only update one of them. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 100), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0); layer->pushPropertiesTo(layerImpl.get()); // We should only have the first tile since the other tile was invalidated but not painted. @@ -130,8 +139,7 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles) TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) { - CCPriorityCalculator priorityCalculator; - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -143,10 +151,10 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), &occluded); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -162,7 +170,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) layer->invalidateContentRect(IntRect(0, 0, 50, 50)); // ....but the area is occluded. occluded.setOcclusion(IntRect(0, 0, 50, 50)); - layer->updateContentRect(updater, IntRect(0, 0, 100, 100), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), &occluded); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -177,7 +185,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) TEST_F(TiledLayerChromiumTest, pushDeletedTiles) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -187,10 +195,10 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -199,7 +207,7 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); textureManager->clearPriorities(); - textureManager->clearAllMemory(&allocator); + textureManager->clearAllMemory(m_resourceProvider.get()); textureManager->setMaxMemoryLimitBytes(4*1024*1024); // This should drop the tiles on the impl thread. @@ -210,9 +218,9 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); // This should recreate and update the deleted textures. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 100), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -223,7 +231,7 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -238,10 +246,10 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) layer->setVisibleContentRect(visibleRect); layer->invalidateContentRect(contentRect); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); updateTextures(); // We should need idle-painting for 3x3 tiles in the center. @@ -254,10 +262,10 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) // For the next four updates, we should detect we still need idle painting. for (int i = 0; i < 4; i++) { - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -281,7 +289,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) { // Start with 2mb of memory, but the test is going to try to use just more than 1mb, so we reduce to 1mb later. - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(2*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(2*1024*1024, 1024, CCRenderer::ContentPool); DebugScopedSetImplThread implThread; RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -305,11 +313,11 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) layer1->invalidateContentRect(layerRect); // Paint a single tile in layer2 so that it will idle paint. - layer2->setTexturePriorities(priorityCalculator); - layer1->setTexturePriorities(priorityCalculator); + layer2->setTexturePriorities(m_priorityCalculator); + layer1->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer1->updateContentRect(updater, layerRect, 0); - layer2->updateContentRect(updater, IntRect(0, 0, 100, 100), 0); + layer1->updateContentRect(m_updater, layerRect, 0); + layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0); // We should need idle-painting for both remaining tiles in layer2. EXPECT_TRUE(layer2->needsIdlePaint(layer2Rect)); @@ -323,10 +331,10 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) textureManager->setMaxMemoryLimitBytes(1024 * 1024); // Now idle paint layer2. We are going to run out of memory though! - layer2->setTexturePriorities(priorityCalculator); - layer1->setTexturePriorities(priorityCalculator); + layer2->setTexturePriorities(m_priorityCalculator); + layer1->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer2->updateContentRect(updater, IntRect(0, 0, 100, 100), 0); + layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0); // Oh well, commit the frame and push. updateTextures(); @@ -343,11 +351,11 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) EXPECT_FALSE(layerImpl2->hasTileAt(0, 2)); // Now if layer2 becomes fully visible, we should be able to paint it and push valid textures. - layer2->setTexturePriorities(priorityCalculator); - layer1->setTexturePriorities(priorityCalculator); + layer2->setTexturePriorities(m_priorityCalculator); + layer1->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer2->updateContentRect(updater, layer2Rect, 0); - layer1->updateContentRect(updater, layerRect, 0); + layer2->updateContentRect(m_updater, layer2Rect, 0); + layer1->updateContentRect(m_updater, layerRect, 0); updateTextures(); layer1->pushPropertiesTo(layerImpl1.get()); @@ -363,7 +371,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -377,9 +385,9 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); layer->invalidateContentRect(IntRect(0, 0, 100, 100)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 100), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), &occluded); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -389,7 +397,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -402,9 +410,9 @@ TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer.get()); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -415,7 +423,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; @@ -430,15 +438,15 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer2->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer1->setTexturePriorities(priorityCalculator); - layer2->setTexturePriorities(priorityCalculator); + layer1->setTexturePriorities(m_priorityCalculator); + layer2->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer1->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer1->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); // Invalidate a tile on layer1 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get()); - layer2->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); updateTextures(); layer1->pushPropertiesTo(layer1Impl.get()); @@ -453,7 +461,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; @@ -468,14 +476,14 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer2->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer1->setTexturePriorities(priorityCalculator); - layer2->setTexturePriorities(priorityCalculator); + layer1->setTexturePriorities(m_priorityCalculator); + layer2->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // Invalidate a tile on layer2 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get()); - layer1->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); - layer2->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer1->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); + layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); updateTextures(); layer1->pushPropertiesTo(layer1Impl.get()); layer2->pushPropertiesTo(layer2Impl.get()); @@ -497,7 +505,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) // We have enough memory for only the visible rect, so we will run out of memory in first idle paint. int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(memoryLimit, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(memoryLimit, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -507,9 +515,9 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) layer->setVisibleContentRect(visibleRect); layer->invalidateContentRect(contentRect); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); // Idle-painting should see no more priority tiles for painting. EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); @@ -520,9 +528,9 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) // We should have one tile on the impl side. EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); // We shouldn't signal we need another idle paint. EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); @@ -530,7 +538,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -547,11 +555,11 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) layer->setVisibleContentRect(contentRect); layer->invalidateContentRect(contentRect); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // Empty layers don't paint or idle-paint. - layer->updateContentRect(updater, contentRect, 0); + layer->updateContentRect(m_updater, contentRect, 0); // Empty layers don't have tiles. EXPECT_EQ(0u, layer->numPaintedTiles()); @@ -571,7 +579,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) IntSize contentBounds(100, 100); IntRect contentRect(IntPoint::zero(), contentBounds); - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -585,9 +593,9 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) for (int i = 0; i < 2; i++) { // Paint / idle-paint. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); // Non-visible layers don't need idle paint. EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); @@ -611,7 +619,7 @@ static void testHaveOuterTiles(FakeCCTiledLayerImpl* layerImpl, int width, int h TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(8000*8000*8, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(8000*8000*8, 1024, CCRenderer::ContentPool); DebugScopedSetImplThread implThread; int tileWidth = FakeTiledLayerChromium::tileSize().width(); @@ -635,7 +643,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers) layer->setVisibleContentRect(visibleRect); layer->invalidateContentRect(contentRect); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // If idlePaintRect gives back a non-empty result then we should paint it. Otherwise, @@ -647,10 +655,10 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers) // If the layer is to be prepainted at all, then after four updates we should have the outer row/columns painted. for (int k = 0; k < 4; ++k) { - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); } @@ -660,10 +668,10 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers) // We don't currently idle paint past the outermost tiles. EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); for (int k = 0; k < 4; ++k) { - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, visibleRect, 0); + layer->updateContentRect(m_updater, visibleRect, 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); } @@ -675,24 +683,19 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers) TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); - FakeTextureAllocator fakeAllocator; - FakeTextureCopier fakeCopier; - FakeTextureUploader fakeUploader; - OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes())); - // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); - updater.update(ccContext.get(), &fakeAllocator, &fakeCopier, &fakeUploader, 1000); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); + updateTextures(1000); layer->pushPropertiesTo(layerImpl.get()); // We should have both tiles on the impl side. @@ -702,21 +705,21 @@ TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) layer->fakeLayerTextureUpdater()->clearPrepareCount(); // Invoke updateContentRect again. As the layer is valid updateContentRect shouldn't be invoked on // the LayerTextureUpdater. - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); - updater.update(ccContext.get(), &fakeAllocator, &fakeCopier, &fakeUploader, 1000); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); + updateTextures(1000); EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); layer->invalidateContentRect(IntRect(0, 0, 50, 50)); // setRectToInvalidate triggers invalidateContentRect() being invoked from updateContentRect. layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get()); layer->fakeLayerTextureUpdater()->clearPrepareCount(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); - updater.update(ccContext.get(), &fakeAllocator, &fakeCopier, &fakeUploader, 1000); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); + updateTextures(1000); EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); layer->fakeLayerTextureUpdater()->clearPrepareCount(); // The layer should still be invalid as updateContentRect invoked invalidate. - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); - updater.update(ccContext.get(), &fakeAllocator, &fakeCopier, &fakeUploader, 1000); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); + updateTextures(1000); EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); } @@ -725,8 +728,9 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) // The updateRect (that indicates what was actually painted) should be in // layer space, not the content space. - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(textureManager.get())); + DebugScopedSetImplThread implThread; IntRect layerBounds(0, 0, 300, 200); IntRect contentBounds(0, 0, 200, 250); @@ -739,32 +743,32 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) // However, it should still be in layer space, not content space. layer->invalidateContentRect(contentBounds); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, contentBounds, 0); + layer->updateContentRect(m_updater, contentBounds, 0); EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); updateTextures(); // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); layer->invalidateContentRect(contentBounds); - layer->updateContentRect(updater, contentBounds, 0); + layer->updateContentRect(m_updater, contentBounds, 0); EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); updateTextures(); // Partial re-paint should also be represented by the updateRect in layer space, not content space. IntRect partialDamage(30, 100, 10, 10); layer->invalidateContentRect(partialDamage); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, contentBounds, 0); + layer->updateContentRect(m_updater, contentBounds, 0); EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); } TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); @@ -778,9 +782,9 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); // Push the tiles to the impl side and check that there is exactly one. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 100), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); @@ -795,9 +799,9 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); // The impl side should get 2x2 tiles now. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 200, 200), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 200, 200), 0); updateTextures(); layer->pushPropertiesTo(layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); @@ -808,8 +812,8 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the // impl side. layer->setNeedsDisplay(); - layer->setTexturePriorities(priorityCalculator); - layer->updateContentRect(updater, IntRect(1, 0, 0, 1), 0); + layer->setTexturePriorities(m_priorityCalculator); + layer->updateContentRect(m_updater, IntRect(1, 0, 0, 1), 0); textureManager->prioritizeTextures(); layer->pushPropertiesTo(layerImpl.get()); @@ -840,17 +844,17 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) rootLayer->setBounds(contentBounds); rootLayer->setVisibleContentRect(contentRect); - rootLayer->setPosition(FloatPoint(150, 150)); + rootLayer->setPosition(FloatPoint(0, 0)); childLayer->setBounds(contentBounds); childLayer->setVisibleContentRect(contentRect); - childLayer->setPosition(FloatPoint(150, 150)); + childLayer->setPosition(FloatPoint(0, 0)); rootLayer->invalidateContentRect(contentRect); childLayer->invalidateContentRect(contentRect); ccLayerTreeHost->setRootLayer(rootLayer); ccLayerTreeHost->setViewportSize(IntSize(300, 300)); - ccLayerTreeHost->updateLayers(updater, memoryLimit); + ccLayerTreeHost->updateLayers(m_updater, memoryLimit); // We'll skip the root layer. EXPECT_TRUE(rootLayer->skipsDraw()); @@ -861,10 +865,10 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) // Remove the child layer. rootLayer->removeAllChildren(); - ccLayerTreeHost->updateLayers(updater, memoryLimit); + ccLayerTreeHost->updateLayers(m_updater, memoryLimit); EXPECT_FALSE(rootLayer->skipsDraw()); - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(&allocator); + ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); WebKit::WebCompositor::shutdown(); @@ -872,16 +876,16 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) TEST_F(TiledLayerChromiumTest, resizeToSmaller) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); layer->setBounds(IntSize(700, 700)); layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); layer->invalidateContentRect(IntRect(0, 0, 700, 700)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 700, 700), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 700, 700), 0); layer->setBounds(IntSize(200, 200)); layer->invalidateContentRect(IntRect(0, 0, 200, 200)); @@ -889,7 +893,7 @@ TEST_F(TiledLayerChromiumTest, resizeToSmaller) TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); int size = 1 << 30; @@ -898,9 +902,9 @@ TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) layer->invalidateContentRect(IntRect(0, 0, size, size)); // Ensure no crash for bounds where size * size would overflow an int. - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 700, 700), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 700, 700), 0); } TEST_F(TiledLayerChromiumTest, partialUpdates) @@ -921,7 +925,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); layer->setBounds(contentBounds); - layer->setPosition(FloatPoint(150, 150)); + layer->setPosition(FloatPoint(0, 0)); layer->setVisibleContentRect(contentRect); layer->invalidateContentRect(contentRect); @@ -929,17 +933,17 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) ccLayerTreeHost->setViewportSize(IntSize(300, 200)); // Full update of all 6 tiles. - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); { DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_TRUE(updater.hasMoreUpdates()); + EXPECT_TRUE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); updateTextures(4); EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); layer->pushPropertiesTo(layerImpl.get()); } @@ -947,17 +951,17 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) // Full update of 3 tiles and partial update of 3 tiles. layer->invalidateContentRect(IntRect(0, 0, 300, 150)); - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); { DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); updateTextures(4); EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_TRUE(updater.hasMoreUpdates()); + EXPECT_TRUE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); updateTextures(4); EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); layer->pushPropertiesTo(layerImpl.get()); } @@ -968,14 +972,14 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) { DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_TRUE(updater.hasMoreUpdates()); + EXPECT_TRUE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); layer->pushPropertiesTo(layerImpl.get()); } @@ -995,14 +999,14 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) { DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_TRUE(updater.hasMoreUpdates()); + EXPECT_TRUE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); updateTextures(4); EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); layer->pushPropertiesTo(layerImpl.get()); } @@ -1013,16 +1017,19 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) { DebugScopedSetImplThread implThread; OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); layer->pushPropertiesTo(layerImpl.get()); } ccLayerTreeHost->commitComplete(); - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(&allocator); + { + DebugScopedSetImplThread implThread; + ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); + } ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); WebKit::WebCompositor::shutdown(); @@ -1030,7 +1037,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); // The tile size is 100x100, so this invalidates and then paints two tiles. @@ -1038,15 +1045,15 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer->invalidateContentRect(IntRect(0, 0, 100, 200)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 100, 200), 0); + layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0); EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount()); } TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; @@ -1059,9 +1066,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds())); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1072,7 +1079,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) occluded.setOcclusion(IntRect(250, 200, 300, 100)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1083,7 +1090,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) occluded.setOcclusion(IntRect(250, 250, 300, 100)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1093,7 +1100,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; @@ -1107,9 +1114,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->setVisibleContentRect(IntRect(0, 0, 600, 360)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 360), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 360), &occluded); EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1122,9 +1129,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) occluded.setOcclusion(IntRect(200, 200, 300, 150)); layer->setVisibleContentRect(IntRect(0, 0, 600, 350)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 350), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 350), &occluded); EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1137,9 +1144,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) occluded.setOcclusion(IntRect(200, 200, 300, 150)); layer->setVisibleContentRect(IntRect(0, 0, 600, 340)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 340), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 340), &occluded); EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1150,7 +1157,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; @@ -1162,11 +1169,14 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) occluded.setOcclusion(IntRect(200, 200, 300, 100)); layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); - updateTextures(); + { + DebugScopedSetImplThread implThread; + updateTextures(); + } EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); @@ -1175,7 +1185,7 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1185,7 +1195,7 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; @@ -1202,9 +1212,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) occluded.setOcclusion(IntRect(100, 100, 150, 50)); layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds())); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1214,7 +1224,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; @@ -1230,9 +1240,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) occluded.setOcclusion(IntRect(200, 200, 300, 100)); layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds())); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); // The content is half the size of the layer (so the number of tiles is fewer). // In this case, the content is 300x300, and since the tile size is 100, the // number of tiles 3x3. @@ -1250,9 +1260,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) occluded.setOcclusion(IntRect(200, 200, 300, 200)); layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds())); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1270,9 +1280,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) occluded.setOcclusion(IntRect(100, 100, 150, 100)); layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds())); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); - layer->updateContentRect(updater, IntRect(0, 0, 600, 600), &occluded); + layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded); EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1282,9 +1292,10 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; + DebugScopedSetImplThread implThread; // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. @@ -1299,13 +1310,13 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) layer->setVisibleContentRect(visibleBounds); layer->setDrawOpacity(1); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty. layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(contentBounds); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.isEmpty()); @@ -1318,7 +1329,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) opaquePaintRect = IntRect(10, 10, 90, 190); layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); layer->invalidateContentRect(contentBounds); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); @@ -1331,7 +1342,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) // If we paint again without invalidating, the same stuff should be opaque. layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); @@ -1346,7 +1357,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) // not be affected. layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(0, 0, 1, 1)); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); @@ -1361,7 +1372,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) // not be affected. layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(10, 10, 1, 1)); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds()); @@ -1375,9 +1386,10 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) { - OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024); + OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); TestCCOcclusionTracker occluded; + DebugScopedSetImplThread implThread; // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. @@ -1392,13 +1404,13 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) layer->setVisibleContentRect(visibleBounds); layer->setDrawOpacity(1); - layer->setTexturePriorities(priorityCalculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // Invalidates and paints the whole layer. layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(contentBounds); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.isEmpty()); @@ -1413,7 +1425,7 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(0, 0, 1, 1)); layer->invalidateContentRect(IntRect(50, 200, 10, 10)); - layer->updateContentRect(updater, contentBounds, &occluded); + layer->updateContentRect(m_updater, contentBounds, &occluded); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.isEmpty()); @@ -1474,14 +1486,14 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca root->invalidateContentRect(rootRect); child->invalidateContentRect(childRect); child2->invalidateContentRect(child2Rect); - ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); + ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max()); { DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); root->fakeLayerTextureUpdater()->clearUpdateCount(); child->fakeLayerTextureUpdater()->clearUpdateCount(); @@ -1509,14 +1521,14 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca root->invalidateContentRect(rootRect); child->invalidateContentRect(childRect); child2->invalidateContentRect(child2Rect); - ccLayerTreeHost->updateLayers(updater, (3 * 2 + 3 * 1) * (100 * 100) * 4); + ccLayerTreeHost->updateLayers(m_updater, (3 * 2 + 3 * 1) * (100 * 100) * 4); { DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); root->fakeLayerTextureUpdater()->clearUpdateCount(); child->fakeLayerTextureUpdater()->clearUpdateCount(); @@ -1545,14 +1557,14 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca root->invalidateContentRect(rootRect); child->invalidateContentRect(childRect); child2->invalidateContentRect(child2Rect); - ccLayerTreeHost->updateLayers(updater, (3 * 1) * (100 * 100) * 4); + ccLayerTreeHost->updateLayers(m_updater, (3 * 1) * (100 * 100) * 4); { DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); - EXPECT_FALSE(updater.hasMoreUpdates()); + EXPECT_FALSE(m_updater.hasMoreUpdates()); root->fakeLayerTextureUpdater()->clearUpdateCount(); child->fakeLayerTextureUpdater()->clearUpdateCount(); @@ -1574,7 +1586,10 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca } ccLayerTreeHost->commitComplete(); - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(&allocator); + { + DebugScopedSetImplThread implThread; + ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); + } ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); WebKit::WebCompositor::shutdown(); @@ -1605,7 +1620,7 @@ public: { OwnPtr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPainter::create()); m_trackingLayerPainter = trackingLayerPainter.get(); - m_layerTextureUpdater = BitmapCanvasLayerTextureUpdater::create(trackingLayerPainter.release(), false); + m_layerTextureUpdater = BitmapCanvasLayerTextureUpdater::create(trackingLayerPainter.release()); } virtual ~UpdateTrackingTiledLayerChromium() { } @@ -1621,8 +1636,7 @@ private: TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) { - OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000)); - CCPriorityCalculator calculator; + OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000, CCRenderer::ContentPool)); RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(textureManager.get())); @@ -1635,53 +1649,58 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) EXPECT_EQ(contentRect.size(), layer->contentBounds()); layer->setVisibleContentRect(contentRect); - layer->setTexturePriorities(calculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // Update the whole tile. - layer->updateContentRect(updater, contentRect, 0); + layer->updateContentRect(m_updater, contentRect, 0); layer->trackingLayerPainter()->resetPaintedRect(); EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); - updateTextures(); + { + DebugScopedSetImplThread implThread; + updateTextures(); + } // Invalidate the entire layer in content space. When painting, the rect given to webkit should match the layer's bounds. layer->invalidateContentRect(contentRect); - layer->updateContentRect(updater, contentRect, 0); + layer->updateContentRect(m_updater, contentRect, 0); EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) { - OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000)); - CCPriorityCalculator calculator; + OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000, CCRenderer::ContentPool)); RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(textureManager.get())); IntRect layerRect(0, 0, 30, 31); layer->setPosition(layerRect.location()); layer->setBounds(layerRect.size()); - layer->setContentsScale(1.3); + layer->setContentsScale(1.3f); IntRect contentRect(IntPoint(), layer->contentBounds()); layer->setVisibleContentRect(contentRect); - layer->setTexturePriorities(calculator); + layer->setTexturePriorities(m_priorityCalculator); textureManager->prioritizeTextures(); // Update the whole tile. - layer->updateContentRect(updater, contentRect, 0); + layer->updateContentRect(m_updater, contentRect, 0); layer->trackingLayerPainter()->resetPaintedRect(); EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); - updateTextures(); + { + DebugScopedSetImplThread implThread; + updateTextures(); + } // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. layer->setNeedsDisplayRect(layerRect); - layer->updateContentRect(updater, contentRect, 0); + layer->updateContentRect(m_updater, contentRect, 0); EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } diff --git a/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp b/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp index 937cee202..eb442f4e3 100644 --- a/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp +++ b/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp @@ -200,10 +200,10 @@ TEST(WebTransformationMatrixTest, verifyMatrixInversion) EXPECT_TRUE(scale.isInvertible()); WebTransformationMatrix inverseScale = scale.inverse(); - EXPECT_ROW1_EQ(0.25, 0, 0, 0, inverseScale); - EXPECT_ROW2_EQ(0, 0.1, 0, 0, inverseScale); - EXPECT_ROW3_EQ(0, 0, 0.01, 0, inverseScale); - EXPECT_ROW4_EQ(0, 0, 0, 1, inverseScale); + EXPECT_ROW1_EQ(0.25, 0, 0, 0, inverseScale); + EXPECT_ROW2_EQ(0, .1f, 0, 0, inverseScale); + EXPECT_ROW3_EQ(0, 0, .01f, 0, inverseScale); + EXPECT_ROW4_EQ(0, 0, 0, 1, inverseScale); // Try to invert a matrix that is not invertible. // The inverse() function should simply return an identity matrix. @@ -979,7 +979,7 @@ TEST(WebTransformationMatrixTest, verifyIsIntegerTranslation) EXPECT_TRUE(A.isIntegerTranslation()); A.makeIdentity(); - A.translate(2.0, 3.0); + A.translate(2, 3); EXPECT_TRUE(A.isIntegerTranslation()); A.makeIdentity(); @@ -1183,7 +1183,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutX) EXPECT_ROW3_NEAR(0, sin(expectedRotationAngle), cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); EXPECT_ROW4_EQ(0, 0, 0, 1, to); - expectedRotationAngle = 45.0 * piDouble / 180.0; + expectedRotationAngle = 45 * piDouble / 180.0; to.makeIdentity(); to.rotate3d(1, 0, 0, 90); to.blend(from, 0.5); @@ -1222,7 +1222,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutY) EXPECT_ROW3_NEAR(-sin(expectedRotationAngle), 0, cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); EXPECT_ROW4_EQ(0, 0, 0, 1, to); - expectedRotationAngle = 45.0 * piDouble / 180.0; + expectedRotationAngle = 45 * piDouble / 180.0; to.makeIdentity(); to.rotate3d(0, 1, 0, 90); to.blend(from, 0.5); @@ -1261,7 +1261,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutZ) EXPECT_ROW3_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD); EXPECT_ROW4_EQ(0, 0, 0, 1, to); - expectedRotationAngle = 45.0 * piDouble / 180.0; + expectedRotationAngle = 45 * piDouble / 180.0; to.makeIdentity(); to.rotate3d(0, 0, 1, 90); to.blend(from, 0.5); diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog index 7d313e348..a6fb4a584 100644 --- a/Source/WebKit/efl/ChangeLog +++ b/Source/WebKit/efl/ChangeLog @@ -1,3 +1,124 @@ +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * DefaultTheme/default.edc: + +2012-07-20 Kihong Kwon <kihong.kwon@samsung.com> + + [EFL] Remove unused headers from ewk_security_origin + https://bugs.webkit.org/show_bug.cgi?id=91914 + + Reviewed by Noam Rosenthal. + + There are some unused header in the ewk_security_origin.h/cpp + We need to remove them. + + * ewk/ewk_security_origin.cpp: + * ewk/ewk_security_origin.h: + +2012-07-20 Christophe Dumez <christophe.dumez@intel.com> + + [EFL] Proxy configuration should honor the no_proxy environment variable + https://bugs.webkit.org/show_bug.cgi?id=91747 + + Reviewed by Kenneth Rohde Christiansen. + + Use the new custom proxy resolver from WebCore in + WebKit1-EFL's ewk_network_proxy_uri_set() / get(), + instead of the less flexible SOUP_SESSION_PROXY_URI + SoupSession property. + + * ewk/ewk_network.cpp: + (ewk_network_proxy_uri_set): + (ewk_network_proxy_uri_get): + +2012-07-20 Thiago Marcos P. Santos <thiago.santos@intel.com> + + [EFL] Fix build when protocol handler and custom scheme is disabled + https://bugs.webkit.org/show_bug.cgi?id=91840 + + Reviewed by Kenneth Rohde Christiansen. + + Fixed namespace closing bracket positioning. + + * WebCoreSupport/RegisterProtocolHandlerClientEfl.cpp: + (WebCore): + +2012-07-20 Kihong Kwon <kihong.kwon@samsung.com> + + [EFL] Check parameters of ewk APIs in ewk_security_origin + https://bugs.webkit.org/show_bug.cgi?id=91833 + + Reviewed by Kentaro Hara. + + For preventing crash, check parameters of ewk APIs in the ewk_security_origin.cpp. + + * ewk/ewk_security_origin.cpp: + (ewk_security_origin_port_get): + (ewk_security_origin_web_database_usage_get): + (ewk_security_origin_web_database_quota_get): + (ewk_security_origin_web_database_quota_set): + (ewk_security_origin_application_cache_quota_set): + (ewk_security_origin_application_cache_clear): + (ewk_security_origin_web_database_get_all): + (ewk_security_origin_free): + * ewk/ewk_security_origin.h: + +2012-07-19 Kihong Kwon <kihong.kwon@samsung.com> + + [EFL] Enable interactive form validation + https://bugs.webkit.org/show_bug.cgi?id=91711 + + Reviewed by Ryosuke Niwa. + + Enable interactive form validation on the Efl. + This makes we can validate data at form elements. + In addition, it is already enabled in the DRT. + + * ewk/ewk_view.cpp: + (_ewk_view_priv_new): + +2012-07-18 Christophe Dumez <christophe.dumez@intel.com> + + [EFL] Add central error management to EFL port + https://bugs.webkit.org/show_bug.cgi?id=91598 + + Reviewed by Kenneth Rohde Christiansen. + + Make use of ErrorsEfl header from WebCore in + EFL's FrameLoaderClient now that we have + a central place for errors. + + * WebCoreSupport/FrameLoaderClientEfl.cpp: + (WebCore::FrameLoaderClientEfl::cancelledError): + (WebCore::FrameLoaderClientEfl::blockedError): + (WebCore::FrameLoaderClientEfl::cannotShowURLError): + (WebCore::FrameLoaderClientEfl::interruptedForPolicyChangeError): + (WebCore::FrameLoaderClientEfl::cannotShowMIMETypeError): + (WebCore::FrameLoaderClientEfl::fileDoesNotExistError): + (WebCore::FrameLoaderClientEfl::pluginWillHandleLoadError): + (WebCore::FrameLoaderClientEfl::shouldFallBack): + +2012-07-18 Seokju Kwon <seokju.kwon@samsung.com> + + [EFL][DRT] Add support for Web Inspector in WebKit-EFL DRT + https://bugs.webkit.org/show_bug.cgi?id=87935 + + Reviewed by Andreas Kling. + + Add implementation of DumpRenderTreeSupportEfl::evaluateInWebInspector(). + Some scripts for test should be evaluated in frontend. + + * WebCoreSupport/DumpRenderTreeSupportEfl.cpp: + (DumpRenderTreeSupportEfl::evaluateInWebInspector): + * WebCoreSupport/DumpRenderTreeSupportEfl.h: + 2012-07-17 Christophe Dumez <christophe.dumez@intel.com> [EFL] Replace 0 by NULL in public headers documentation diff --git a/Source/WebKit/efl/DefaultTheme/default.edc b/Source/WebKit/efl/DefaultTheme/default.edc index 5715e289d..1ecd0442b 100644 --- a/Source/WebKit/efl/DefaultTheme/default.edc +++ b/Source/WebKit/efl/DefaultTheme/default.edc @@ -48,7 +48,7 @@ collections { #include "widget/check/check.edc" #include "widget/entry/entry.edc" #include "widget/combo/combo.edc" -#ifdef ENABLE_PROGRESS_TAG +#ifdef ENABLE_PROGRESS_ELEMENT #include "widget/progressbar/progressbar.edc" #endif #include "widget/file/file.edc" diff --git a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp index 485db7f09..bc0dc61be 100644 --- a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp @@ -520,6 +520,18 @@ bool DumpRenderTreeSupportEfl::isTargetItem(const Ewk_History_Item* ewkHistoryIt return historyItem->isTargetItem(); } +void DumpRenderTreeSupportEfl::evaluateInWebInspector(const Evas_Object* ewkView, long callId, const String& script) +{ +#if ENABLE(INSPECTOR) + WebCore::Page* page = EWKPrivate::corePage(ewkView); + if (!page) + return; + + if (page->inspectorController()) + page->inspectorController()->evaluateForTestInFrontend(callId, script); +#endif +} + void DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld(const Evas_Object* ewkFrame, int worldID, JSObjectRef globalObject, const String& script) { WebCore::Frame* coreFrame = EWKPrivate::coreFrame(ewkFrame); diff --git a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h index 611f3c85f..eaf11d328 100644 --- a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h +++ b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h @@ -94,6 +94,7 @@ public: static HistoryItemChildrenVector childHistoryItems(const Ewk_History_Item*); static String historyItemTarget(const Ewk_History_Item*); static bool isTargetItem(const Ewk_History_Item*); + static void evaluateInWebInspector(const Evas_Object* ewkView, long callId, const String& script); static void evaluateScriptInIsolatedWorld(const Evas_Object* ewkFrame, int worldID, JSObjectRef globalObject, const String& script); static JSGlobalContextRef globalContextRefForFrame(const Evas_Object* ewkFrame); diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp index 5072de236..d26961b16 100644 --- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp @@ -38,6 +38,7 @@ #include "APICast.h" #include "DocumentLoader.h" +#include "ErrorsEfl.h" #include "FormState.h" #include "FrameLoader.h" #include "FrameNetworkingContextEfl.h" @@ -867,69 +868,44 @@ void FrameLoaderClientEfl::download(ResourceHandle*, const ResourceRequest& requ ewk_view_download_request(m_view, &download); } -// copied from WebKit/Misc/WebKitErrors[Private].h -enum { - WebKitErrorCannotShowMIMEType = 100, - WebKitErrorCannotShowURL = 101, - WebKitErrorFrameLoadInterruptedByPolicyChange = 102, - WebKitErrorCannotUseRestrictedPort = 103, - WebKitErrorCannotFindPlugIn = 200, - WebKitErrorCannotLoadPlugIn = 201, - WebKitErrorJavaUnavailable = 202, - WebKitErrorPluginWillHandleLoad = 204 -}; - -// Domains used for ResourceError -const char* const NSURLErrorDomain = "NSURLErrorDomain"; -const char* const WebKitErrorDomain = "WebKitErrorDomain"; - ResourceError FrameLoaderClientEfl::cancelledError(const ResourceRequest& request) { - ResourceError error(NSURLErrorDomain, -999, request.url().string(), - "Request cancelled"); - error.setIsCancellation(true); - return error; + return WebCore::cancelledError(request); } ResourceError FrameLoaderClientEfl::blockedError(const ResourceRequest& request) { - return ResourceError(WebKitErrorDomain, WebKitErrorCannotUseRestrictedPort, request.url().string(), - "Request blocked"); + return WebCore::blockedError(request); } ResourceError FrameLoaderClientEfl::cannotShowURLError(const ResourceRequest& request) { - return ResourceError(WebKitErrorDomain, WebKitErrorCannotShowURL, request.url().string(), - "Cannot show URL"); + return WebCore::cannotShowURLError(request); } ResourceError FrameLoaderClientEfl::interruptedForPolicyChangeError(const ResourceRequest& request) { - return ResourceError(WebKitErrorDomain, WebKitErrorFrameLoadInterruptedByPolicyChange, - request.url().string(), "Frame load interrupted by policy change"); + return WebCore::interruptedForPolicyChangeError(request); } ResourceError FrameLoaderClientEfl::cannotShowMIMETypeError(const ResourceResponse& response) { - return ResourceError(NSURLErrorDomain, WebKitErrorCannotShowMIMEType, response.url().string(), - "Cannot show mimetype"); + return WebCore::cannotShowMIMETypeError(response); } ResourceError FrameLoaderClientEfl::fileDoesNotExistError(const ResourceResponse& response) { - return ResourceError(NSURLErrorDomain, -998 /* ### */, response.url().string(), - "File does not exist"); + return WebCore::fileDoesNotExistError(response); } ResourceError FrameLoaderClientEfl::pluginWillHandleLoadError(const ResourceResponse& response) { - return ResourceError(WebKitErrorDomain, WebKitErrorPluginWillHandleLoad, response.url().string(), - "Plugin will handle load"); + return WebCore::pluginWillHandleLoadError(response); } bool FrameLoaderClientEfl::shouldFallBack(const ResourceError& error) { - return !(error.isCancellation() || error.errorCode() == WebKitErrorFrameLoadInterruptedByPolicyChange || error.errorCode() == WebKitErrorPluginWillHandleLoad); + return !(error.isCancellation() || error.errorCode() == PolicyErrorFrameLoadInterruptedByPolicyChange || error.errorCode() == PluginErrorWillHandleLoad); } bool FrameLoaderClientEfl::canCachePage() const diff --git a/Source/WebKit/efl/WebCoreSupport/RegisterProtocolHandlerClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/RegisterProtocolHandlerClientEfl.cpp index 5127e72bf..8f30850f6 100644 --- a/Source/WebKit/efl/WebCoreSupport/RegisterProtocolHandlerClientEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/RegisterProtocolHandlerClientEfl.cpp @@ -87,5 +87,6 @@ void RegisterProtocolHandlerClientEfl::unregisterProtocolHandler(const String& s } #endif -#endif // ENABLE(REGISTER_PROTOCOL_HANDLER) || ENABLE(CUSTOM_SCHEME_HANDLER) } + +#endif // ENABLE(REGISTER_PROTOCOL_HANDLER) || ENABLE(CUSTOM_SCHEME_HANDLER) diff --git a/Source/WebKit/efl/ewk/ewk_network.cpp b/Source/WebKit/efl/ewk/ewk_network.cpp index 8ad3c4927..781e945ab 100644 --- a/Source/WebKit/efl/ewk/ewk_network.cpp +++ b/Source/WebKit/efl/ewk/ewk_network.cpp @@ -21,6 +21,7 @@ #include "ewk_network.h" #include "NetworkStateNotifier.h" +#include "ProxyResolverSoup.h" #include "ResourceHandle.h" #include "ewk_private.h" #include <Eina.h> @@ -37,18 +38,20 @@ void ewk_network_proxy_uri_set(const char* proxy) return; } - SoupURI* uri = soup_uri_new(proxy); - EINA_SAFETY_ON_NULL_RETURN(uri); - - g_object_set(session, SOUP_SESSION_PROXY_URI, uri, NULL); - soup_uri_free(uri); + SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(proxy, 0); + soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl)); + g_object_unref(resolverEfl); } const char* ewk_network_proxy_uri_get(void) { SoupURI* uri; SoupSession* session = WebCore::ResourceHandle::defaultSession(); - g_object_get(session, SOUP_SESSION_PROXY_URI, &uri, NULL); + SoupProxyURIResolver* resolver = SOUP_PROXY_URI_RESOLVER(soup_session_get_feature(session, SOUP_TYPE_PROXY_RESOLVER)); + if (!resolver) + return 0; + + g_object_get(resolver, SOUP_PROXY_RESOLVER_WK_PROXY_URI, &uri, NULL); if (!uri) { ERR("no proxy uri"); diff --git a/Source/WebKit/efl/ewk/ewk_security_origin.cpp b/Source/WebKit/efl/ewk/ewk_security_origin.cpp index 8b87bc3bf..1b6884e8c 100644 --- a/Source/WebKit/efl/ewk/ewk_security_origin.cpp +++ b/Source/WebKit/efl/ewk/ewk_security_origin.cpp @@ -24,11 +24,9 @@ #include "ApplicationCacheStorage.h" #include "DatabaseTracker.h" #include "SecurityOrigin.h" -#include "ewk_private.h" #include "ewk_security_origin_private.h" #include "ewk_web_database.h" #include "ewk_web_database_private.h" -#include <Eina.h> #include <wtf/RefPtr.h> #include <wtf/UnusedParam.h> #include <wtf/text/CString.h> @@ -60,11 +58,14 @@ const char* ewk_security_origin_string_get(const Ewk_Security_Origin* origin) uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); return origin->securityOrigin->port(); } uint64_t ewk_security_origin_web_database_usage_get(const Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + #if ENABLE(SQL_DATABASE) return WebCore::DatabaseTracker::tracker().usageForOrigin(origin->securityOrigin.get()); #else @@ -74,6 +75,8 @@ uint64_t ewk_security_origin_web_database_usage_get(const Ewk_Security_Origin* o uint64_t ewk_security_origin_web_database_quota_get(const Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + #if ENABLE(SQL_DATABASE) return WebCore::DatabaseTracker::tracker().quotaForOrigin(origin->securityOrigin.get()); #else @@ -83,6 +86,8 @@ uint64_t ewk_security_origin_web_database_quota_get(const Ewk_Security_Origin* o void ewk_security_origin_web_database_quota_set(const Ewk_Security_Origin* origin, uint64_t quota) { + EINA_SAFETY_ON_NULL_RETURN(origin); + #if ENABLE(SQL_DATABASE) WebCore::DatabaseTracker::tracker().setQuota(origin->securityOrigin.get(), quota); #endif @@ -90,16 +95,20 @@ void ewk_security_origin_web_database_quota_set(const Ewk_Security_Origin* origi void ewk_security_origin_application_cache_quota_set(const Ewk_Security_Origin* origin, int64_t quota) { + EINA_SAFETY_ON_NULL_RETURN(origin); WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin->securityOrigin.get(), quota); } void ewk_security_origin_application_cache_clear(const Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN(origin); WebCore::ApplicationCache::deleteCacheForOrigin(origin->securityOrigin.get()); } Eina_List* ewk_security_origin_web_database_get_all(const Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + Eina_List* databases = 0; #if ENABLE(SQL_DATABASE) Vector<WTF::String> names; @@ -119,6 +128,8 @@ Eina_List* ewk_security_origin_web_database_get_all(const Ewk_Security_Origin* o void ewk_security_origin_free(Ewk_Security_Origin* origin) { + EINA_SAFETY_ON_NULL_RETURN(origin); + origin->securityOrigin = 0; eina_stringshare_del(origin->host); eina_stringshare_del(origin->protocol); diff --git a/Source/WebKit/efl/ewk/ewk_security_origin.h b/Source/WebKit/efl/ewk/ewk_security_origin.h index 0fddcc0ff..9996972d7 100644 --- a/Source/WebKit/efl/ewk/ewk_security_origin.h +++ b/Source/WebKit/efl/ewk/ewk_security_origin.h @@ -33,7 +33,7 @@ #ifndef ewk_security_origin_h #define ewk_security_origin_h -#include <Evas.h> +#include <Eina.h> #ifdef __cplusplus extern "C" { @@ -81,7 +81,7 @@ EAPI const char *ewk_security_origin_string_get(const Ewk_Security_Orig * * @param o security origin object * - * @return the port + * @return the port or @c 0 if there is not a proper security origin scheme */ EAPI uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin *o); @@ -91,7 +91,7 @@ EAPI uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin * This function won't work if Web SQL Database was not enabled when * building WebKit and will just return 0. * - * @param o security origin object + * @param o security origin object or @c 0 if there is not a proper security origin scheme * * @return the usage in bytes */ @@ -105,7 +105,7 @@ EAPI uint64_t ewk_security_origin_web_database_usage_get(const Ewk_S * * @param o security origin object * - * @return the quota in bytes + * @return the quota in bytes or @c 0 if there is not a proper security origin scheme */ EAPI uint64_t ewk_security_origin_web_database_quota_get(const Ewk_Security_Origin *o); @@ -146,7 +146,7 @@ EAPI void ewk_security_origin_application_cache_clear(const Ewk_ * * @param o security origin object * - * @return list of web databases in the security origin + * @return list of web databases in the security origin or @c NULL if there is not a proper security origin scheme * * @see ewk_web_database_free() * @see ewk_web_database_list_free() diff --git a/Source/WebKit/efl/ewk/ewk_view.cpp b/Source/WebKit/efl/ewk/ewk_view.cpp index f0859dfee..dc8ac88ba 100644 --- a/Source/WebKit/efl/ewk/ewk_view.cpp +++ b/Source/WebKit/efl/ewk/ewk_view.cpp @@ -797,6 +797,7 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) #if ENABLE(FULLSCREEN_API) priv->pageSettings->setFullScreenEnabled(true); #endif + priv->pageSettings->setInteractiveFormValidationEnabled(true); url = priv->pageSettings->userStyleSheetLocation(); priv->settings.userStylesheet = eina_stringshare_add(url.string().utf8().data()); diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog index b994b7000..60d697325 100644 --- a/Source/WebKit/mac/ChangeLog +++ b/Source/WebKit/mac/ChangeLog @@ -1,3 +1,70 @@ +2012-07-23 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * Configurations/FeatureDefines.xcconfig: + +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_DETAILS to ENABLE_DETAILS_ELEMENT + https://bugs.webkit.org/show_bug.cgi?id=91928 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * Configurations/FeatureDefines.xcconfig: + +2012-07-20 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_DATALIST to ENABLE_DATALIST_ELEMENT + https://bugs.webkit.org/show_bug.cgi?id=91846 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * Configurations/FeatureDefines.xcconfig: + +2012-07-18 Benjamin Poulain <bpoulain@apple.com> + + [Mac] Make WebDataSourcePrivate lighter + https://bugs.webkit.org/show_bug.cgi?id=91511 + + Reviewed by Anders Carlsson. + + Make WebDataSourcePrivate a simple C++ class and use smart pointers for memory management. + + Since the "loader" attribute is only set on initialization, all the assertions spread in + various function are removed in favor of assertions on initialization. + + * WebView/WebDataSource.h: + * WebView/WebDataSource.mm: + (WebDataSourcePrivate): + (WebDataSourcePrivate::WebDataSourcePrivate): + (WebDataSourcePrivate::~WebDataSourcePrivate): + Use a class instead of a Objective-C object for WebDataSourcePrivate. + Use smart pointers instead of ref counting manually. + + (-[WebDataSource _setRepresentation:]): + (-[WebDataSource _addSubframeArchives:]): + (-[WebDataSource _transferApplicationCache:]): + (-[WebDataSource _setDeferMainResourceDataLoad:]): + (-[WebDataSource _documentFragmentWithArchive:]): + (-[WebDataSource _initWithDocumentLoader:]): + + (+[WebDataSource initialize]): + (-[WebDataSource dealloc]): + (-[WebDataSource finalize]): + WebDataSource takes the special initialization and destruction that was done in WebDataSourcePrivate. + + (-[WebDataSource representation]): + 2012-07-17 Vivek Galatage <vivekgalatage@gmail.com> Web Inspector: refactor InspectorController::connectFrontend() to accept InspectorFrontendChannel. diff --git a/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig b/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig index 1fc82597c..dedcb83f2 100644 --- a/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig +++ b/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig @@ -49,9 +49,9 @@ ENABLE_CSS_VARIABLES = ; ENABLE_CUSTOM_SCHEME_HANDLER = ; ENABLE_DASHBOARD_SUPPORT = $(ENABLE_DASHBOARD_SUPPORT_$(REAL_PLATFORM_NAME)); ENABLE_DASHBOARD_SUPPORT_macosx = ENABLE_DASHBOARD_SUPPORT; -ENABLE_DATALIST = ; +ENABLE_DATALIST_ELEMENT = ; ENABLE_DATA_TRANSFER_ITEMS = ; -ENABLE_DETAILS = ENABLE_DETAILS; +ENABLE_DETAILS_ELEMENT = ENABLE_DETAILS_ELEMENT; ENABLE_DEVICE_ORIENTATION = ; ENABLE_DIALOG_ELEMENT = ; ENABLE_DIRECTORY_UPLOAD = ; @@ -98,7 +98,7 @@ ENABLE_LINK_PRERENDER = ; ENABLE_MATHML = ENABLE_MATHML; ENABLE_MEDIA_SOURCE = ; ENABLE_MEDIA_STATISTICS = ; -ENABLE_METER_TAG = ENABLE_METER_TAG; +ENABLE_METER_ELEMENT = ENABLE_METER_ELEMENT; ENABLE_MHTML = ; ENABLE_MICRODATA = ; ENABLE_MUTATION_OBSERVERS = ENABLE_MUTATION_OBSERVERS; @@ -108,7 +108,7 @@ ENABLE_NOTIFICATIONS_macosx_1070 = ; ENABLE_NOTIFICATIONS_macosx_1080 = ENABLE_NOTIFICATIONS; ENABLE_NOTIFICATIONS_macosx_1090 = ENABLE_NOTIFICATIONS; ENABLE_PAGE_VISIBILITY_API = ; -ENABLE_PROGRESS_TAG = ENABLE_PROGRESS_TAG; +ENABLE_PROGRESS_ELEMENT = ENABLE_PROGRESS_ELEMENT; ENABLE_QUOTA = ; ENABLE_REGISTER_PROTOCOL_HANDLER = ; ENABLE_REQUEST_ANIMATION_FRAME = ENABLE_REQUEST_ANIMATION_FRAME; @@ -135,4 +135,4 @@ ENABLE_WEB_TIMING = ; ENABLE_WORKERS = ENABLE_WORKERS; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS3_FLEXBOX) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_VARIABLES) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_TAG) $(ENABLE_MICRODATA) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PROGRESS_TAG) $(ENABLE_QUOTA) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_UNDO_MANAGER) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS3_FLEXBOX) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_VARIABLES) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MICRODATA) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_QUOTA) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_UNDO_MANAGER) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XSLT); diff --git a/Source/WebKit/mac/WebView/WebDataSource.h b/Source/WebKit/mac/WebView/WebDataSource.h index 1ffd3398a..c742f1efb 100644 --- a/Source/WebKit/mac/WebView/WebDataSource.h +++ b/Source/WebKit/mac/WebView/WebDataSource.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2012 Apple Computer, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,7 +35,6 @@ @class NSURLRequest; @class NSURLResponse; @class WebArchive; -@class WebDataSourcePrivate; @class WebFrame; @class WebResource; @@ -49,7 +48,7 @@ @interface WebDataSource : NSObject { @private - WebDataSourcePrivate *_private; + void *_private; } /*! diff --git a/Source/WebKit/mac/WebView/WebDataSource.mm b/Source/WebKit/mac/WebView/WebDataSource.mm index d9125f70f..52048e714 100644 --- a/Source/WebKit/mac/WebView/WebDataSource.mm +++ b/Source/WebKit/mac/WebView/WebDataSource.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,63 +62,38 @@ #import <runtime/InitializeThreading.h> #import <wtf/Assertions.h> #import <wtf/MainThread.h> +#import <wtf/RefPtr.h> +#import <wtf/RetainPtr.h> using namespace WebCore; -@interface WebDataSourcePrivate : NSObject { -@public - WebDocumentLoaderMac* loader; - - id <WebDocumentRepresentation> representation; - - BOOL representationFinishedLoading; - BOOL includedInWebKitStatistics; -} -@end - -@implementation WebDataSourcePrivate - -+ (void)initialize -{ - JSC::initializeThreading(); - WTF::initializeMainThreadToProcessMainThread(); - WebCore::RunLoop::initializeMainRunLoop(); - WebCoreObjCFinalizeOnMainThread(self); -} - -- (void)dealloc +class WebDataSourcePrivate { - if (WebCoreObjCScheduleDeallocateOnMainThread([WebDataSourcePrivate class], self)) - return; - - ASSERT(loader); - if (loader) { - ASSERT(!loader->isLoading()); - loader->detachDataSource(); - loader->deref(); +public: + WebDataSourcePrivate(PassRefPtr<WebDocumentLoaderMac> loader) + : loader(loader) + { + ASSERT(this->loader); + } + ~WebDataSourcePrivate() + { + if (loader) { + ASSERT(!loader->isLoading()); + loader->detachDataSource(); + } } - - [representation release]; - [super dealloc]; -} + RefPtr<WebDocumentLoaderMac> loader; + RetainPtr<id<WebDocumentRepresentation> > representation; + BOOL representationFinishedLoading; + BOOL includedInWebKitStatistics; +}; -- (void)finalize +static inline WebDataSourcePrivate* toPrivate(void* privateAttribute) { - ASSERT_MAIN_THREAD(); - - ASSERT(loader); - if (loader) { - ASSERT(!loader->isLoading()); - loader->detachDataSource(); - loader->deref(); - } - - [super finalize]; + return reinterpret_cast<WebDataSourcePrivate*>(privateAttribute); } -@end - @interface WebDataSource (WebFileInternal) @end @@ -126,9 +101,8 @@ using namespace WebCore; - (void)_setRepresentation:(id<WebDocumentRepresentation>)representation { - [_private->representation release]; - _private->representation = [representation retain]; - _private->representationFinishedLoading = NO; + toPrivate(_private)->representation = representation; + toPrivate(_private)->representationFinishedLoading = NO; } static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCClass, NSArray *supportTypes) @@ -152,21 +126,28 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl @implementation WebDataSource (WebPrivate) ++ (void)initialize +{ + if (self == [WebDataSource class]) { + JSC::initializeThreading(); + WTF::initializeMainThreadToProcessMainThread(); + WebCore::RunLoop::initializeMainRunLoop(); + WebCoreObjCFinalizeOnMainThread(self); + } +} + - (NSError *)_mainDocumentError { - return _private->loader->mainDocumentError(); + return toPrivate(_private)->loader->mainDocumentError(); } - (void)_addSubframeArchives:(NSArray *)subframeArchives { // FIXME: This SPI is poor, poor design. Can we come up with another solution for those who need it? - DocumentLoader* loader = [self _documentLoader]; - ASSERT(loader); - NSEnumerator *enumerator = [subframeArchives objectEnumerator]; WebArchive *archive; while ((archive = [enumerator nextObject]) != nil) - loader->addAllArchiveResources([archive _coreLegacyWebArchive]); + toPrivate(_private)->loader->addAllArchiveResources([archive _coreLegacyWebArchive]); } - (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL @@ -197,24 +178,20 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (BOOL)_transferApplicationCache:(NSString*)destinationBundleIdentifier { - DocumentLoader* loader = [self _documentLoader]; - - if (!loader) + if (!toPrivate(_private)->loader) return NO; NSString *cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:destinationBundleIdentifier]; - return ApplicationCacheStorage::storeCopyOfCache(cacheDir, loader->applicationCacheHost()); + return ApplicationCacheStorage::storeCopyOfCache(cacheDir, toPrivate(_private)->loader->applicationCacheHost()); } - (void)_setDeferMainResourceDataLoad:(BOOL)flag { - DocumentLoader* loader = [self _documentLoader]; - - if (!loader) + if (!toPrivate(_private)->loader) return; - loader->setDeferMainResourceDataLoad(flag); + toPrivate(_private)->loader->setDeferMainResourceDataLoad(flag); } @end @@ -223,7 +200,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (void)_finishedLoading { - _private->representationFinishedLoading = YES; + toPrivate(_private)->representationFinishedLoading = YES; [[self representation] finishedLoadingWithDataSource:self]; } @@ -238,8 +215,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (void)_setMainDocumentError:(NSError *)error { - if (!_private->representationFinishedLoading) { - _private->representationFinishedLoading = YES; + if (!toPrivate(_private)->representationFinishedLoading) { + toPrivate(_private)->representationFinishedLoading = YES; [[self representation] receivedError:error withDataSource:self]; } } @@ -289,8 +266,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([WebView canShowMIMETypeAsHTML:MIMEType]) { NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding]; // FIXME: seems poor form to do this as a side effect of getting a document fragment - if (DocumentLoader* loader = [self _documentLoader]) - loader->addAllArchiveResources([archive _coreLegacyWebArchive]); + if (toPrivate(_private)->loader) + toPrivate(_private)->loader->addAllArchiveResources([archive _coreLegacyWebArchive]); DOMDocumentFragment *fragment = [[self webFrame] _documentFragmentWithMarkupString:markupString baseURLString:[[mainResource URL] _web_originalDataAsString]]; [markupString release]; @@ -332,7 +309,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl // May return nil if not initialized with a URL. - (NSURL *)_URL { - const KURL& url = _private->loader->url(); + const KURL& url = toPrivate(_private)->loader->url(); if (url.isEmpty()) return nil; return url; @@ -360,12 +337,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl [newRep release]; } - [_private->representation setDataSource:self]; + id<WebDocumentRepresentation> representation = toPrivate(_private)->representation.get(); + [representation setDataSource:self]; } - (DocumentLoader*)_documentLoader { - return _private->loader; + return toPrivate(_private)->loader.get(); } - (id)_initWithDocumentLoader:(PassRefPtr<WebDocumentLoaderMac>)loader @@ -373,14 +351,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl self = [super init]; if (!self) return nil; - - _private = [[WebDataSourcePrivate alloc] init]; - - _private->loader = loader.leakRef(); + + ASSERT(loader); + _private = static_cast<void*>(new WebDataSourcePrivate(loader)); - LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(_private->loader->request().url())); + LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(toPrivate(_private)->loader->request().url())); - if ((_private->includedInWebKitStatistics = [[self webFrame] _isIncludedInWebKitStatistics])) + if ((toPrivate(_private)->includedInWebKitStatistics = [[self webFrame] _isIncludedInWebKitStatistics])) ++WebDataSourceCount; return self; @@ -397,25 +374,32 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (void)dealloc { - if (_private && _private->includedInWebKitStatistics) + if (WebCoreObjCScheduleDeallocateOnMainThread([WebDataSource class], self)) + return; + + if (toPrivate(_private) && toPrivate(_private)->includedInWebKitStatistics) --WebDataSourceCount; - [_private release]; + delete toPrivate(_private); [super dealloc]; } - (void)finalize { - if (_private && _private->includedInWebKitStatistics) + ASSERT_MAIN_THREAD(); + + if (toPrivate(_private) && toPrivate(_private)->includedInWebKitStatistics) --WebDataSourceCount; + delete toPrivate(_private); + [super finalize]; } - (NSData *)data { - RefPtr<SharedBuffer> mainResourceData = _private->loader->mainResourceData(); + RefPtr<SharedBuffer> mainResourceData = toPrivate(_private)->loader->mainResourceData(); if (!mainResourceData) return nil; return [mainResourceData->createNSData() autorelease]; @@ -423,12 +407,12 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (id <WebDocumentRepresentation>)representation { - return _private->representation; + return toPrivate(_private)->representation.get(); } - (WebFrame *)webFrame { - FrameLoader* frameLoader = _private->loader->frameLoader(); + FrameLoader* frameLoader = toPrivate(_private)->loader->frameLoader(); if (!frameLoader) return nil; return static_cast<WebFrameLoaderClient*>(frameLoader->client())->webFrame(); @@ -436,27 +420,27 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (NSURLRequest *)initialRequest { - return _private->loader->originalRequest().nsURLRequest(); + return toPrivate(_private)->loader->originalRequest().nsURLRequest(); } - (NSMutableURLRequest *)request { - FrameLoader* frameLoader = _private->loader->frameLoader(); + FrameLoader* frameLoader = toPrivate(_private)->loader->frameLoader(); if (!frameLoader || !frameLoader->frameHasLoaded()) return nil; // FIXME: this cast is dubious - return (NSMutableURLRequest *)_private->loader->request().nsURLRequest(); + return (NSMutableURLRequest *)toPrivate(_private)->loader->request().nsURLRequest(); } - (NSURLResponse *)response { - return _private->loader->response().nsURLResponse(); + return toPrivate(_private)->loader->response().nsURLResponse(); } - (NSString *)textEncodingName { - NSString *textEncodingName = _private->loader->overrideEncoding(); + NSString *textEncodingName = toPrivate(_private)->loader->overrideEncoding(); if (!textEncodingName) textEncodingName = [[self response] textEncodingName]; return textEncodingName; @@ -464,7 +448,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (BOOL)isLoading { - return _private->loader->isLoadingInAPISense(); + return toPrivate(_private)->loader->isLoadingInAPISense(); } // Returns nil or the page title. @@ -475,7 +459,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (NSURL *)unreachableURL { - const KURL& unreachableURL = _private->loader->unreachableURL(); + const KURL& unreachableURL = toPrivate(_private)->loader->unreachableURL(); if (unreachableURL.isEmpty()) return nil; return unreachableURL; @@ -484,7 +468,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (WebArchive *)webArchive { // it makes no sense to grab a WebArchive from an uncommitted document. - if (!_private->loader->isCommitted()) + if (!toPrivate(_private)->loader->isCommitted()) return nil; return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core([self webFrame]))] autorelease]; @@ -492,14 +476,14 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (WebResource *)mainResource { - RefPtr<ArchiveResource> coreResource = _private->loader->mainResource(); + RefPtr<ArchiveResource> coreResource = toPrivate(_private)->loader->mainResource(); return [[[WebResource alloc] _initWithCoreResource:coreResource.release()] autorelease]; } - (NSArray *)subresources { Vector<PassRefPtr<ArchiveResource> > coreSubresources; - _private->loader->getSubresources(coreSubresources); + toPrivate(_private)->loader->getSubresources(coreSubresources); NSMutableArray *subresources = [[NSMutableArray alloc] initWithCapacity:coreSubresources.size()]; for (unsigned i = 0; i < coreSubresources.size(); ++i) { @@ -515,14 +499,14 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (WebResource *)subresourceForURL:(NSURL *)URL { - RefPtr<ArchiveResource> subresource = _private->loader->subresource(URL); + RefPtr<ArchiveResource> subresource = toPrivate(_private)->loader->subresource(URL); return subresource ? [[[WebResource alloc] _initWithCoreResource:subresource.get()] autorelease] : nil; } - (void)addSubresource:(WebResource *)subresource { - _private->loader->addArchiveResource([subresource _coreResource]); + toPrivate(_private)->loader->addArchiveResource([subresource _coreResource]); } @end diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp index caf95058f..588dcf7aa 100644 --- a/Source/WebKit/qt/Api/qwebsettings.cpp +++ b/Source/WebKit/qt/Api/qwebsettings.cpp @@ -82,9 +82,7 @@ public: QString localStoragePath; QString offlineWebApplicationCachePath; qint64 offlineStorageDefaultQuota; -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) QWebSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy; -#endif void apply(); WebCore::Settings* settings; }; @@ -164,6 +162,10 @@ void QWebSettingsPrivate::apply() global->attributes.value(QWebSettings::WebGLEnabled)); settings->setWebGLEnabled(value); +#if ENABLE(CSS_SHADERS) + // For now, enable CSS shaders when WebGL is enabled. + settings->setCSSCustomFilterEnabled(value); +#endif #if USE(ACCELERATED_COMPOSITING) settings->setAcceleratedCompositingForCanvasEnabled(value); #endif @@ -365,7 +367,6 @@ QWebSettings* QWebSettings::globalSettings() \value DefaultFixedFontSize The default font size for fixed-pitch text. */ -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) /*! \enum QWebSettings::ThirdPartyCookiePolicy @@ -380,7 +381,6 @@ QWebSettings* QWebSettings::globalSettings() \since QtWebKit 2,3 */ -#endif /*! \enum QWebSettings::WebGraphic @@ -530,9 +530,7 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::SiteSpecificQuirksEnabled, true); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) d->thirdPartyCookiePolicy = AlwaysAllowThirdPartyCookies; -#endif } /*! @@ -869,7 +867,6 @@ void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheM qMax(0, totalCapacity)); } -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) /*! Sets the third-party cookie policy, the default is AlwaysAllowThirdPartyCookies. */ @@ -885,7 +882,6 @@ QWebSettings::ThirdPartyCookiePolicy QWebSettings::thirdPartyCookiePolicy() cons { return d->thirdPartyCookiePolicy; } -#endif /*! Sets the actual font family to \a family for the specified generic family, diff --git a/Source/WebKit/qt/Api/qwebsettings.h b/Source/WebKit/qt/Api/qwebsettings.h index 2e07356f2..835a72e24 100644 --- a/Source/WebKit/qt/Api/qwebsettings.h +++ b/Source/WebKit/qt/Api/qwebsettings.h @@ -97,13 +97,11 @@ public: DefaultFontSize, DefaultFixedFontSize }; -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) enum ThirdPartyCookiePolicy { AlwaysAllowThirdPartyCookies, AlwaysBlockThirdPartyCookies, AllowThirdPartyWithExistingCookies }; -#endif static QWebSettings *globalSettings(); @@ -156,10 +154,8 @@ public: static void enablePersistentStorage(const QString& path = QString()); -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) void setThirdPartyCookiePolicy(ThirdPartyCookiePolicy); QWebSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy() const; -#endif inline QWebSettingsPrivate* handle() const { return d; } diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index dabbee48e..d75294502 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,54 @@ +2012-07-22 Kent Tamura <tkent@chromium.org> + + Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively + https://bugs.webkit.org/show_bug.cgi?id=91941 + + Reviewed by Kentaro Hara. + + A flag name for an elmement should be ENABLE_*_ELEMENT. + + * WebCoreSupport/RenderThemeQStyle.cpp: + (WebCore): + * WebCoreSupport/RenderThemeQStyle.h: + +2012-07-19 No'am Rosenthal <noam.rosenthal@nokia.com> + + [Qt] Enable CSS shaders in Qt (software mode) + https://bugs.webkit.org/show_bug.cgi?id=85140 + + Reviewed by Simon Hausmann. + + Enable CSS Shaders in settings when WebGL is enabled. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + +2012-07-19 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Remove support for Qt versions before 4.8.0 + https://bugs.webkit.org/show_bug.cgi?id=91730 + + Reviewed by Kenneth Rohde Christiansen. + + Remove Qt version check #ifdefs for Qt versions before 4.8.0. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate): + (QWebSettings::QWebSettings): + (QWebSettings::thirdPartyCookiePolicy): + * Api/qwebsettings.h: + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * tests/qdeclarativewebview/tst_qdeclarativewebview.cpp: + (tst_QDeclarativeWebView): + (tst_QDeclarativeWebView::backgroundColor): + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::render): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage): + (tst_QWebPage::thirdPartyCookiePolicy): + 2012-07-17 Gabor Ballabas <gaborb@inf.u-szeged.hu> [Qt][V8] Remove the V8 related codepaths and configuration diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index d6fa62722..c02e66e66 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -984,13 +984,11 @@ void DumpRenderTreeSupportQt::setMinimumTimerInterval(QWebPage* page, double int corePage->settings()->setMinDOMTimerInterval(interval); } -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPage *page, const QUrl& url, const QUrl& firstPartyUrl) { Page* corePage = QWebPagePrivate::core(page); return thirdPartyCookiePolicyPermits(corePage->mainFrame()->loader()->networkingContext(), url, firstPartyUrl); } -#endif QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrame* frame, const QString& elementId) { diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index e0c868081..0184ee4da 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -211,9 +211,7 @@ public: static void setDefersLoading(QWebPage*, bool flag); static void goBack(QWebPage*); -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) static bool thirdPartyCookiePolicyAllows(QWebPage*, const QUrl&, const QUrl& firstPartyUrl); -#endif static QImage paintPagesWithBoundaries(QWebFrame*); }; diff --git a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp index 6c734710b..7cfdabfc2 100644 --- a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp +++ b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp @@ -47,7 +47,7 @@ #include "PaintInfo.h" #include "QWebPageClient.h" #include "RenderBox.h" -#if ENABLE(PROGRESS_TAG) +#if ENABLE(PROGRESS_ELEMENT) #include "RenderProgress.h" #endif #include "RenderSlider.h" @@ -70,7 +70,7 @@ #include <QStyleFactory> #include <QStyleOptionButton> #include <QStyleOptionFrameV2> -#if ENABLE(PROGRESS_TAG) +#if ENABLE(PROGRESS_ELEMENT) #include <QStyleOptionProgressBarV2> #endif #include <QStyleOptionSlider> @@ -492,7 +492,7 @@ bool RenderThemeQStyle::paintMenuListButton(RenderObject* o, const PaintInfo& i, return false; } -#if ENABLE(PROGRESS_TAG) +#if ENABLE(PROGRESS_ELEMENT) double RenderThemeQStyle::animationDurationForProgressBar(RenderProgress* renderProgress) const { if (renderProgress->position() >= 0) diff --git a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h index fa160366a..7e8c26e91 100644 --- a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h +++ b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h @@ -64,7 +64,7 @@ protected: virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const; -#if ENABLE(PROGRESS_TAG) +#if ENABLE(PROGRESS_ELEMENT) // Returns the duration of the animation for the progress bar. virtual double animationDurationForProgressBar(RenderProgress*) const; virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); diff --git a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp index b1722a6fb..3623c6a3f 100644 --- a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -40,9 +40,7 @@ private slots: void renderingEnabled(); void setHtml(); void settings(); -#if QT_VERSION >= 0x040704 void backgroundColor(); -#endif private: void checkNoErrors(const QDeclarativeComponent&); @@ -505,7 +503,6 @@ void tst_QDeclarativeWebView::settings() } } -#if QT_VERSION >= 0x040704 void tst_QDeclarativeWebView::backgroundColor() { // We test here the rendering of the background. @@ -533,7 +530,6 @@ void tst_QDeclarativeWebView::backgroundColor() wv->setProperty("backgroundColor", Qt::green); QCOMPARE(spyColorChanged.count(), 1); } -#endif void tst_QDeclarativeWebView::checkNoErrors(const QDeclarativeComponent& component) { diff --git a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp index fb47e4b61..9a208bc47 100644 --- a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp @@ -1062,11 +1062,7 @@ void tst_QWebElement::render() QPainter painter(&chunk); painter.fillRect(chunkRect, Qt::white); QRect chunkPaintRect(x, 0, chunkWidth, chunkHeight); -#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) tables[0].render(&painter, chunkPaintRect); -#else - tables[0].render(&painter); -#endif painter.end(); // The first chunk in this test is passing, but the others are failing diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index b6f0aeee3..13e7a9f17 100644 --- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -90,9 +90,7 @@ public slots: private slots: void initTestCase(); void cleanupTestCase(); -#if QT_VERSION >= 0x040800 void thirdPartyCookiePolicy(); -#endif void contextMenuCopy(); void contextMenuPopulatedOnce(); void acceptNavigationRequest(); @@ -3042,7 +3040,6 @@ void tst_QWebPage::navigatorCookieEnabled() QVERIFY(m_page->mainFrame()->evaluateJavaScript("navigator.cookieEnabled").toBool()); } -#if QT_VERSION >= 0x040800 void tst_QWebPage::thirdPartyCookiePolicy() { QWebSettings::globalSettings()->setThirdPartyCookiePolicy(QWebSettings::AlwaysBlockThirdPartyCookies); @@ -3081,7 +3078,6 @@ void tst_QWebPage::thirdPartyCookiePolicy() QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, QUrl("http://anotherexample.co.uk"), QUrl("http://example.co.uk"))); } -#endif #ifdef Q_OS_MAC void tst_QWebPage::macCopyUnicodeToClipboard() |
