Diff
Modified: trunk/Source/WebCore/ChangeLog (120134 => 120135)
--- trunk/Source/WebCore/ChangeLog 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/ChangeLog 2012-06-12 23:04:17 UTC (rev 120135)
@@ -1,3 +1,64 @@
+2012-06-12 Adrienne Walker <[email protected]>
+
+ [chromium] Paint scrollbars on WebKit thread and composite those textures
+ https://bugs.webkit.org/show_bug.cgi?id=88145
+
+ Reviewed by James Robinson.
+
+ Scrollbars were previously painted and uploaded on the compositor
+ thread. This isn't possible to do for many scrollbar themes. This
+ patch changes ScrollbarLayerChromium to paint the scrollbar into two
+ parts: the thumb, and everything else. These are uploaded into
+ textures and synced over to the CCScrollbarImpl where they are
+ composited and drawn.
+
+ Mac and overlay scrollbars are still not enabled to have compositor
+ thread-updated scrollbars.
+
+ As a bonus, fix LayerRendererChromium::drawTextureQuad to draw quads
+ that do not fill the entire layer bounds.
+
+ Tested by existing layout and unit tests by removing the condition
+ that these scrollbar layers are only created when the threaded proxy
+ exists.
+
+ * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
+ (WebCore::scrollbarLayerDidChange):
+ * platform/ScrollbarThemeComposite.cpp:
+ (WebCore::ScrollbarThemeComposite::thumbRect):
+ (WebCore):
+ * platform/ScrollbarThemeComposite.h:
+ (ScrollbarThemeComposite):
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::drawTextureQuad):
+ * platform/graphics/chromium/ScrollbarLayerChromium.cpp:
+ (WebCore::ScrollbarLayerChromium::ScrollbarLayerChromium):
+ (WebCore::ScrollbarLayerChromium::theme):
+ (WebCore):
+ (WebCore::ScrollbarLayerChromium::pushPropertiesTo):
+ (ScrollbarBackgroundPainter):
+ (WebCore::ScrollbarBackgroundPainter::create):
+ (WebCore::ScrollbarBackgroundPainter::paint):
+ (WebCore::ScrollbarBackgroundPainter::ScrollbarBackgroundPainter):
+ (ScrollbarThumbPainter):
+ (WebCore::ScrollbarThumbPainter::create):
+ (WebCore::ScrollbarThumbPainter::paint):
+ (WebCore::ScrollbarThumbPainter::ScrollbarThumbPainter):
+ (WebCore::ScrollbarLayerChromium::setLayerTreeHost):
+ (WebCore::ScrollbarLayerChromium::createTextureUpdaterIfNeeded):
+ (WebCore::ScrollbarLayerChromium::updatePart):
+ (WebCore::ScrollbarLayerChromium::update):
+ * platform/graphics/chromium/ScrollbarLayerChromium.h:
+ (WebCore):
+ (ScrollbarLayerChromium):
+ * platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
+ (WebCore::CCScrollbarLayerImpl::CCScrollbarLayerImpl):
+ (WebCore::CCScrollbarLayerImpl::appendQuads):
+ * platform/graphics/chromium/cc/CCScrollbarLayerImpl.h:
+ (WebCore::CCScrollbarLayerImpl::setBackgroundTextureId):
+ (WebCore::CCScrollbarLayerImpl::setThumbTextureId):
+ (CCScrollbarLayerImpl):
+
2012-06-12 Tony Chang <[email protected]>
Replaced items in a flexbox should be coerced to display:block
Modified: trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp (120134 => 120135)
--- trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -120,14 +120,13 @@
if (!scrollbarGraphicsLayer->contentsOpaque())
scrollbarGraphicsLayer->setContentsOpaque(isOpaqueRootScrollbar);
- // Only certain platforms support the way that scrollbars are currently
- // being painted on the impl thread. For example, Cocoa is not threadsafe.
- bool platformSupported = false;
-#if OS(LINUX)
- platformSupported = true;
+ // FIXME: Mac scrollbar themes are not thread-safe.
+ bool platformSupported = true;
+#if OS(DARWIN)
+ platformSupported = false;
#endif
- if (scrollbar->isCustomScrollbar() || !CCProxy::hasImplThread() || !platformSupported) {
+ if (!platformSupported || scrollbar->isOverlayScrollbar()) {
scrollbarGraphicsLayer->setContentsToMedia(0);
scrollbarGraphicsLayer->setDrawsContent(true);
return 0;
Modified: trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp (120134 => 120135)
--- trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -271,6 +271,20 @@
context->fillRect(cornerRect, Color::white, ColorSpaceDeviceRGB);
}
+IntRect ScrollbarThemeComposite::thumbRect(ScrollbarThemeClient* scrollbar)
+{
+ if (!hasThumb(scrollbar))
+ return IntRect();
+
+ IntRect track = trackRect(scrollbar);
+ IntRect startTrackRect;
+ IntRect thumbRect;
+ IntRect endTrackRect;
+ splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect);
+
+ return thumbRect;
+}
+
void ScrollbarThemeComposite::paintOverhangAreas(ScrollView*, GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
{
context->setFillColor(Color::white, ColorSpaceDeviceRGB);
Modified: trunk/Source/WebCore/platform/ScrollbarThemeComposite.h (120134 => 120135)
--- trunk/Source/WebCore/platform/ScrollbarThemeComposite.h 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/ScrollbarThemeComposite.h 2012-06-12 23:04:17 UTC (rev 120135)
@@ -32,27 +32,24 @@
class ScrollbarThemeComposite : public ScrollbarTheme {
public:
+ // Implement ScrollbarTheme interface
virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& damageRect);
-
virtual ScrollbarPart hitTest(ScrollbarThemeClient*, const PlatformMouseEvent&);
-
virtual void invalidatePart(ScrollbarThemeClient*, ScrollbarPart);
-
virtual int thumbPosition(ScrollbarThemeClient*);
virtual int thumbLength(ScrollbarThemeClient*);
virtual int trackPosition(ScrollbarThemeClient*);
virtual int trackLength(ScrollbarThemeClient*);
-
virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
-protected:
virtual bool hasButtons(ScrollbarThemeClient*) = 0;
virtual bool hasThumb(ScrollbarThemeClient*) = 0;
virtual IntRect backButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false) = 0;
virtual IntRect forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false) = 0;
virtual IntRect trackRect(ScrollbarThemeClient*, bool painting = false) = 0;
+ virtual IntRect thumbRect(ScrollbarThemeClient*);
virtual void splitTrack(ScrollbarThemeClient*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack);
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (120134 => 120135)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -1130,9 +1130,11 @@
if (!quad->premultipliedAlpha())
GLC(context(), context()->blendFunc(GraphicsContext3D::SRC_ALPHA, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
- const IntSize& bounds = quad->quadRect().size();
+ WebTransformationMatrix quadTransform = quad->quadTransform();
+ IntRect quadRect = quad->quadRect();
+ quadTransform.translate(quadRect.x() + quadRect.width() / 2.0, quadRect.y() + quadRect.height() / 2.0);
- drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(), binding.matrixLocation, binding.alphaLocation, -1);
+ drawTexturedQuad(quadTransform, quadRect.width(), quadRect.height(), quad->opacity(), sharedGeometryQuad(), binding.matrixLocation, binding.alphaLocation, -1);
if (!quad->premultipliedAlpha())
GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
Modified: trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp (120134 => 120135)
--- trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -28,8 +28,13 @@
#include "ScrollbarLayerChromium.h"
+#include "BitmapCanvasLayerTextureUpdater.h"
+#include "LayerPainterChromium.h"
#include "Scrollbar.h"
+#include "ScrollbarThemeComposite.h"
+#include "cc/CCLayerTreeHost.h"
#include "cc/CCScrollbarLayerImpl.h"
+#include "cc/CCTextureUpdater.h"
namespace WebCore {
@@ -46,6 +51,7 @@
ScrollbarLayerChromium::ScrollbarLayerChromium(Scrollbar* scrollbar, int scrollLayerId)
: m_scrollbar(scrollbar)
, m_scrollLayerId(scrollLayerId)
+ , m_textureFormat(GraphicsContext3D::INVALID_ENUM)
, m_scrollbarOverlayStyle(scrollbar->scrollbarOverlayStyle())
, m_isScrollableAreaActive(scrollbar->isScrollableAreaActive())
, m_isScrollViewScrollbar(scrollbar->isScrollViewScrollbar())
@@ -54,6 +60,12 @@
{
}
+ScrollbarThemeComposite* ScrollbarLayerChromium::theme() const
+{
+ // All Chromium scrollbars are ScrollbarThemeComposite-derived.
+ return static_cast<ScrollbarThemeComposite*>(m_scrollbar->theme());
+}
+
void ScrollbarLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
LayerChromium::pushPropertiesTo(layer);
@@ -62,6 +74,16 @@
scrollbarLayer->setScrollbarOverlayStyle(m_scrollbarOverlayStyle);
+ if (m_background && m_background->texture()->isReserved())
+ scrollbarLayer->setBackgroundTextureId(m_background->texture()->textureId());
+ else
+ scrollbarLayer->setBackgroundTextureId(0);
+
+ if (m_thumb && m_thumb->texture()->isReserved())
+ scrollbarLayer->setThumbTextureId(m_thumb->texture()->textureId());
+ else
+ scrollbarLayer->setThumbTextureId(0);
+
Vector<IntRect> tickmarks;
m_scrollbar->getTickmarks(tickmarks);
scrollbarLayer->setTickmarks(tickmarks);
@@ -79,5 +101,157 @@
scrollbarLayer->setEnabled(m_scrollbar->enabled());
}
+class ScrollbarBackgroundPainter : public LayerPainterChromium {
+ WTF_MAKE_NONCOPYABLE(ScrollbarBackgroundPainter);
+public:
+ static PassOwnPtr<ScrollbarBackgroundPainter> create(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+ {
+ return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, theme));
+ }
+
+ virtual void paint(GraphicsContext& context, const IntRect& contentRect)
+ {
+ // The following is a simplification of ScrollbarThemeComposite::paint.
+ m_theme->paintScrollbarBackground(&context, m_scrollbar);
+
+ if (m_theme->hasButtons(m_scrollbar)) {
+ IntRect backButtonStartPaintRect = m_theme->backButtonRect(m_scrollbar, BackButtonStartPart, true);
+ m_theme->paintButton(&context, m_scrollbar, backButtonStartPaintRect, BackButtonStartPart);
+
+ IntRect backButtonEndPaintRect = m_theme->backButtonRect(m_scrollbar, BackButtonEndPart, true);
+ m_theme->paintButton(&context, m_scrollbar, backButtonEndPaintRect, BackButtonEndPart);
+
+ IntRect forwardButtonStartPaintRect = m_theme->forwardButtonRect(m_scrollbar, ForwardButtonStartPart, true);
+ m_theme->paintButton(&context, m_scrollbar, forwardButtonStartPaintRect, ForwardButtonStartPart);
+
+ IntRect forwardButtonEndPaintRect = m_theme->forwardButtonRect(m_scrollbar, ForwardButtonEndPart, true);
+ m_theme->paintButton(&context, m_scrollbar, forwardButtonEndPaintRect, ForwardButtonEndPart);
+ }
+
+ IntRect trackPaintRect = m_theme->trackRect(m_scrollbar, true);
+ m_theme->paintTrackBackground(&context, m_scrollbar, trackPaintRect);
+
+ bool thumbPresent = m_theme->hasThumb(m_scrollbar);
+ if (thumbPresent) {
+ // FIXME: There's no "paint the whole track" part. Drawing both the
+ // BackTrackPart and the ForwardTrackPart in their splitTrack rects
+ // ends up leaving a distinctive line. Painting one part as the
+ // entire track appears to be identical to painting both and
+ // covering up the split between them with the thumb.
+ m_theme->paintTrackPiece(&context, m_scrollbar, trackPaintRect, BackTrackPart);
+ }
+
+ m_theme->paintTickmarks(&context, m_scrollbar, trackPaintRect);
+ }
+private:
+ ScrollbarBackgroundPainter(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+ : m_scrollbar(scrollbar)
+ , m_theme(theme)
+ {
+ }
+
+ ScrollbarThemeClient* m_scrollbar;
+ ScrollbarThemeComposite* m_theme;
+};
+
+class ScrollbarThumbPainter : public LayerPainterChromium {
+ WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter);
+public:
+ static PassOwnPtr<ScrollbarThumbPainter> create(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+ {
+ return adoptPtr(new ScrollbarThumbPainter(scrollbar, theme));
+ }
+
+ virtual void paint(GraphicsContext& context, const IntRect& contentRect)
+ {
+ context.clearRect(contentRect);
+
+ // Consider the thumb to be at the origin when painting.
+ IntRect thumbRect = IntRect(IntPoint(), m_theme->thumbRect(m_scrollbar).size());
+ m_theme->paintThumb(&context, m_scrollbar, thumbRect);
+ }
+
+private:
+ ScrollbarThumbPainter(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+ : m_scrollbar(scrollbar)
+ , m_theme(theme)
+ {
+ }
+
+ ScrollbarThemeClient* m_scrollbar;
+ ScrollbarThemeComposite* m_theme;
+};
+
+void ScrollbarLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
+{
+ if (!host || host != layerTreeHost()) {
+ m_backgroundUpdater.clear();
+ m_background.clear();
+ m_thumbUpdater.clear();
+ m_thumb.clear();
+ }
+
+ LayerChromium::setLayerTreeHost(host);
}
+
+void ScrollbarLayerChromium::createTextureUpdaterIfNeeded()
+{
+ bool useMapSubImage = layerTreeHost()->layerRendererCapabilities().usingMapSub;
+ m_textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat;
+
+ if (!m_backgroundUpdater)
+ m_backgroundUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), theme()), useMapSubImage);
+ if (!m_background)
+ m_background = m_backgroundUpdater->createTexture(layerTreeHost()->contentsTextureManager());
+
+ if (!m_thumbUpdater)
+ m_thumbUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarThumbPainter::create(m_scrollbar.get(), theme()), useMapSubImage);
+ if (!m_thumb)
+ m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTextureManager());
+}
+
+void ScrollbarLayerChromium::updatePart(LayerTextureUpdater* painter, LayerTextureUpdater::Texture* texture, const IntRect& rect, CCTextureUpdater& updater)
+{
+ bool textureValid = texture->texture()->isValid(rect.size(), m_textureFormat);
+ // Skip painting and uploading if there are no invalidations.
+ if (textureValid && m_updateRect.isEmpty()) {
+ texture->texture()->reserve(rect.size(), m_textureFormat);
+ return;
+ }
+
+ // ScrollbarLayerChromium doesn't support partial uploads, so any
+ // invalidation is treated a full layer invalidation.
+ if (layerTreeHost()->bufferedUpdates() && textureValid)
+ layerTreeHost()->deleteTextureAfterCommit(texture->texture()->steal());
+
+ if (!texture->texture()->reserve(rect.size(), m_textureFormat))
+ return;
+
+ // Paint and upload the entire part.
+ IntRect paintedOpaqueRect;
+ painter->prepareToUpdate(rect, rect.size(), false, 1, paintedOpaqueRect);
+ texture->prepareRect(rect);
+
+ IntRect destRect(IntPoint(), rect.size());
+ updater.appendUpdate(texture, rect, destRect);
+}
+
+void ScrollbarLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker*)
+{
+ if (contentBounds().isEmpty())
+ return;
+
+ createTextureUpdaterIfNeeded();
+
+ IntPoint scrollbarOrigin(m_scrollbar->x(), m_scrollbar->y());
+ IntRect contentRect(scrollbarOrigin, contentBounds());
+ updatePart(m_backgroundUpdater.get(), m_background.get(), contentRect, updater);
+
+ // Consider the thumb to be at the origin when painting.
+ IntRect thumbRect = IntRect(IntPoint(), theme()->thumbRect(m_scrollbar.get()).size());
+ if (!thumbRect.isEmpty())
+ updatePart(m_thumbUpdater.get(), m_thumb.get(), thumbRect, updater);
+}
+
+}
#endif // USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h (120134 => 120135)
--- trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h 2012-06-12 23:04:17 UTC (rev 120135)
@@ -29,18 +29,24 @@
#if USE(ACCELERATED_COMPOSITING)
#include "LayerChromium.h"
+#include "LayerTextureUpdater.h"
#include "ScrollTypes.h"
namespace WebCore {
class Scrollbar;
+class ScrollbarThemeComposite;
+class CCTextureUpdater;
class ScrollbarLayerChromium : public LayerChromium {
public:
virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
static PassRefPtr<ScrollbarLayerChromium> create(Scrollbar*, int scrollLayerId);
- virtual void pushPropertiesTo(CCLayerImpl*);
+ // LayerChromium interface
+ virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
+ virtual void setLayerTreeHost(CCLayerTreeHost*) OVERRIDE;
+ virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
int scrollLayerId() const { return m_scrollLayerId; }
void setScrollLayerId(int id) { m_scrollLayerId = id; }
@@ -51,9 +57,22 @@
ScrollbarLayerChromium(Scrollbar*, int scrollLayerId);
private:
+ ScrollbarThemeComposite* theme() const;
+ void updatePart(LayerTextureUpdater*, LayerTextureUpdater::Texture*, const IntRect&, CCTextureUpdater&);
+ void createTextureUpdaterIfNeeded();
+
RefPtr<Scrollbar> m_scrollbar;
int m_scrollLayerId;
+ GC3Denum m_textureFormat;
+
+ RefPtr<LayerTextureUpdater> m_backgroundUpdater;
+ RefPtr<LayerTextureUpdater> m_thumbUpdater;
+
+ // All the parts of the scrollbar except the thumb
+ OwnPtr<LayerTextureUpdater::Texture> m_background;
+ OwnPtr<LayerTextureUpdater::Texture> m_thumb;
+
ScrollbarOverlayStyle m_scrollbarOverlayStyle;
bool m_isScrollableAreaActive;
bool m_isScrollViewScrollbar;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp (120134 => 120135)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -29,12 +29,13 @@
#include "CCScrollbarLayerImpl.h"
-#include "CCTileDrawQuad.h"
#include "LayerRendererChromium.h"
#include "ManagedTexture.h"
#include "PlatformCanvas.h"
#include "ScrollbarTheme.h"
+#include "ScrollbarThemeComposite.h"
#include "cc/CCQuadCuller.h"
+#include "cc/CCTextureDrawQuad.h"
namespace WebCore {
@@ -47,74 +48,32 @@
: CCLayerImpl(id)
, m_scrollLayer(0)
, m_scrollbar(this)
+ , m_backgroundTextureId(0)
+ , m_thumbTextureId(0)
{
}
-void CCScrollbarLayerImpl::willDraw(CCRenderer* layerRenderer, CCGraphicsContext* context)
+void CCScrollbarLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
{
- CCLayerImpl::willDraw(layerRenderer, context);
-
- if (bounds().isEmpty() || contentBounds().isEmpty())
+ ScrollbarThemeComposite* theme = static_cast<ScrollbarThemeComposite*>(ScrollbarTheme::theme());
+ if (!theme)
return;
- if (!m_texture)
- m_texture = ManagedTexture::create(layerRenderer->implTextureManager());
+ bool premultipledAlpha = false;
+ FloatRect uvRect(0, 0, 1, 1);
+ bool flipped = false;
- // The context could have been lost since the last frame and the old texture
- // manager may no longer be valid.
- m_texture->setTextureManager(layerRenderer->implTextureManager());
-
- IntSize textureSize = contentBounds();
- if (!m_texture->reserve(textureSize, GraphicsContext3D::RGBA))
+ IntRect thumbRect = theme->thumbRect(&m_scrollbar);
+ thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y());
+ if (m_thumbTextureId && theme->hasThumb(&m_scrollbar) && !thumbRect.isEmpty())
+ quadList.append(CCTextureDrawQuad::create(sharedQuadState, thumbRect, m_thumbTextureId, premultipledAlpha, uvRect, flipped));
+ if (!m_backgroundTextureId)
return;
- PlatformCanvas canvas;
- canvas.resize(textureSize);
- {
- PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::GrayscaleText);
- paint(painter.context());
- }
-
- {
- PlatformCanvas::AutoLocker locker(&canvas);
- m_texture->bindTexture(context, layerRenderer->implTextureAllocator());
-
- // FIXME: Skia uses BGRA actually, we correct that with the swizzle pixel shader.
- GraphicsContext3D* context3d = context->context3D();
- if (!context3d) {
- // FIXME: Implement this path for software compositing.
- return;
- }
-
- GLC(context3d, context3d->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, m_texture->format(), canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
- }
+ IntRect backgroundRect(IntPoint(), contentBounds());
+ quadList.append(CCTextureDrawQuad::create(sharedQuadState, backgroundRect, m_backgroundTextureId, premultipledAlpha, uvRect, flipped));
}
-void CCScrollbarLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
-{
- if (!m_texture->isReserved())
- return;
-
- IntRect quadRect(IntPoint(), bounds());
- quadList.append(CCTileDrawQuad::create(sharedQuadState, quadRect, quadRect, m_texture->textureId(), IntPoint(), m_texture->size(), GraphicsContext3D::NEAREST, true, true, true, true, true));
-}
-
-void CCScrollbarLayerImpl::didDraw()
-{
- CCLayerImpl::didDraw();
-
- m_texture->unreserve();
-}
-
-void CCScrollbarLayerImpl::paint(GraphicsContext* context)
-{
- ScrollbarTheme* theme = ScrollbarTheme::theme(); // FIXME: should make impl-side clone if needed
-
- context->clearRect(IntRect(IntPoint(), contentBounds()));
- theme->paint(&m_scrollbar, context, IntRect(IntPoint(), contentBounds()));
-}
-
-
int CCScrollbarLayerImpl::CCScrollbar::x() const
{
return frameRect().x();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h (120134 => 120135)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h 2012-06-12 23:04:17 UTC (rev 120135)
@@ -55,22 +55,19 @@
void setEnabled(bool enabled) { m_enabled = enabled; }
+ void setBackgroundTextureId(unsigned id) { m_backgroundTextureId = id; }
+ void setThumbTextureId(unsigned id) { m_thumbTextureId = id; }
CCLayerImpl* scrollLayer() const { return m_scrollLayer; }
void setScrollLayer(CCLayerImpl* scrollLayer) { m_scrollLayer = scrollLayer; }
- virtual void willDraw(CCRenderer*, CCGraphicsContext*) OVERRIDE;
virtual void appendQuads(CCQuadCuller&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
- virtual void didDraw() OVERRIDE;
protected:
explicit CCScrollbarLayerImpl(int id);
- virtual void paint(GraphicsContext*);
-
private:
CCLayerImpl* m_scrollLayer;
- OwnPtr<ManagedTexture> m_texture;
// nested class only to avoid namespace problem
class CCScrollbar : public ScrollbarThemeClient {
@@ -128,6 +125,9 @@
};
CCScrollbar m_scrollbar;
+ unsigned m_backgroundTextureId;
+ unsigned m_thumbTextureId;
+
ScrollbarOverlayStyle m_scrollbarOverlayStyle;
Vector<IntRect> m_tickmarks;
bool m_isScrollableAreaActive;
Modified: trunk/Source/WebKit/chromium/ChangeLog (120134 => 120135)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-12 23:04:17 UTC (rev 120135)
@@ -1,3 +1,16 @@
+2012-06-12 Adrienne Walker <[email protected]>
+
+ [chromium] Paint scrollbars on WebKit thread and composite those textures
+ https://bugs.webkit.org/show_bug.cgi?id=88145
+
+ Reviewed by James Robinson.
+
+ Remove scrollbarLayerLostContext test that no longer makes sense. The
+ compositor won't draw at all after a lost context if it has no
+ contents.
+
+ * tests/CCLayerTreeHostImplTest.cpp:
+
2012-06-12 Joshua Bell <[email protected]>
IndexedDB: ObjectStore/Index shouldn't hold reference to backing store
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (120134 => 120135)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-06-12 22:52:31 UTC (rev 120134)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-06-12 23:04:17 UTC (rev 120135)
@@ -1584,26 +1584,6 @@
ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { }
};
-TEST_F(CCLayerTreeHostImplTest, scrollbarLayerLostContext)
-{
- m_hostImpl->setRootLayer(ScrollbarLayerFakePaint::create(0));
- ScrollbarLayerFakePaint* scrollbar = static_cast<ScrollbarLayerFakePaint*>(m_hostImpl->rootLayer());
- scrollbar->setBounds(IntSize(1, 1));
- scrollbar->setContentBounds(IntSize(1, 1));
- scrollbar->setDrawsContent(true);
-
- for (int i = 0; i < 2; ++i) {
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
- ASSERT(frame.renderPasses.size() == 1);
- CCRenderPass* renderPass = frame.renderPasses[0].get();
- // Scrollbar layer should always generate quads, even after lost context
- EXPECT_GT(renderPass->quadList().size(), 0u);
- m_hostImpl->didDrawAllLayers(frame);
- m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader);
- }
-}
-
// Fake WebGraphicsContext3D that will cause a failure if trying to use a
// resource that wasn't created by it (resources created by
// FakeWebGraphicsContext3D have an id of 1).