Diff
Modified: trunk/Source/WebCore/ChangeLog (202811 => 202812)
--- trunk/Source/WebCore/ChangeLog 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/ChangeLog 2016-07-05 06:16:09 UTC (rev 202812)
@@ -1,3 +1,23 @@
+2016-07-04 Carlos Garcia Campos <[email protected]>
+
+ [Coordinated Graphics] Modernize and cleanup CompositingCoordinator
+ https://bugs.webkit.org/show_bug.cgi?id=159212
+
+ Reviewed by Žan Doberšek.
+
+ Use references instead of pointers when possible.
+
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+ (WebCore::CoordinatedGraphicsLayer::paintToSurface):
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+ * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
+ (WebCore::CoordinatedImageBacking::update):
+ * platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
+ * platform/graphics/texmap/coordinated/CoordinatedSurface.h:
+ * platform/graphics/texmap/coordinated/Tile.cpp:
+ (WebCore::Tile::updateBackBuffer):
+ * platform/graphics/texmap/coordinated/TiledBackingStoreClient.h:
+
2016-07-04 Youenn Fablet <[email protected]>
Remove RequestOriginPolicy from ResourceLoaderOptions
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -950,7 +950,7 @@
return enclosingIntRect(rect);
}
-bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client* client)
+bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client& client)
{
ASSERT(m_coordinator);
ASSERT(m_coordinator->isFlushingLayerChanges());
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -49,9 +49,9 @@
public:
virtual bool isFlushingLayerChanges() const = 0;
virtual FloatRect visibleContentsRect() const = 0;
- virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
+ virtual Ref<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
- virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
+ virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client&) = 0;
virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0;
};
@@ -139,7 +139,7 @@
void createTile(uint32_t tileID, float) override;
void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
void removeTile(uint32_t tileID) override;
- bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client*) override;
+ bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client&) override;
void setCoordinator(CoordinatedGraphicsLayerClient*);
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -129,11 +129,11 @@
IntRect rect(IntPoint::zero(), IntSize(m_image->size()));
ImageBackingSurfaceClient surfaceClient(*m_image, rect);
- m_surface->paintToSurface(rect, &surfaceClient);
+ m_surface->paintToSurface(rect, surfaceClient);
m_nativeImagePtr = m_image->nativeImageForCurrentFrame();
- m_client->updateImageBacking(id(), m_surface);
+ m_client->updateImageBacking(id(), m_surface.copyRef());
m_isDirty = false;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -42,7 +42,7 @@
class Client {
public:
virtual void createImageBacking(CoordinatedImageBackingID) = 0;
- virtual void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) = 0;
+ virtual void updateImageBacking(CoordinatedImageBackingID, RefPtr<CoordinatedSurface>&&) = 0;
virtual void clearImageBackingContents(CoordinatedImageBackingID) = 0;
virtual void removeImageBacking(CoordinatedImageBackingID) = 0;
};
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -53,7 +53,7 @@
bool supportsAlpha() const { return flags() & SupportsAlpha; }
IntSize size() const { return m_size; }
- virtual void paintToSurface(const IntRect&, Client*) = 0;
+ virtual void paintToSurface(const IntRect&, Client&) = 0;
#if USE(TEXTURE_MAPPER)
virtual void copyToTexture(RefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) = 0;
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/Tile.cpp (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/Tile.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/Tile.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -72,7 +72,7 @@
SurfaceUpdateInfo updateInfo;
- if (!m_tiledBackingStore.client()->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, this))
+ if (!m_tiledBackingStore.client()->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, *this))
return false;
updateInfo.updateRect = m_dirtyRect;
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h (202811 => 202812)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -39,7 +39,7 @@
virtual void createTile(uint32_t tileID, float) = 0;
virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
virtual void removeTile(uint32_t tileID) = 0;
- virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
+ virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client&) = 0;
};
#endif
Modified: trunk/Source/WebKit2/ChangeLog (202811 => 202812)
--- trunk/Source/WebKit2/ChangeLog 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-05 06:16:09 UTC (rev 202812)
@@ -1,3 +1,67 @@
+2016-07-04 Carlos Garcia Campos <[email protected]>
+
+ [Coordinated Graphics] Modernize and cleanup CompositingCoordinator
+ https://bugs.webkit.org/show_bug.cgi?id=159212
+
+ Reviewed by Žan Doberšek.
+
+ Changes done:
+
+ - Use references instead of pointers when possible.
+ - Add missing final/override keywords.
+ - Reduce the use of PassRefPtr
+ - Move member initializations to the declaration.
+ - Use nullptr instead of 0.
+ - Use HashMap::ensure() instead of complicated code with iterators.
+ - Avoid heap allocation when possible.
+
+ * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:
+ (WebKit::WebCoordinatedSurface::paintToSurface):
+ * Shared/CoordinatedGraphics/WebCoordinatedSurface.h:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp:
+ (WebKit::ThreadSafeCoordinatedSurface::paintToSurface):
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h:
+ * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp:
+ (WebKit::GeneralAreaAllocator::expand):
+ (WebKit::GeneralAreaAllocator::splitNode):
+ (WebKit::GeneralAreaAllocator::release):
+ (WebKit::GeneralAreaAllocator::GeneralAreaAllocator): Deleted.
+ * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h:
+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+ (WebKit::CompositingCoordinator::CompositingCoordinator):
+ (WebKit::CompositingCoordinator::flushPendingLayerChanges):
+ (WebKit::CompositingCoordinator::createImageBackingIfNeeded):
+ (WebKit::CompositingCoordinator::updateImageBacking):
+ (WebKit::CompositingCoordinator::notifyFlushRequired):
+ (WebKit::CompositingCoordinator::paintContents):
+ (WebKit::CompositingCoordinator::createUpdateAtlas):
+ (WebKit::CompositingCoordinator::commitScrollOffset):
+ (WebKit::CompositingCoordinator::paintToSurface):
+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+ (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+ (WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer):
+ (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
+ (WebKit::CoordinatedLayerTreeHost::invalidate):
+ (WebKit::CoordinatedLayerTreeHost::forceRepaint):
+ (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
+ (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
+ (WebKit::CoordinatedLayerTreeHost::renderNextFrame):
+ (WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
+ (WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired):
+ (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+ (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory):
+ (WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
+ (WebKit::CoordinatedLayerTreeHost::commitScrollOffset):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
+ (WebKit::UpdateAtlas::UpdateAtlas):
+ (WebKit::UpdateAtlas::~UpdateAtlas):
+ (WebKit::UpdateAtlas::buildLayoutIfNeeded):
+ (WebKit::UpdateAtlas::paintOnAvailableBuffer):
+ (WebKit::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient): Deleted.
+ * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
+
2016-07-04 Brady Eidson <[email protected]>
WebProcesses don't handle DatabaseProcess going away uncleanly..
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp (202811 => 202812)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -181,12 +181,10 @@
return true;
}
-void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
{
- ASSERT(client);
-
auto context = createGraphicsContext(rect);
- client->paintToSurfaceContext(*context);
+ client.paintToSurfaceContext(*context);
}
#if USE(TEXTURE_MAPPER)
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h (202811 => 202812)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -71,7 +71,7 @@
virtual ~WebCoordinatedSurface();
- void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) override;
+ void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
#if USE(TEXTURE_MAPPER)
void copyToTexture(RefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override;
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp (202811 => 202812)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -52,12 +52,10 @@
{
}
-void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
{
- ASSERT(client);
-
GraphicsContext& context = beginPaint(rect);
- client->paintToSurfaceContext(context);
+ client.paintToSurfaceContext(context);
endPaint();
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h (202811 => 202812)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -39,7 +39,7 @@
// Create a new ThreadSafeCoordinatedSurface and allocate either a GraphicsSurface or a ImageBuffer as backing.
static Ref<ThreadSafeCoordinatedSurface> create(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
- void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) override;
+ void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
void copyToTexture(RefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override;
private:
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -76,9 +76,6 @@
m_root = new Node();
m_root->rect = IntRect(0, 0, m_size.width(), m_size.height());
m_root->largestFree = m_size;
- m_root->parent = 0;
- m_root->left = 0;
- m_root->right = 0;
m_nodeCount = 1;
setMinimumAllocation(IntSize(8, 8));
}
@@ -128,13 +125,13 @@
Node* right = new Node();
m_nodeCount += 2;
m_root->parent = parent;
- parent->parent = 0;
+ parent->parent = nullptr;
parent->left = m_root;
parent->right = right;
parent->largestFree = m_root->rect.size();
right->parent = parent;
- right->left = 0;
- right->right = 0;
+ right->left = nullptr;
+ right->right = nullptr;
right->largestFree = m_root->rect.size();
if (split == SplitOnX) {
parent->rect = IntRect(m_root->rect.x(), m_root->rect.y(),
@@ -240,20 +237,15 @@
return IntPoint(-1, -1);
}
-GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode
- (Node* node, Split split)
+GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode(Node* node, Split split)
{
Node* left = new Node();
+ left->parent = node;
Node* right = new Node();
- m_nodeCount += 2;
- left->parent = node;
- left->left = 0;
- left->right = 0;
right->parent = node;
- right->left = 0;
- right->right = 0;
node->left = left;
node->right = right;
+ m_nodeCount += 2;
if (split == SplitOnX) {
left->rect = IntRect(node->rect.x(), node->rect.y(),
@@ -317,8 +309,8 @@
freeNode(node->left);
freeNode(node->right);
m_nodeCount -= 2;
- node->left = 0;
- node->right = 0;
+ node->left = nullptr;
+ node->right = nullptr;
node->largestFree = node->rect.size();
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -76,26 +76,28 @@
WebCore::IntSize roundAllocation(const WebCore::IntSize&) const;
};
-class GeneralAreaAllocator : public AreaAllocator {
+class GeneralAreaAllocator final : public AreaAllocator {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit GeneralAreaAllocator(const WebCore::IntSize&);
virtual ~GeneralAreaAllocator();
- void expand(const WebCore::IntSize&);
- WebCore::IntRect allocate(const WebCore::IntSize&);
- void release(const WebCore::IntRect&);
- int overhead() const;
+ void expand(const WebCore::IntSize&) override;
+ WebCore::IntRect allocate(const WebCore::IntSize&) override;
+ void release(const WebCore::IntRect&) override;
+ int overhead() const override;
private:
enum Split { SplitOnX, SplitOnY };
struct Node {
+ WTF_MAKE_FAST_ALLOCATED;
+ public:
WebCore::IntRect rect;
WebCore::IntSize largestFree;
- Node* parent;
- Node* left;
- Node* right;
+ Node* parent { nullptr };
+ Node* left { nullptr };
+ Node* right { nullptr };
};
Node* m_root;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -36,8 +36,6 @@
#include <WebCore/InspectorController.h>
#include <WebCore/MainFrame.h>
#include <WebCore/Page.h>
-#include <WebCore/Settings.h>
-#include <wtf/CurrentTime.h>
#include <wtf/TemporaryChange.h>
using namespace WebCore;
@@ -44,20 +42,10 @@
namespace WebKit {
-CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
+CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client& client)
: m_page(page)
, m_client(client)
- , m_rootCompositingLayer(nullptr)
- , m_overlayCompositingLayer(nullptr)
- , m_isDestructing(false)
- , m_isPurging(false)
- , m_isFlushingLayerChanges(false)
- , m_shouldSyncFrame(false)
- , m_didInitializeRootCompositingLayer(false)
, m_releaseInactiveAtlasesTimer(*this, &CompositingCoordinator::releaseInactiveAtlasesTimerFired)
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- , m_lastAnimationServiceTime(0)
-#endif
{
}
@@ -111,7 +99,7 @@
bool viewportIsStable = m_page->mainFrame().view()->viewportIsStable();
m_rootLayer->flushCompositingStateForThisLayerOnly(viewportIsStable);
- m_client->didFlushRootLayer(m_visibleContentsRect);
+ m_client.didFlushRootLayer(m_visibleContentsRect);
if (m_overlayCompositingLayer)
m_overlayCompositingLayer->flushCompositingState(FloatRect(FloatPoint(), m_rootLayer->size()), viewportIsStable);
@@ -133,7 +121,7 @@
}
m_state.scrollPosition = m_visibleContentsRect.location();
- m_client->commitSceneState(m_state);
+ m_client.commitSceneState(m_state);
clearPendingStateChanges();
m_shouldSyncFrame = false;
@@ -212,18 +200,13 @@
m_state.layersToUpdate.append(std::make_pair(id, state));
}
-PassRefPtr<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
+Ref<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
{
CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
- ImageBackingMap::iterator it = m_imageBackings.find(imageID);
- RefPtr<CoordinatedImageBacking> imageBacking;
- if (it == m_imageBackings.end()) {
- imageBacking = CoordinatedImageBacking::create(this, image);
- m_imageBackings.add(imageID, imageBacking);
- } else
- imageBacking = it->value;
-
- return imageBacking;
+ auto addResult = m_imageBackings.ensure(imageID, [this, image] {
+ return CoordinatedImageBacking::create(this, image);
+ });
+ return *addResult.iterator->value;
}
void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID)
@@ -231,10 +214,10 @@
m_state.imagesToCreate.append(imageID);
}
-void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
+void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<CoordinatedSurface>&& coordinatedSurface)
{
m_shouldSyncFrame = true;
- m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
+ m_state.imagesToUpdate.append(std::make_pair(imageID, WTFMove(coordinatedSurface)));
}
void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID)
@@ -271,12 +254,12 @@
void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
{
if (!m_isDestructing && !isFlushingLayerChanges())
- m_client->notifyFlushRequired();
+ m_client.notifyFlushRequired();
}
void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& clipRect)
{
- m_client->paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
+ m_client.paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
}
std::unique_ptr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
@@ -300,9 +283,9 @@
return m_page->pageScaleFactor();
}
-void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
+void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, RefPtr<CoordinatedSurface>&& coordinatedSurface)
{
- m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
+ m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, WTFMove(coordinatedSurface)));
}
void CompositingCoordinator::removeUpdateAtlas(uint32_t atlasID)
@@ -371,11 +354,8 @@
void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
{
- LayerMap::iterator i = m_registeredLayers.find(layerID);
- if (i == m_registeredLayers.end())
- return;
-
- i->value->commitScrollOffset(offset);
+ if (auto* layer = m_registeredLayers.get(layerID))
+ layer->commitScrollOffset(offset);
}
void CompositingCoordinator::renderNextFrame()
@@ -395,7 +375,7 @@
m_updateAtlases.clear();
}
-bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
+bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client& client)
{
for (auto& updateAtlas : m_updateAtlases) {
UpdateAtlas* atlas = updateAtlas.get();
@@ -407,7 +387,7 @@
}
static const int ScratchBufferDimension = 1024; // Should be a power of two.
- m_updateAtlases.append(std::make_unique<UpdateAtlas>(this, ScratchBufferDimension, flags));
+ m_updateAtlases.append(std::make_unique<UpdateAtlas>(*this, ScratchBufferDimension, flags));
scheduleReleaseInactiveAtlases();
return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -48,12 +48,12 @@
namespace WebKit {
-class CompositingCoordinator : public WebCore::GraphicsLayerClient
+class CompositingCoordinator final : public WebCore::GraphicsLayerClient
, public WebCore::CoordinatedGraphicsLayerClient
, public WebCore::CoordinatedImageBacking::Client
, public UpdateAtlas::Client
, public WebCore::GraphicsLayerFactory {
- WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(CompositingCoordinator);
public:
class Client {
public:
@@ -63,7 +63,7 @@
virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) = 0;
};
- CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client*);
+ CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client&);
virtual ~CompositingCoordinator();
void setRootCompositingLayer(WebCore::GraphicsLayer*);
@@ -100,7 +100,7 @@
// CoordinatedImageBacking::Client
void createImageBacking(WebCore::CoordinatedImageBackingID) override;
- void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr<WebCore::CoordinatedSurface>) override;
+ void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedSurface>&&) override;
void clearImageBackingContents(WebCore::CoordinatedImageBackingID) override;
void removeImageBacking(WebCore::CoordinatedImageBackingID) override;
@@ -107,13 +107,13 @@
// CoordinatedGraphicsLayerClient
bool isFlushingLayerChanges() const override { return m_isFlushingLayerChanges; }
WebCore::FloatRect visibleContentsRect() const override;
- PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) override;
+ Ref<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) override;
void detachLayer(WebCore::CoordinatedGraphicsLayer*) override;
- bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) override;
+ bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client&) override;
void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&) override;
// UpdateAtlas::Client
- void createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) override;
+ void createUpdateAtlas(uint32_t atlasID, RefPtr<WebCore::CoordinatedSurface>&&) override;
void removeUpdateAtlas(uint32_t atlasID) override;
// GraphicsLayerFactory
@@ -130,11 +130,11 @@
double timestamp() const;
WebCore::Page* m_page;
- CompositingCoordinator::Client* m_client;
+ CompositingCoordinator::Client& m_client;
std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
- WebCore::GraphicsLayer* m_rootCompositingLayer;
- WebCore::GraphicsLayer* m_overlayCompositingLayer;
+ WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr };
+ WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr };
WebCore::CoordinatedGraphicsState m_state;
@@ -145,18 +145,17 @@
Vector<std::unique_ptr<UpdateAtlas>> m_updateAtlases;
// We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
- bool m_isDestructing;
- bool m_isPurging;
- bool m_isFlushingLayerChanges;
+ bool m_isDestructing { false };
+ bool m_isPurging { false };
+ bool m_isFlushingLayerChanges { false };
+ bool m_shouldSyncFrame { false };
+ bool m_didInitializeRootCompositingLayer { false };
WebCore::FloatRect m_visibleContentsRect;
-
- bool m_shouldSyncFrame;
- bool m_didInitializeRootCompositingLayer;
WebCore::Timer m_releaseInactiveAtlasesTimer;
#if ENABLE(REQUEST_ANIMATION_FRAME)
- double m_lastAnimationServiceTime;
+ double m_lastAnimationServiceTime { 0 };
#endif
};
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -61,12 +61,12 @@
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage& webPage)
: LayerTreeHost(webPage)
- , m_coordinator(std::make_unique<CompositingCoordinator>(webPage.corePage(), this))
+ , m_coordinator(webPage.corePage(), *this)
, m_layerFlushTimer(RunLoop::main(), this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
{
- m_coordinator->createRootLayer(m_webPage.size());
+ m_coordinator.createRootLayer(m_webPage.size());
#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
- m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
+ m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator.rootLayer())->id();
#endif
CoordinatedSurface::setFactory(createCoordinatedSurface);
@@ -90,12 +90,12 @@
void CoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer)
{
LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer);
- m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer);
+ m_coordinator.setViewOverlayRootLayer(viewOverlayRootLayer);
}
void CoordinatedLayerTreeHost::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
{
- m_coordinator->setRootCompositingLayer(graphicsLayer);
+ m_coordinator.setRootCompositingLayer(graphicsLayer);
}
void CoordinatedLayerTreeHost::invalidate()
@@ -102,7 +102,7 @@
{
cancelPendingLayerFlush();
- m_coordinator->clearRootLayer();
+ m_coordinator.clearRootLayer();
LayerTreeHost::invalidate();
}
@@ -110,7 +110,7 @@
{
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
- m_coordinator->syncDisplayState();
+ m_coordinator.syncDisplayState();
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
// This is aligned with LayerTreeHostCA.
@@ -119,7 +119,7 @@
if (m_isWaitingForRenderer)
return;
- m_coordinator->flushPendingLayerChanges();
+ m_coordinator.flushPendingLayerChanges();
}
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
@@ -133,13 +133,13 @@
void CoordinatedLayerTreeHost::sizeDidChange(const IntSize& newSize)
{
- m_coordinator->sizeDidChange(newSize);
+ m_coordinator.sizeDidChange(newSize);
scheduleLayerFlush();
}
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
{
- m_coordinator->setVisibleContentsRect(rect, trajectoryVector);
+ m_coordinator.setVisibleContentsRect(rect, trajectoryVector);
scheduleLayerFlush();
}
@@ -147,12 +147,12 @@
{
m_isWaitingForRenderer = false;
scheduleLayerFlush();
- m_coordinator->renderNextFrame();
+ m_coordinator.renderNextFrame();
}
void CoordinatedLayerTreeHost::purgeBackingStores()
{
- m_coordinator->purgeBackingStores();
+ m_coordinator.purgeBackingStores();
}
void CoordinatedLayerTreeHost::didFlushRootLayer(const FloatRect& visibleContentRect)
@@ -167,12 +167,12 @@
if (m_isSuspended || m_isWaitingForRenderer)
return;
- m_coordinator->syncDisplayState();
+ m_coordinator.syncDisplayState();
if (!m_isValid)
return;
- bool didSync = m_coordinator->flushPendingLayerChanges();
+ bool didSync = m_coordinator.flushPendingLayerChanges();
if (m_forceRepaintAsyncCallbackID) {
m_webPage.send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID));
@@ -212,7 +212,7 @@
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
{
- m_coordinator->deviceOrPageScaleFactorChanged();
+ m_coordinator.deviceOrPageScaleFactorChanged();
m_webPage.mainFrame()->pageOverlayController().didChangeDeviceScaleFactor();
}
@@ -222,7 +222,7 @@
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
{
- return m_coordinator.get();
+ return &m_coordinator;
}
#if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -235,13 +235,13 @@
return;
scheduleLayerFlush();
- m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime());
+ m_layerFlushTimer.startOneShot(m_coordinator.nextAnimationServiceTime());
}
#endif
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
{
- m_coordinator->commitScrollOffset(layerID, offset);
+ m_coordinator.commitScrollOffset(layerID, offset);
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -85,7 +85,7 @@
static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
- std::unique_ptr<CompositingCoordinator> m_coordinator;
+ CompositingCoordinator m_coordinator;
bool m_isWaitingForRenderer { true };
uint64_t m_forceRepaintAsyncCallbackID { 0 };
RunLoop::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp 2016-07-05 06:16:09 UTC (rev 202812)
@@ -32,9 +32,9 @@
namespace WebKit {
-class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client {
+class UpdateAtlasSurfaceClient final : public CoordinatedSurface::Client {
public:
- UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize& size, bool supportsAlpha)
+ UpdateAtlasSurfaceClient(CoordinatedSurface::Client& client, const IntSize& size, bool supportsAlpha)
: m_client(client)
, m_size(size)
, m_supportsAlpha(supportsAlpha)
@@ -49,18 +49,17 @@
context.setCompositeOperation(CompositeSourceOver);
}
- m_client->paintToSurfaceContext(context);
+ m_client.paintToSurfaceContext(context);
}
private:
- CoordinatedSurface::Client* m_client;
+ CoordinatedSurface::Client& m_client;
IntSize m_size;
bool m_supportsAlpha;
};
-UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags)
+UpdateAtlas::UpdateAtlas(Client& client, int dimension, CoordinatedSurface::Flags flags)
: m_client(client)
- , m_inactivityInSeconds(0)
{
static uint32_t nextID = 0;
m_ID = ++nextID;
@@ -67,21 +66,21 @@
IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
m_surface = CoordinatedSurface::create(size, flags);
- m_client->createUpdateAtlas(m_ID, m_surface);
+ m_client.createUpdateAtlas(m_ID, m_surface.copyRef());
}
UpdateAtlas::~UpdateAtlas()
{
if (m_surface)
- m_client->removeUpdateAtlas(m_ID);
+ m_client.removeUpdateAtlas(m_ID);
}
void UpdateAtlas::buildLayoutIfNeeded()
{
- if (!m_areaAllocator) {
- m_areaAllocator = std::make_unique<GeneralAreaAllocator>(size());
- m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
- }
+ if (m_areaAllocator)
+ return;
+ m_areaAllocator = std::make_unique<GeneralAreaAllocator>(size());
+ m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
}
void UpdateAtlas::didSwapBuffers()
@@ -89,8 +88,7 @@
m_areaAllocator = nullptr;
}
-
-bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
+bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client& client)
{
m_inactivityInSeconds = 0;
buildLayoutIfNeeded();
@@ -109,7 +107,7 @@
offset = rect.location();
UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
- m_surface->paintToSurface(rect, &surfaceClient);
+ m_surface->paintToSurface(rect, surfaceClient);
return true;
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h (202811 => 202812)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h 2016-07-04 18:36:30 UTC (rev 202811)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h 2016-07-05 06:16:09 UTC (rev 202812)
@@ -41,17 +41,17 @@
public:
class Client {
public:
- virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr<WebCore::CoordinatedSurface>) = 0;
+ virtual void createUpdateAtlas(uint32_t /* id */, RefPtr<WebCore::CoordinatedSurface>&&) = 0;
virtual void removeUpdateAtlas(uint32_t /* id */) = 0;
};
- UpdateAtlas(Client*, int dimension, WebCore::CoordinatedSurface::Flags);
+ UpdateAtlas(Client&, int dimension, WebCore::CoordinatedSurface::Flags);
~UpdateAtlas();
inline WebCore::IntSize size() const { return m_surface->size(); }
// Returns false if there is no available buffer.
- bool paintOnAvailableBuffer(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint& offset, WebCore::CoordinatedSurface::Client*);
+ bool paintOnAvailableBuffer(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint& offset, WebCore::CoordinatedSurface::Client&);
void didSwapBuffers();
bool supportsAlpha() const { return m_surface->supportsAlpha(); }
@@ -71,11 +71,11 @@
void buildLayoutIfNeeded();
private:
- Client* m_client;
+ Client& m_client;
std::unique_ptr<GeneralAreaAllocator> m_areaAllocator;
RefPtr<WebCore::CoordinatedSurface> m_surface;
- double m_inactivityInSeconds;
- uint32_t m_ID;
+ double m_inactivityInSeconds { 0 };
+ uint32_t m_ID { 0 };
};
} // namespace WebKit