Diff
Modified: trunk/Source/WebCore/ChangeLog (89646 => 89647)
--- trunk/Source/WebCore/ChangeLog 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/ChangeLog 2011-06-24 01:17:38 UTC (rev 89647)
@@ -1,3 +1,61 @@
+2011-05-25 James Robinson <[email protected]>
+
+ Reviewed by Kenneth Russell.
+
+ [chromium] Fix ownership of PlatformImage for ImageLayerChromiums
+ https://bugs.webkit.org/show_bug.cgi?id=61099
+
+ For a composited image, both the ImageLayerChromium and its associated LayerTilerChromium need access to a
+ PlatformImage - the ImageLayerChromium has to update the PlatformImage's contents and the LayerTilerChromium has
+ to upload pixels from it. This patch makes the ImageLayerTextureUpdater have exclusive ownership of the
+ PlatformImage and moves ownership of the LayerTextureUpdater from the LayerTilerChromium to the owner of the
+ tiler. The updater is passed in as a parameter to the relevant tiler calls.
+
+ Patch also fixes a number of minor style issues (missing explicit keyword on constructor, etc).
+
+ Refactor only, no new tests.
+
+ * platform/graphics/chromium/ContentLayerChromium.cpp:
+ (WebCore::ContentLayerPainter::create):
+ (WebCore::ContentLayerPainter::ContentLayerPainter):
+ (WebCore::ContentLayerChromium::paintContentsIfDirty):
+ (WebCore::ContentLayerChromium::createTextureUpdaterIfNeeded):
+ (WebCore::ContentLayerChromium::draw):
+ (WebCore::ContentLayerChromium::createTilerIfNeeded):
+ (WebCore::ContentLayerChromium::updateCompositorResources):
+ * platform/graphics/chromium/ContentLayerChromium.h:
+ * platform/graphics/chromium/ImageLayerChromium.cpp:
+ (WebCore::ImageLayerTextureUpdater::create):
+ (WebCore::ImageLayerTextureUpdater::updateFromImage):
+ (WebCore::ImageLayerTextureUpdater::imageSize):
+ (WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater):
+ (WebCore::ImageLayerChromium::~ImageLayerChromium):
+ (WebCore::ImageLayerChromium::paintContentsIfDirty):
+ (WebCore::ImageLayerChromium::updateCompositorResources):
+ (WebCore::ImageLayerChromium::setLayerRenderer):
+ (WebCore::ImageLayerChromium::createTextureUpdaterIfNeeded):
+ (WebCore::ImageLayerChromium::layerBounds):
+ * platform/graphics/chromium/ImageLayerChromium.h:
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::LayerRendererChromium):
+ (WebCore::LayerRendererChromium::updateRootLayerContents):
+ (WebCore::LayerRendererChromium::drawRootLayer):
+ (WebCore::LayerRendererChromium::updateLayers):
+ * platform/graphics/chromium/LayerRendererChromium.h:
+ * platform/graphics/chromium/LayerTextureUpdater.h:
+ (WebCore::LayerTextureUpdater::LayerTextureUpdater):
+ * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
+ (WebCore::LayerTextureUpdaterBitmap::create):
+ (WebCore::LayerTextureUpdaterSkPicture::create):
+ * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
+ * platform/graphics/chromium/LayerTilerChromium.cpp:
+ (WebCore::LayerTilerChromium::create):
+ (WebCore::LayerTilerChromium::LayerTilerChromium):
+ (WebCore::LayerTilerChromium::prepareToUpdate):
+ (WebCore::LayerTilerChromium::updateRect):
+ (WebCore::LayerTilerChromium::draw):
+ * platform/graphics/chromium/LayerTilerChromium.h:
+
2011-06-23 Adrienne Walker <[email protected]>
Unreviewed, rolling out r89632 and r89640.
Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp 2011-06-24 01:17:38 UTC (rev 89647)
@@ -57,10 +57,11 @@
namespace WebCore {
class ContentLayerPainter : public LayerPainterChromium {
+ WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
public:
- explicit ContentLayerPainter(GraphicsLayerChromium* owner)
- : m_owner(owner)
+ static PassOwnPtr<ContentLayerPainter> create(GraphicsLayerChromium* owner)
{
+ return adoptPtr(new ContentLayerPainter(owner));
}
virtual void paint(GraphicsContext& context, const IntRect& contentRect)
@@ -75,6 +76,11 @@
PlatformBridge::histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
}
private:
+ explicit ContentLayerPainter(GraphicsLayerChromium* owner)
+ : m_owner(owner)
+ {
+ }
+
GraphicsLayerChromium* m_owner;
};
@@ -112,12 +118,13 @@
if (!drawsContent())
return;
- m_tiler->prepareToUpdate(layerRect);
+ m_tiler->prepareToUpdate(layerRect, m_textureUpdater.get());
m_dirtyRect = FloatRect();
}
void ContentLayerChromium::cleanupResources()
{
+ m_textureUpdater.clear();
m_tiler.clear();
LayerChromium::cleanupResources();
}
@@ -128,14 +135,17 @@
createTilerIfNeeded();
}
-PassOwnPtr<LayerTextureUpdater> ContentLayerChromium::createTextureUpdater()
+void ContentLayerChromium::createTextureUpdaterIfNeeded()
{
- OwnPtr<LayerPainterChromium> painter = adoptPtr(new ContentLayerPainter(m_owner));
+ if (m_textureUpdater)
+ return;
#if USE(SKIA)
- if (layerRenderer()->accelerateDrawing())
- return adoptPtr(new LayerTextureUpdaterSkPicture(layerRendererContext(), painter.release(), layerRenderer()->skiaContext()));
+ if (layerRenderer()->accelerateDrawing()) {
+ m_textureUpdater = LayerTextureUpdaterSkPicture::create(layerRendererContext(), ContentLayerPainter::create(m_owner), layerRenderer()->skiaContext());
+ return;
+ }
#endif
- return adoptPtr(new LayerTextureUpdaterBitmap(layerRendererContext(), painter.release(), layerRenderer()->contextSupportsMapSub()));
+ m_textureUpdater = LayerTextureUpdaterBitmap::create(layerRendererContext(), ContentLayerPainter::create(m_owner), layerRenderer()->contextSupportsMapSub());
}
TransformationMatrix ContentLayerChromium::tilingTransform()
@@ -216,7 +226,7 @@
const TransformationMatrix transform = tilingTransform();
IntRect layerRect = visibleLayerRect(targetSurfaceRect);
if (!layerRect.isEmpty())
- m_tiler->draw(layerRect, transform, ccLayerImpl()->drawOpacity());
+ m_tiler->draw(layerRect, transform, ccLayerImpl()->drawOpacity(), m_textureUpdater.get());
}
bool ContentLayerChromium::drawsContent() const
@@ -238,16 +248,17 @@
if (m_tiler)
return;
+ createTextureUpdaterIfNeeded();
+
m_tiler = LayerTilerChromium::create(
layerRenderer(),
- createTextureUpdater(),
IntSize(defaultTileSize, defaultTileSize),
LayerTilerChromium::HasBorderTexels);
}
void ContentLayerChromium::updateCompositorResources()
{
- m_tiler->updateRect();
+ m_tiler->updateRect(m_textureUpdater.get());
}
void ContentLayerChromium::setTilingOption(TilingOption option)
Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -69,8 +69,6 @@
virtual void cleanupResources();
virtual void setLayerRenderer(LayerRendererChromium*);
- virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater();
-
virtual IntRect layerBounds() const;
virtual TransformationMatrix tilingTransform();
@@ -81,8 +79,10 @@
void updateLayerSize(const IntSize&);
void createTilerIfNeeded();
+ virtual void createTextureUpdaterIfNeeded();
void setTilingOption(TilingOption);
+ OwnPtr<LayerTextureUpdater> m_textureUpdater;
OwnPtr<LayerTilerChromium> m_tiler;
TilingOption m_tilingOption;
};
Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp 2011-06-24 01:17:38 UTC (rev 89647)
@@ -45,13 +45,13 @@
namespace WebCore {
class ImageLayerTextureUpdater : public LayerTextureUpdater {
+ WTF_MAKE_NONCOPYABLE(ImageLayerTextureUpdater);
public:
- ImageLayerTextureUpdater(GraphicsContext3D* context, const PlatformImage& image, bool useMapTexSubImage)
- : LayerTextureUpdater(context)
- , m_image(image)
- , m_texSubImage(useMapTexSubImage)
+ static PassOwnPtr<ImageLayerTextureUpdater> create(GraphicsContext3D* context, bool useMapTexSubImage)
{
+ return adoptPtr(new ImageLayerTextureUpdater(context, useMapTexSubImage));
}
+
virtual ~ImageLayerTextureUpdater() { }
virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
@@ -83,14 +83,29 @@
m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, texture->format(), context());
}
+ void updateFromImage(NativeImagePtr nativeImage)
+ {
+ m_image.updateFromImage(nativeImage);
+ }
+
+ IntSize imageSize() const
+ {
+ return m_image.size();
+ }
+
private:
+ ImageLayerTextureUpdater(GraphicsContext3D* context, bool useMapTexSubImage)
+ : LayerTextureUpdater(context)
+ , m_texSubImage(useMapTexSubImage)
+ {
+ }
+
IntRect imageRect() const
{
return IntRect(IntPoint::zero(), m_image.size());
}
- // FIXME: ImageLayerTextureUpdater should rather own a PlatformImage rather than keeping a reference.
- const PlatformImage& m_image;
+ PlatformImage m_image;
LayerTextureSubImage m_texSubImage;
};
@@ -106,6 +121,10 @@
{
}
+ImageLayerChromium::~ImageLayerChromium()
+{
+}
+
void ImageLayerChromium::setContents(Image* contents)
{
// setContents() currently gets called whenever there is any
@@ -126,30 +145,43 @@
ASSERT(layerRenderer());
if (!m_dirtyRect.isEmpty()) {
- m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame());
- updateLayerSize(m_decodedImage.size());
- IntRect paintRect(IntPoint(0, 0), m_decodedImage.size());
+ // FIXME: This downcast is bad. The fix is to make ImageLayerChromium not derive from ContentLayerChromium.
+ ImageLayerTextureUpdater* imageTextureUpdater = static_cast<ImageLayerTextureUpdater*>(m_textureUpdater.get());
+ imageTextureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
+ updateLayerSize(imageTextureUpdater->imageSize());
+ IntRect paintRect(IntPoint(0, 0), imageTextureUpdater->imageSize());
if (!m_dirtyRect.isEmpty()) {
m_tiler->invalidateRect(paintRect);
m_dirtyRect = IntRect();
}
- m_tiler->prepareToUpdate(paintRect);
+ m_tiler->prepareToUpdate(paintRect, m_textureUpdater.get());
}
}
void ImageLayerChromium::updateCompositorResources()
{
- m_tiler->updateRect();
+ m_tiler->updateRect(m_textureUpdater.get());
}
-PassOwnPtr<LayerTextureUpdater> ImageLayerChromium::createTextureUpdater()
+void ImageLayerChromium::setLayerRenderer(LayerRendererChromium* newLayerRenderer)
{
- return adoptPtr(new ImageLayerTextureUpdater(layerRendererContext(), m_decodedImage, layerRenderer()->contextSupportsMapSub()));
+ if (newLayerRenderer != layerRenderer())
+ m_textureUpdater.clear();
+ ContentLayerChromium::setLayerRenderer(newLayerRenderer);
}
+void ImageLayerChromium::createTextureUpdaterIfNeeded()
+{
+ if (!m_textureUpdater)
+ m_textureUpdater = ImageLayerTextureUpdater::create(layerRendererContext(), layerRenderer()->contextSupportsMapSub());
+}
+
IntRect ImageLayerChromium::layerBounds() const
{
- return IntRect(IntPoint(0, 0), m_decodedImage.size());
+ if (!m_textureUpdater)
+ return IntRect();
+ ImageLayerTextureUpdater* imageTextureUpdater = static_cast<ImageLayerTextureUpdater*>(m_textureUpdater.get());
+ return IntRect(IntPoint(), imageTextureUpdater->imageSize());
}
TransformationMatrix ImageLayerChromium::tilingTransform()
Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -49,6 +49,7 @@
class ImageLayerChromium : public ContentLayerChromium {
public:
static PassRefPtr<ImageLayerChromium> create(GraphicsLayerChromium* owner = 0);
+ virtual ~ImageLayerChromium();
virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect);
virtual void updateCompositorResources();
@@ -59,14 +60,16 @@
protected:
virtual const char* layerTypeAsString() const { return "ImageLayer"; }
- virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater();
+ virtual void setLayerRenderer(LayerRendererChromium*);
+
virtual TransformationMatrix tilingTransform();
virtual IntRect layerBounds() const;
private:
ImageLayerChromium(GraphicsLayerChromium* owner);
- PlatformImage m_decodedImage;
+ virtual void createTextureUpdaterIfNeeded();
+
NativeImagePtr m_imageForCurrentFrame;
RefPtr<Image> m_contents;
};
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-06-24 01:17:38 UTC (rev 89647)
@@ -143,7 +143,14 @@
#endif
m_hardwareCompositing = initializeSharedObjects();
- m_rootLayerContentTiler = LayerTilerChromium::create(this, createRootLayerTextureUpdater(contentPaint), IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
+#if USE(SKIA)
+ if (m_accelerateDrawing)
+ m_rootLayerTextureUpdater = LayerTextureUpdaterSkPicture::create(m_context.get(), contentPaint, skiaContext());
+ else
+#endif
+ m_rootLayerTextureUpdater = LayerTextureUpdaterBitmap::create(m_context.get(), contentPaint, m_contextSupportsMapSub);
+
+ m_rootLayerContentTiler = LayerTilerChromium::create(this, IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
ASSERT(m_rootLayerContentTiler);
m_headsUpDisplay = CCHeadsUpDisplay::create(this);
@@ -191,7 +198,7 @@
void LayerRendererChromium::updateRootLayerContents()
{
TRACE_EVENT("LayerRendererChromium::updateRootLayerContents", this, 0);
- m_rootLayerContentTiler->prepareToUpdate(m_viewportVisibleRect);
+ m_rootLayerContentTiler->prepareToUpdate(m_viewportVisibleRect, m_rootLayerTextureUpdater.get());
}
void LayerRendererChromium::drawRootLayer()
@@ -199,7 +206,7 @@
TransformationMatrix scroll;
scroll.translate(-m_viewportVisibleRect.x(), -m_viewportVisibleRect.y());
- m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f);
+ m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f, m_rootLayerTextureUpdater.get());
}
void LayerRendererChromium::setViewport(const IntRect& visibleRect, const IntRect& contentRect, const IntPoint& scrollPosition)
@@ -294,15 +301,6 @@
copyOffscreenTextureToDisplay();
}
-PassOwnPtr<LayerTextureUpdater> LayerRendererChromium::createRootLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
-{
-#if USE(SKIA)
- if (accelerateDrawing())
- return adoptPtr(new LayerTextureUpdaterSkPicture(context(), painter, skiaContext()));
-#endif
- return adoptPtr(new LayerTextureUpdaterBitmap(context(), painter, contextSupportsMapSub()));
-}
-
void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList)
{
TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0);
@@ -343,7 +341,7 @@
// Update compositor resources for root layer.
{
TRACE_EVENT("LayerRendererChromium::updateLayer::updateRoot", this, 0);
- m_rootLayerContentTiler->updateRect();
+ m_rootLayerContentTiler->updateRect(m_rootLayerTextureUpdater.get());
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -165,8 +165,6 @@
LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);
- PassOwnPtr<LayerTextureUpdater> createRootLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
-
void updateLayers(LayerList& renderSurfaceLayerList);
void updateRootLayerContents();
void updatePropertiesAndRenderSurfaces(CCLayerImpl*, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layers);
@@ -206,6 +204,7 @@
TransformationMatrix m_projectionMatrix;
RefPtr<LayerChromium> m_rootLayer;
+ OwnPtr<LayerTextureUpdater> m_rootLayerTextureUpdater;
OwnPtr<LayerTilerChromium> m_rootLayerContentTiler;
bool m_hardwareCompositing;
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -39,8 +39,8 @@
class LayerTexture;
class LayerTextureUpdater {
+ WTF_MAKE_NONCOPYABLE(LayerTextureUpdater);
public:
- explicit LayerTextureUpdater(GraphicsContext3D* context) : m_context(context) { }
virtual ~LayerTextureUpdater() { }
enum Orientation {
@@ -62,6 +62,8 @@
virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
protected:
+ explicit LayerTextureUpdater(GraphicsContext3D* context) : m_context(context) { }
+
GraphicsContext3D* context() const { return m_context; }
private:
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp 2011-06-24 01:17:38 UTC (rev 89647)
@@ -63,6 +63,11 @@
m_contentRect = contentRect;
}
+PassOwnPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
+{
+ return adoptPtr(new LayerTextureUpdaterBitmap(context, painter, useMapTexSubImage));
+}
+
LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
: LayerTextureUpdaterCanvas(context, painter)
, m_texSubImage(useMapTexSubImage)
@@ -99,6 +104,11 @@
}
#if USE(SKIA)
+PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+{
+ return adoptPtr(new LayerTextureUpdaterSkPicture(context, painter, skiaContext));
+}
+
LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(GraphicsContext3D* context, PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
: LayerTextureUpdaterCanvas(context, painter)
, m_skiaContext(skiaContext)
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -50,23 +50,27 @@
// A LayerTextureUpdater with an internal canvas.
class LayerTextureUpdaterCanvas : public LayerTextureUpdater {
+ WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterCanvas);
public:
- LayerTextureUpdaterCanvas(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>);
virtual ~LayerTextureUpdaterCanvas() { }
protected:
+ LayerTextureUpdaterCanvas(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>);
+
void paintContents(GraphicsContext&, const IntRect& contentRect);
const IntRect& contentRect() const { return m_contentRect; }
private:
+
IntRect m_contentRect;
OwnPtr<LayerPainterChromium> m_painter;
};
// A LayerTextureUpdater with an internal bitmap canvas.
class LayerTextureUpdaterBitmap : public LayerTextureUpdaterCanvas {
+ WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterBitmap);
public:
- LayerTextureUpdaterBitmap(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
+ static PassOwnPtr<LayerTextureUpdaterBitmap> create(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
virtual ~LayerTextureUpdaterBitmap() { }
virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
@@ -75,14 +79,16 @@
virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect);
private:
+ LayerTextureUpdaterBitmap(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
PlatformCanvas m_canvas;
LayerTextureSubImage m_texSubImage;
};
#if USE(SKIA)
class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
+ WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterSkPicture);
public:
- LayerTextureUpdaterSkPicture(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
+ static PassOwnPtr<LayerTextureUpdaterSkPicture> create(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
virtual ~LayerTextureUpdaterSkPicture();
virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
@@ -91,6 +97,7 @@
virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect);
private:
+ LayerTextureUpdaterSkPicture(GraphicsContext3D*, PassOwnPtr<LayerPainterChromium>, GrContext*);
void deleteFrameBuffer();
bool createFrameBuffer();
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp 2011-06-24 01:17:38 UTC (rev 89647)
@@ -43,19 +43,18 @@
namespace WebCore {
-PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border)
+PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)
{
if (!layerRenderer || tileSize.isEmpty())
return nullptr;
- return adoptPtr(new LayerTilerChromium(layerRenderer, textureUpdater, tileSize, border));
+ return adoptPtr(new LayerTilerChromium(layerRenderer, tileSize, border));
}
-LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border)
+LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)
: m_textureFormat(PlatformColor::bestTextureFormat(layerRenderer->context()))
, m_skipsDraw(false)
, m_tilingData(max(tileSize.width(), tileSize.height()), 0, 0, border == HasBorderTexels)
- , m_textureUpdater(textureUpdater)
, m_layerRenderer(layerRenderer)
{
setTileSize(tileSize);
@@ -225,7 +224,7 @@
m_tilingData.setTotalSize(0, 0);
}
-void LayerTilerChromium::prepareToUpdate(const IntRect& contentRect)
+void LayerTilerChromium::prepareToUpdate(const IntRect& contentRect, LayerTextureUpdater* textureUpdater)
{
if (m_skipsDraw || contentRect.isEmpty()) {
m_updateRect = IntRect();
@@ -264,10 +263,10 @@
if (dirtyLayerRect.isEmpty())
return;
- m_textureUpdater->prepareToUpdate(m_paintRect, m_tileSize, m_tilingData.borderTexels());
+ textureUpdater->prepareToUpdate(m_paintRect, m_tileSize, m_tilingData.borderTexels());
}
-void LayerTilerChromium::updateRect()
+void LayerTilerChromium::updateRect(LayerTextureUpdater* textureUpdater)
{
// Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
if (!m_tilingData.totalSizeX() || !m_tilingData.totalSizeY() || m_updateRect.isEmpty())
@@ -327,7 +326,7 @@
GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
- m_textureUpdater->updateTextureRect(tile->texture(), sourceRect, destRect);
+ textureUpdater->updateTextureRect(tile->texture(), sourceRect, destRect);
tile->clearDirty();
}
}
@@ -338,17 +337,17 @@
m_layerPosition = layerPosition;
}
-void LayerTilerChromium::draw(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity)
+void LayerTilerChromium::draw(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity, LayerTextureUpdater* textureUpdater)
{
if (m_skipsDraw || !m_tiles.size() || contentRect.isEmpty())
return;
- switch (m_textureUpdater->sampledTexelFormat(m_textureFormat)) {
+ switch (textureUpdater->sampledTexelFormat(m_textureFormat)) {
case LayerTextureUpdater::SampledTexelFormatRGBA:
- drawTiles(contentRect, globalTransform, opacity, layerRenderer()->tilerProgram());
+ drawTiles(contentRect, globalTransform, opacity, layerRenderer()->tilerProgram(), textureUpdater);
break;
case LayerTextureUpdater::SampledTexelFormatBGRA:
- drawTiles(contentRect, globalTransform, opacity, layerRenderer()->tilerProgramSwizzle());
+ drawTiles(contentRect, globalTransform, opacity, layerRenderer()->tilerProgramSwizzle(), textureUpdater);
break;
default:
ASSERT_NOT_REACHED();
@@ -367,7 +366,7 @@
}
template <class T>
-void LayerTilerChromium::drawTiles(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity, const T* program)
+void LayerTilerChromium::drawTiles(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity, const T* program, LayerTextureUpdater* textureUpdater)
{
GraphicsContext3D* context = layerRendererContext();
GLC(context, context->useProgram(program->program()));
@@ -407,7 +406,7 @@
float texScaleY = tileRect.height() / tileHeight;
// OpenGL coordinate system is bottom-up.
// If tile texture is top-down, we need to flip the texture coordinates.
- if (m_textureUpdater->orientation() == LayerTextureUpdater::TopDownOrientation) {
+ if (textureUpdater->orientation() == LayerTextureUpdater::TopDownOrientation) {
texTranslateY = 1.0 - texTranslateY;
texScaleY *= -1.0;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h (89646 => 89647)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h 2011-06-24 01:11:29 UTC (rev 89646)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h 2011-06-24 01:17:38 UTC (rev 89647)
@@ -46,7 +46,7 @@
public:
enum BorderTexelOption { HasBorderTexels, NoBorderTexels };
- static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption);
+ static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);
~LayerTilerChromium();
@@ -55,11 +55,11 @@
void invalidateEntireLayer();
// Prepare data needed to update textures that instersect with contentRect.
- void prepareToUpdate(const IntRect& contentRect);
+ void prepareToUpdate(const IntRect& contentRect, LayerTextureUpdater*);
// Update invalid textures that intersect with contentRect provided in prepareToUpdate().
- void updateRect();
+ void updateRect(LayerTextureUpdater*);
// Draw all tiles that intersect with the content rect.
- void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity);
+ void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity, LayerTextureUpdater*);
int numTiles() const { return m_tilingData.numTiles(); }
@@ -79,7 +79,7 @@
LayerTexture* getSingleTexture();
private:
- LayerTilerChromium(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption);
+ LayerTilerChromium(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);
class Tile : public RefCounted<Tile> {
WTF_MAKE_NONCOPYABLE(Tile);
@@ -105,7 +105,7 @@
// Draw all tiles that intersect with contentRect.
template <class T>
- void drawTiles(const IntRect& contentRect, const TransformationMatrix&, float opacity, const T* program);
+ void drawTiles(const IntRect& contentRect, const TransformationMatrix&, float opacity, const T* program, LayerTextureUpdater*);
template <class T>
void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& drawMatrix,
@@ -162,7 +162,6 @@
TilingData m_tilingData;
- OwnPtr<LayerTextureUpdater> m_textureUpdater;
LayerRendererChromium* m_layerRenderer;
};