[chromium] Stop relying on implicit WebFoo <-> WebCore conversion operators in compositor
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Aug 2012 01:39:31 +0000 (01:39 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Aug 2012 01:39:31 +0000 (01:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93169

Reviewed by Adrienne Walker.

This removes the compositor's reliance on implicit conversion operators from Web* types to WebKit-internal
types, specifically WebRect <-> WebCore::IntRect and WebString <-> WTF::String.

* platform/graphics/chromium/CanvasLayerTextureUpdater.cpp:
(WebCore::CanvasLayerTextureUpdater::paintContents):
* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::getFramebufferPixels):
* platform/graphics/chromium/ScrollbarLayerChromium.cpp:
(WebCore::ScrollbarLayerChromium::setTexturePriorities):
(WebCore::ScrollbarLayerChromium::update):
* platform/graphics/chromium/cc/CCFontAtlas.cpp:
(WebCore::CCFontAtlas::drawOneLineOfTextInternal):
* platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
(WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounter):
(WebCore::CCHeadsUpDisplayLayerImpl::drawDebugRects):
* platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
(WebCore::toUVRect):
(WebCore::CCScrollbarLayerImpl::appendQuads):
(WebCore::CCScrollbarLayerImpl::CCScrollbar::size):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124683 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp
Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp

index 2a9a54e..a9c4cf0 100644 (file)
@@ -1,3 +1,32 @@
+2012-08-03  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Stop relying on implicit WebFoo <-> WebCore conversion operators in compositor
+        https://bugs.webkit.org/show_bug.cgi?id=93169
+
+        Reviewed by Adrienne Walker.
+
+        This removes the compositor's reliance on implicit conversion operators from Web* types to WebKit-internal
+        types, specifically WebRect <-> WebCore::IntRect and WebString <-> WTF::String.
+
+        * platform/graphics/chromium/CanvasLayerTextureUpdater.cpp:
+        (WebCore::CanvasLayerTextureUpdater::paintContents):
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::getFramebufferPixels):
+        * platform/graphics/chromium/ScrollbarLayerChromium.cpp:
+        (WebCore::ScrollbarLayerChromium::setTexturePriorities):
+        (WebCore::ScrollbarLayerChromium::update):
+        * platform/graphics/chromium/cc/CCFontAtlas.cpp:
+        (WebCore::CCFontAtlas::drawOneLineOfTextInternal):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
+        (WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounter):
+        (WebCore::CCHeadsUpDisplayLayerImpl::drawDebugRects):
+        * platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
+        (WebCore::toUVRect):
+        (WebCore::CCScrollbarLayerImpl::appendQuads):
+        (WebCore::CCScrollbarLayerImpl::CCScrollbar::size):
+
 2012-08-03  Michael Nordman  <michaeln@google.com>
 
         [Chromium] Cross-thread-copy a couple more recently added ResourceResponse data members, apparently
index 3f9ee36..b5c651c 100644 (file)
@@ -70,8 +70,9 @@ void CanvasLayerTextureUpdater::paintContents(SkCanvas* canvas, const IntRect& c
     SkPaint paint;
     paint.setAntiAlias(false);
     paint.setXfermodeMode(SkXfermode::kClear_Mode);
-    canvas->drawRect(layerRect, paint);
-    canvas->clipRect(layerRect);
+    SkRect layerSkRect = SkRect::MakeXYWH(layerRect.x(), layerRect.y(), layerRect.width(), layerRect.height());
+    canvas->drawRect(layerSkRect, paint);
+    canvas->clipRect(layerSkRect);
 
     FloatRect opaqueLayerRect;
     double paintBeginTime = monotonicallyIncreasingTime();
index 9cd1e75..a0e857e 100644 (file)
@@ -117,7 +117,7 @@ void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(WebGraphic
     canvas->translate(0.0, texture->size().height());
     canvas->scale(1.0, -1.0);
     // Only the region corresponding to destRect on the texture must be updated.
-    canvas->clipRect(SkRect(destRect));
+    canvas->clipRect(SkRect::MakeXYWH(destRect.x(), destRect.y(), destRect.width(), destRect.height()));
     // Translate the origin of contentRect to that of destRect.
     // Note that destRect is defined relative to sourceRect.
     canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(),
index 1eccf3e..0296b77 100644 (file)
@@ -1309,8 +1309,8 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re
 
     bool doWorkaround = needsIOSurfaceReadbackWorkaround();
 
-    Platform3DObject temporaryTexture = NullPlatform3DObject;
-    Platform3DObject temporaryFBO = NullPlatform3DObject;
+    Platform3DObject temporaryTexture = 0;
+    Platform3DObject temporaryFBO = 0;
 
     if (doWorkaround) {
         // On Mac OS X, calling glReadPixels against an FBO whose color attachment is an
index 5f73ebe..652d744 100644 (file)
@@ -94,7 +94,8 @@ public:
     {
         WebKit::WebCanvas* canvas = skCanvas;
         // The following is a simplification of ScrollbarThemeComposite::paint.
-        m_painter.paintScrollbarBackground(canvas, m_scrollbar, contentRect);
+        WebKit::WebRect contentWebRect(contentRect.x(), contentRect.y(), contentRect.width(), contentRect.height());
+        m_painter.paintScrollbarBackground(canvas, m_scrollbar, contentWebRect);
 
         if (m_geometry.hasButtons(m_scrollbar)) {
             WebRect backButtonStartPaintRect = m_geometry.backButtonStartRect(m_scrollbar);
@@ -246,8 +247,8 @@ void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&)
         m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(drawsToRoot));
     }
     if (m_thumb) {
-        IntSize thumbSize = IntRect(m_geometry.thumbRect(m_scrollbar.get())).size();
-        m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
+        WebKit::WebRect thumbRect = m_geometry.thumbRect(m_scrollbar.get());
+        m_thumb->texture()->setDimensions(IntSize(thumbRect.width, thumbRect.height), m_textureFormat);
         m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(drawsToRoot));
     }
 }
@@ -259,16 +260,17 @@ void ScrollbarLayerChromium::update(CCTextureUpdater& updater, const CCOcclusion
 
     createTextureUpdaterIfNeeded();
 
-    IntPoint scrollbarOrigin(m_scrollbar->location());
+    IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().y);
     IntRect contentRect(scrollbarOrigin, contentBounds());
     updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, updater, stats);
     if (m_foreTrack && m_foreTrackUpdater)
         updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, updater, stats);
 
     // Consider the thumb to be at the origin when painting.
-    IntRect thumbRect = IntRect(IntPoint(), IntRect(m_geometry.thumbRect(m_scrollbar.get())).size());
-    if (!thumbRect.isEmpty())
-        updatePart(m_thumbUpdater.get(), m_thumb.get(), thumbRect, updater, stats);
+    WebKit::WebRect thumbRect = m_geometry.thumbRect(m_scrollbar.get());
+    IntRect originThumbRect = IntRect(0, 0, thumbRect.width, thumbRect.height);
+    if (!originThumbRect.isEmpty())
+        updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, updater, stats);
 }
 
 }
index f941454..65cf434 100644 (file)
@@ -71,7 +71,7 @@ void CCFontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const String& text
         // If the ASCII code is out of bounds, then index 0 is used, which is just a plain rectangle glyph.
         int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0;
         IntRect glyphBounds = m_asciiToRectTable[asciiIndex];
-        SkIRect source = glyphBounds;
+        SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), glyphBounds.width(), glyphBounds.height());
         canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()));
         position.setX(position.x() + glyphBounds.width());
     }
index cfe8910..dd321b1 100644 (file)
@@ -187,7 +187,7 @@ void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCoun
             p = 1;
 
         // Plot this data point.
-        IntPoint cur(graphLeft + x, 1 + top + p*h);
+        SkPoint cur = SkPoint::Make(graphLeft + x, 1 + top + p*h);
         if (path.isEmpty())
             path.moveTo(cur);
         else
@@ -257,15 +257,16 @@ void CCHeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, CCDebugRectHist
             break;
         }
 
-        SkRect rect = debugRects[i].rect;
+        const FloatRect& rect = debugRects[i].rect;
+        SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
         SkPaint paint;
         paint.setColor(fillColor);
-        canvas->drawRect(rect, paint);
+        canvas->drawRect(skRect, paint);
 
         paint.setColor(strokeColor);
         paint.setStyle(SkPaint::kStroke_Style);
         paint.setStrokeWidth(2);
-        canvas->drawRect(rect, paint);
+        canvas->drawRect(skRect, paint);
     }
 }
 
index 31abb1d..58018aa 100644 (file)
@@ -80,10 +80,10 @@ void CCScrollbarLayerImpl::setScrollbarData(const WebScrollbar* scrollbar, WebKi
     scrollbar->getTickmarks(m_tickmarks);
 }
 
-static FloatRect toUVRect(const WebRect& r, const WebRect& bounds)
+static FloatRect toUVRect(const WebRect& r, const IntRect& bounds)
 {
-    return FloatRect(static_cast<float>(r.x) / bounds.width, static_cast<float>(r.y) / bounds.height,
-                     static_cast<float>(r.width) / bounds.width, static_cast<float>(r.height) / bounds.height);
+    return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float>(r.y) / bounds.height(),
+                     static_cast<float>(r.width) / bounds.width(), static_cast<float>(r.height) / bounds.height());
 }
 
 void CCScrollbarLayerImpl::scrollbarGeometry(WebRect& thumbRect, WebRect& backTrackRect, WebRect& foreTrackRect)
@@ -104,7 +104,7 @@ void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadS
     scrollbarGeometry(thumbRect, backTrackRect, foreTrackRect);
 
     if (m_thumbResourceId && !thumbRect.isEmpty()) {
-        OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, IntRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvRect, flipped);
+        OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, IntRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height), m_thumbResourceId, premultipledAlpha, uvRect, flipped);
         quad->setNeedsBlending();
         quadList.append(quad.release());
     }
@@ -114,7 +114,7 @@ void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadS
 
     // We only paint the track in two parts if we were given a texture for the forward track part.
     if (m_foreTrackResourceId && !foreTrackRect.isEmpty())
-        quadList.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped));
+        quadList.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreTrackRect.x, foreTrackRect.y, foreTrackRect.width, foreTrackRect.height), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped));
 
     // Order matters here: since the back track texture is being drawn to the entire contents rect, we must append it after the thumb and
     // fore track quads. The back track texture contains (and displays) the buttons.
@@ -146,7 +146,7 @@ WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const
 
 WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const
 {
-    return m_owner->contentBounds();
+    return WebKit::WebSize(m_owner->contentBounds().width(), m_owner->contentBounds().height());
 }
 
 bool CCScrollbarLayerImpl::CCScrollbar::enabled() const