Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert some OwnPtr/PassOwnPtr in CoordinatedGraphics code to std::un…
…ique_ptr's

https://bugs.webkit.org/show_bug.cgi?id=122614

Patch by Sergio Correia <sergio.correia@openbossa.org> on 2013-10-10
Reviewed by Anders Carlsson.

Source/WebCore:

No new tests, covered by existing ones.

* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
(WebCore::CompositingCoordinator::paintToSurface):
(WebCore::CompositingCoordinator::releaseInactiveAtlasesTimerFired):
* platform/graphics/texmap/coordinated/CompositingCoordinator.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
(WebCore::CoordinatedGraphicsLayer::createBackingStore):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
(WebCore::CoordinatedGraphicsLayer::purgeBackingStores):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::createLayer):
(WebCore::CoordinatedGraphicsScene::deleteLayer):
(WebCore::CoordinatedGraphicsScene::ensureRootLayer):
(WebCore::CoordinatedGraphicsScene::purgeGLResources):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp:
(WebCore::ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface):
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h:
* platform/graphics/texmap/coordinated/UpdateAtlas.cpp:
(WebCore::UpdateAtlas::buildLayoutIfNeeded):
(WebCore::UpdateAtlas::didSwapBuffers):
* platform/graphics/texmap/coordinated/UpdateAtlas.h:
(WebCore::UpdateAtlas::isInUse):

Source/WebKit2:

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:

Canonical link: https://commits.webkit.org/140717@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
qrwteyrutiyoup authored and webkit-commit-queue committed Oct 10, 2013
1 parent 14f5735 commit 1ba0ec1
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 40 deletions.
34 changes: 34 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,37 @@
2013-10-10 Sergio Correia <sergio.correia@openbossa.org>

Convert some OwnPtr/PassOwnPtr in CoordinatedGraphics code to std::unique_ptr's
https://bugs.webkit.org/show_bug.cgi?id=122614

Reviewed by Anders Carlsson.

No new tests, covered by existing ones.

* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
(WebCore::CompositingCoordinator::paintToSurface):
(WebCore::CompositingCoordinator::releaseInactiveAtlasesTimerFired):
* platform/graphics/texmap/coordinated/CompositingCoordinator.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
(WebCore::CoordinatedGraphicsLayer::createBackingStore):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
(WebCore::CoordinatedGraphicsLayer::purgeBackingStores):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::createLayer):
(WebCore::CoordinatedGraphicsScene::deleteLayer):
(WebCore::CoordinatedGraphicsScene::ensureRootLayer):
(WebCore::CoordinatedGraphicsScene::purgeGLResources):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp:
(WebCore::ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface):
* platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h:
* platform/graphics/texmap/coordinated/UpdateAtlas.cpp:
(WebCore::UpdateAtlas::buildLayoutIfNeeded):
(WebCore::UpdateAtlas::didSwapBuffers):
* platform/graphics/texmap/coordinated/UpdateAtlas.h:
(WebCore::UpdateAtlas::isInUse):

2013-10-10 Roger Fong <roger_fong@apple.com>

Store uniform type information in WebGLUniformationLocation.
Expand Down
Expand Up @@ -43,11 +43,6 @@

namespace WebCore {

PassOwnPtr<CompositingCoordinator> CompositingCoordinator::create(Page* page, CompositingCoordinator::Client* client)
{
return adoptPtr(new CompositingCoordinator(page, client));
}

CompositingCoordinator::~CompositingCoordinator()
{
purgeBackingStores();
Expand Down Expand Up @@ -395,7 +390,7 @@ bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurf
}

static const int ScratchBufferDimension = 1024; // Should be a power of two.
m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags)));
m_updateAtlases.append(std::make_unique<UpdateAtlas>(this, ScratchBufferDimension, flags));
scheduleReleaseInactiveAtlases();
return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
}
Expand All @@ -411,7 +406,7 @@ void CompositingCoordinator::scheduleReleaseInactiveAtlases()
void CompositingCoordinator::releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*)
{
// We always want to keep one atlas for root contents layer.
OwnPtr<UpdateAtlas> atlasToKeepAnyway;
std::unique_ptr<UpdateAtlas> atlasToKeepAnyway;
bool foundActiveAtlasForRootContentsLayer = false;
for (int i = m_updateAtlases.size() - 1; i >= 0; --i) {
UpdateAtlas* atlas = m_updateAtlases[i].get();
Expand All @@ -420,7 +415,7 @@ void CompositingCoordinator::releaseInactiveAtlasesTimerFired(Timer<CompositingC
bool usableForRootContentsLayer = !atlas->supportsAlpha();
if (atlas->isInactive()) {
if (!foundActiveAtlasForRootContentsLayer && !atlasToKeepAnyway && usableForRootContentsLayer)
atlasToKeepAnyway = m_updateAtlases[i].release();
atlasToKeepAnyway = std::move(m_updateAtlases[i]);
m_updateAtlases.remove(i);
} else if (usableForRootContentsLayer)
foundActiveAtlasForRootContentsLayer = true;
Expand Down
Expand Up @@ -38,7 +38,6 @@
#include "IntRect.h"
#include "Timer.h"
#include "UpdateAtlas.h"
#include <wtf/OwnPtr.h>

#if ENABLE(CSS_SHADERS)
#include "FilterOperations.h"
Expand Down Expand Up @@ -67,7 +66,7 @@ class CompositingCoordinator : public GraphicsLayerClient
virtual void paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect& clipRect) = 0;
};

static PassOwnPtr<CompositingCoordinator> create(Page*, CompositingCoordinator::Client*);
CompositingCoordinator(Page*, CompositingCoordinator::Client*);
virtual ~CompositingCoordinator();

void setRootCompositingLayer(GraphicsLayer*);
Expand All @@ -94,8 +93,6 @@ class CompositingCoordinator : public GraphicsLayerClient
#endif

private:
CompositingCoordinator(Page*, CompositingCoordinator::Client*);

// GraphicsLayerClient
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERRIDE;
virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE;
Expand Down Expand Up @@ -144,7 +141,7 @@ class CompositingCoordinator : public GraphicsLayerClient
LayerMap m_registeredLayers;
typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap;
ImageBackingMap m_imageBackings;
Vector<OwnPtr<UpdateAtlas> > m_updateAtlases;
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_isPurging;
Expand Down
Expand Up @@ -885,15 +885,15 @@ void CoordinatedGraphicsLayer::adjustContentsScale()
// we do not want to drop the previous one as that might result in
// briefly seeing flickering as the old tiles may be dropped before
// something replaces them.
m_previousBackingStore = m_mainBackingStore.release();
m_previousBackingStore = std::move(m_mainBackingStore);

// No reason to save the previous backing store for non-visible areas.
m_previousBackingStore->removeAllNonVisibleTiles();
}

void CoordinatedGraphicsLayer::createBackingStore()
{
m_mainBackingStore = adoptPtr(new TiledBackingStore(this, CoordinatedTileBackend::create(this)));
m_mainBackingStore = std::make_unique<TiledBackingStore>(this, CoordinatedTileBackend::create(this));
m_mainBackingStore->setSupportsAlpha(!contentsOpaque());
m_mainBackingStore->setContentsScale(effectiveContentsScale());
}
Expand Down Expand Up @@ -1014,8 +1014,8 @@ void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
void CoordinatedGraphicsLayer::updateContentBuffers()
{
if (!shouldHaveBackingStore()) {
m_mainBackingStore.clear();
m_previousBackingStore.clear();
m_mainBackingStore = nullptr;
m_previousBackingStore = nullptr;
return;
}

Expand All @@ -1040,16 +1040,16 @@ void CoordinatedGraphicsLayer::updateContentBuffers()
// removing the existing tiles and painting the new ones. The first time
// the visibleRect is full painted we remove the previous backing store.
if (m_mainBackingStore->visibleAreaIsCovered())
m_previousBackingStore.clear();
m_previousBackingStore = nullptr;
}

void CoordinatedGraphicsLayer::purgeBackingStores()
{
#ifndef NDEBUG
TemporaryChange<bool> updateModeProtector(m_isPurging, true);
#endif
m_mainBackingStore.clear();
m_previousBackingStore.clear();
m_mainBackingStore = nullptr;
m_previousBackingStore = nullptr;

releaseImageBackingIfNeeded();

Expand Down
Expand Up @@ -238,8 +238,8 @@ class CoordinatedGraphicsLayer : public GraphicsLayer
#endif

CoordinatedGraphicsLayerClient* m_coordinator;
OwnPtr<TiledBackingStore> m_mainBackingStore;
OwnPtr<TiledBackingStore> m_previousBackingStore;
std::unique_ptr<TiledBackingStore> m_mainBackingStore;
std::unique_ptr<TiledBackingStore> m_previousBackingStore;

RefPtr<Image> m_compositedImage;
NativeImagePtr m_compositedNativeImagePtr;
Expand Down
Expand Up @@ -384,10 +384,10 @@ void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& id

void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
{
OwnPtr<TextureMapperLayer> newLayer = adoptPtr(new TextureMapperLayer);
std::unique_ptr<TextureMapperLayer> newLayer = std::make_unique<TextureMapperLayer>();
newLayer->setID(id);
newLayer->setScrollClient(this);
m_layers.add(id, newLayer.release());
m_layers.add(id, std::move(newLayer));
}

void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs)
Expand All @@ -398,7 +398,7 @@ void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& la

void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID)
{
OwnPtr<TextureMapperLayer> layer = m_layers.take(layerID);
std::unique_ptr<TextureMapperLayer> layer = m_layers.take(layerID);
ASSERT(layer);

m_backingStores.remove(layer.get());
Expand Down Expand Up @@ -650,7 +650,7 @@ void CoordinatedGraphicsScene::ensureRootLayer()
if (m_rootLayer)
return;

m_rootLayer = adoptPtr(new TextureMapperLayer);
m_rootLayer = std::make_unique<TextureMapperLayer>();
m_rootLayer->setMasksToBounds(false);
m_rootLayer->setDrawsContent(false);
m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
Expand Down Expand Up @@ -688,7 +688,7 @@ void CoordinatedGraphicsScene::purgeGLResources()
#endif
m_surfaces.clear();

m_rootLayer.clear();
m_rootLayer = nullptr;
m_rootLayerID = InvalidCoordinatedLayerID;
m_layers.clear();
m_fixedLayers.clear();
Expand Down
Expand Up @@ -182,9 +182,9 @@ class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphics
CoordinatedGraphicsSceneClient* m_client;
bool m_isActive;

OwnPtr<TextureMapperLayer> m_rootLayer;
std::unique_ptr<TextureMapperLayer> m_rootLayer;

typedef HashMap<CoordinatedLayerID, OwnPtr<TextureMapperLayer> > LayerMap;
typedef HashMap<CoordinatedLayerID, std::unique_ptr<TextureMapperLayer>> LayerMap;
LayerMap m_layers;
typedef HashMap<CoordinatedLayerID, TextureMapperLayer*> LayerRawPtrMap;
LayerRawPtrMap m_fixedLayers;
Expand Down
Expand Up @@ -37,9 +37,9 @@ PassRefPtr<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(co
return adoptRef(new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size)));
}

ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> buffer)
ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, std::unique_ptr<ImageBuffer> buffer)
: CoordinatedSurface(size, flags)
, m_imageBuffer(buffer)
, m_imageBuffer(std::move(buffer))
{
}

Expand Down
Expand Up @@ -42,9 +42,9 @@ class ThreadSafeCoordinatedSurface : public CoordinatedSurface {
virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) OVERRIDE;

private:
ThreadSafeCoordinatedSurface(const IntSize&, Flags, PassOwnPtr<ImageBuffer>);
ThreadSafeCoordinatedSurface(const IntSize&, Flags, std::unique_ptr<ImageBuffer>);

OwnPtr<ImageBuffer> m_imageBuffer;
std::unique_ptr<ImageBuffer> m_imageBuffer;
};

} // namespace WebCore
Expand Down
Expand Up @@ -77,14 +77,14 @@ UpdateAtlas::~UpdateAtlas()
void UpdateAtlas::buildLayoutIfNeeded()
{
if (!m_areaAllocator) {
m_areaAllocator = adoptPtr(new GeneralAreaAllocator(size()));
m_areaAllocator = std::make_unique<GeneralAreaAllocator>(size());
m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
}
}

void UpdateAtlas::didSwapBuffers()
{
m_areaAllocator.clear();
m_areaAllocator = nullptr;
}


Expand Down
Expand Up @@ -60,14 +60,14 @@ class UpdateAtlas {
const double inactiveSecondsTolerance = 3;
return m_inactivityInSeconds > inactiveSecondsTolerance;
}
bool isInUse() const { return m_areaAllocator; }
bool isInUse() const { return !!m_areaAllocator; }

private:
void buildLayoutIfNeeded();

private:
Client* m_client;
OwnPtr<GeneralAreaAllocator> m_areaAllocator;
std::unique_ptr<GeneralAreaAllocator> m_areaAllocator;
RefPtr<CoordinatedSurface> m_surface;
double m_inactivityInSeconds;
uint32_t m_ID;
Expand Down
11 changes: 11 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,14 @@
2013-10-10 Sergio Correia <sergio.correia@openbossa.org>

Convert some OwnPtr/PassOwnPtr in CoordinatedGraphics code to std::unique_ptr's
https://bugs.webkit.org/show_bug.cgi?id=122614

Reviewed by Anders Carlsson.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:

2013-10-10 Csaba Osztrogonác <ossy@webkit.org>

generate-message-receiver.py can't handle nested #ifs
Expand Down
Expand Up @@ -74,7 +74,7 @@ CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
, m_layerFlushSchedulingEnabled(true)
, m_forceRepaintAsyncCallbackID(0)
{
m_coordinator = CompositingCoordinator::create(webPage->corePage(), this);
m_coordinator = std::make_unique<CompositingCoordinator>(webPage->corePage(), this);

m_coordinator->createRootLayer(webPage->size());
m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
Expand Down
Expand Up @@ -28,7 +28,6 @@
#include <WebCore/CompositingCoordinator.h>
#include <WebCore/GraphicsLayerFactory.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>

#if ENABLE(CSS_SHADERS)
#include "WebCustomFilterProgramProxy.h"
Expand Down Expand Up @@ -119,7 +118,7 @@ class CoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::Compositi
void disconnectCustomFilterPrograms();
#endif

OwnPtr<WebCore::CompositingCoordinator> m_coordinator;
std::unique_ptr<WebCore::CompositingCoordinator> m_coordinator;

// The page overlay layer. Will be null if there's no page overlay.
std::unique_ptr<WebCore::GraphicsLayer> m_pageOverlayLayer;
Expand Down

0 comments on commit 1ba0ec1

Please sign in to comment.