Coordinated Graphics: CoordinatedGraphicsLayer makes CoordinatedGraphicsScene perform via CoordinatedGraphicsOperation.
https://bugs.webkit.org/show_bug.cgi?id=108294

Patch by Huang Dongsung <luxtella@company100.net> on 2013-02-04
Reviewed by NOBODY (OOPS!).

Source/WebCore:

CoordinatedLayerTreeHostProxy has so many IPC messages (e.g. SyncCanvas and
CreateTile), and there is a long function chain from CoordinatedGraphicsLayer to
CoordinatedGraphicsScene (4 classes).
If we want to add a new message, we need to add similar functions into 4 classes.

Now CoordinatedLayerTreeHost has only one IPC message: CommitCoordinatedGraphicsOperations.
CoordinatedGraphicsLayer makes CoordinatedGraphicsScene run as follows:
1. CoordinatedGraphicsLayer makes a CoordinatedGraphicsOperation (e.g. CreateTile).
2. CoordinatedLayerTreeHost stores all operations.
3. CoordinatedLayerTreeHost sends all operations to CoordinatedLayerTreeHostProxy
at the moment of flushing via CommitCoordinatedGraphicsOperations message.
4. CoordinatedGraphicsScene executes all operations.

There is one big behavior change. All operations (e.g. CreateLayers and
SyncCanvas) are performed at the same time, when
CoordinatedGraphicsScene::commitCoordinatedGraphicsOperations is called.

If you want to add a new operation, add code as follows:
1. Create a new operation subclass in CoordinatedGraphicsOperation.h
2. Override OperationBase::execute() to execute what the operation should do.
3. Implement encode/decode in CoordinatedGraphicsArgumentCoders.

Covered by existing compositing tests.

* CMakeLists.txt:
* Target.pri:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::syncChildren):
(WebCore::CoordinatedGraphicsLayer::syncFilters):
(WebCore::CoordinatedGraphicsLayer::syncLayerState):
(WebCore::CoordinatedGraphicsLayer::syncAnimations):
(WebCore::CoordinatedGraphicsLayer::syncCanvas):
(WebCore::CoordinatedGraphicsLayer::destroyCanvasIfNeeded):
(WebCore::CoordinatedGraphicsLayer::createCanvasIfNeeded):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStorePaintEnd):
(WebCore::CoordinatedGraphicsLayer::createTile):
(WebCore::CoordinatedGraphicsLayer::updateTile):
(WebCore::CoordinatedGraphicsLayer::removeTile):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayerClient):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsOperation.cpp: Added.
(WebCore):
(WebCore::CoordinatedGraphicsOperation::CreateLayers::execute):
(WebCore::CoordinatedGraphicsOperation::DeleteLayers::execute):
(WebCore::CoordinatedGraphicsOperation::SetRootLayer::execute):
(WebCore::CoordinatedGraphicsOperation::SetLayerState::execute):
(WebCore::CoordinatedGraphicsOperation::SetLayerChildren::execute):
(WebCore::CoordinatedGraphicsOperation::CreateTile::execute):
(WebCore::CoordinatedGraphicsOperation::UpdateTile::execute):
(WebCore::CoordinatedGraphicsOperation::RemoveTile::execute):
(WebCore::CoordinatedGraphicsOperation::CreateUpdateAtlas::execute):
(WebCore::CoordinatedGraphicsOperation::RemoveUpdateAtlas::execute):
(WebCore::CoordinatedGraphicsOperation::CreateImageBacking::execute):
(WebCore::CoordinatedGraphicsOperation::UpdateImageBacking::execute):
(WebCore::CoordinatedGraphicsOperation::ClearImageBackingContents::execute):
(WebCore::CoordinatedGraphicsOperation::RemoveImageBacking::execute):
(WebCore::CoordinatedGraphicsOperation::SetLayerAnimations::execute):
(WebCore::CoordinatedGraphicsOperation::RequestAnimationFrame::execute):
(WebCore::CoordinatedGraphicsOperation::CreateCanvas::execute):
(WebCore::CoordinatedGraphicsOperation::SyncCanvas::execute):
(WebCore::CoordinatedGraphicsOperation::DestroyCanvas::execute):
(WebCore::CoordinatedGraphicsOperation::SetLayerFilters::execute):
(WebCore::CoordinatedGraphicsOperation::CreateCustomFilterProgram::execute):
(WebCore::CoordinatedGraphicsOperation::RemoveCustomFilterProgram::execute):
(WebCore::CoordinatedGraphicsOperation::SetLayerRepaintCount::execute):
(WebCore::CoordinatedGraphicsOperation::SetBackgroundColor::execute):
(WebCore::CoordinatedGraphicsOperation::DidChangeScrollPosition::execute):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsOperation.h: Added.
(WebCore):
(CoordinatedGraphicsOperation):
(OperationBase):
(WebCore::CoordinatedGraphicsOperation::OperationBase::~OperationBase):
(Operation):
(WebCore::CoordinatedGraphicsOperation::Operation::~Operation):
(WebCore::CoordinatedGraphicsOperation::Operation::getOperationType):
(CreateLayers):
(WebCore::CoordinatedGraphicsOperation::CreateLayers::create):
(WebCore::CoordinatedGraphicsOperation::CreateLayers::CreateLayers):
(DeleteLayers):
(WebCore::CoordinatedGraphicsOperation::DeleteLayers::create):
(WebCore::CoordinatedGraphicsOperation::DeleteLayers::DeleteLayers):
(SetRootLayer):
(WebCore::CoordinatedGraphicsOperation::SetRootLayer::create):
(WebCore::CoordinatedGraphicsOperation::SetRootLayer::SetRootLayer):
(SetLayerState):
(WebCore::CoordinatedGraphicsOperation::SetLayerState::create):
(WebCore::CoordinatedGraphicsOperation::SetLayerState::SetLayerState):
(SetLayerChildren):
(WebCore::CoordinatedGraphicsOperation::SetLayerChildren::create):
(WebCore::CoordinatedGraphicsOperation::SetLayerChildren::SetLayerChildren):
(CreateTile):
(WebCore::CoordinatedGraphicsOperation::CreateTile::create):
(WebCore::CoordinatedGraphicsOperation::CreateTile::CreateTile):
(UpdateTile):
(WebCore::CoordinatedGraphicsOperation::UpdateTile::create):
(WebCore::CoordinatedGraphicsOperation::UpdateTile::UpdateTile):
(RemoveTile):
(WebCore::CoordinatedGraphicsOperation::RemoveTile::create):
(WebCore::CoordinatedGraphicsOperation::RemoveTile::RemoveTile):
(CreateUpdateAtlas):
(WebCore::CoordinatedGraphicsOperation::CreateUpdateAtlas::create):
(WebCore::CoordinatedGraphicsOperation::CreateUpdateAtlas::CreateUpdateAtlas):
(RemoveUpdateAtlas):
(WebCore::CoordinatedGraphicsOperation::RemoveUpdateAtlas::create):
(WebCore::CoordinatedGraphicsOperation::RemoveUpdateAtlas::RemoveUpdateAtlas):
(CreateImageBacking):
(WebCore::CoordinatedGraphicsOperation::CreateImageBacking::create):
(WebCore::CoordinatedGraphicsOperation::CreateImageBacking::CreateImageBacking):
(UpdateImageBacking):
(WebCore::CoordinatedGraphicsOperation::UpdateImageBacking::create):
(WebCore::CoordinatedGraphicsOperation::UpdateImageBacking::UpdateImageBacking):
(ClearImageBackingContents):
(WebCore::CoordinatedGraphicsOperation::ClearImageBackingContents::create):
(WebCore::CoordinatedGraphicsOperation::ClearImageBackingContents::ClearImageBackingContents):
(RemoveImageBacking):
(WebCore::CoordinatedGraphicsOperation::RemoveImageBacking::create):
(WebCore::CoordinatedGraphicsOperation::RemoveImageBacking::RemoveImageBacking):
(SetLayerAnimations):
(WebCore::CoordinatedGraphicsOperation::SetLayerAnimations::create):
(WebCore::CoordinatedGraphicsOperation::SetLayerAnimations::SetLayerAnimations):
(RequestAnimationFrame):
(WebCore::CoordinatedGraphicsOperation::RequestAnimationFrame::create):
(WebCore::CoordinatedGraphicsOperation::RequestAnimationFrame::RequestAnimationFrame):
(CreateCanvas):
(WebCore::CoordinatedGraphicsOperation::CreateCanvas::create):
(WebCore::CoordinatedGraphicsOperation::CreateCanvas::CreateCanvas):
(SyncCanvas):
(WebCore::CoordinatedGraphicsOperation::SyncCanvas::create):
(WebCore::CoordinatedGraphicsOperation::SyncCanvas::SyncCanvas):
(DestroyCanvas):
(WebCore::CoordinatedGraphicsOperation::DestroyCanvas::create):
(WebCore::CoordinatedGraphicsOperation::DestroyCanvas::DestroyCanvas):
(SetLayerFilters):
(WebCore::CoordinatedGraphicsOperation::SetLayerFilters::create):
(WebCore::CoordinatedGraphicsOperation::SetLayerFilters::SetLayerFilters):
(CreateCustomFilterProgram):
(WebCore::CoordinatedGraphicsOperation::CreateCustomFilterProgram::create):
(WebCore::CoordinatedGraphicsOperation::CreateCustomFilterProgram::CreateCustomFilterProgram):
(RemoveCustomFilterProgram):
(WebCore::CoordinatedGraphicsOperation::RemoveCustomFilterProgram::create):
(WebCore::CoordinatedGraphicsOperation::RemoveCustomFilterProgram::RemoveCustomFilterProgram):
(SetLayerRepaintCount):
(WebCore::CoordinatedGraphicsOperation::SetLayerRepaintCount::create):
(WebCore::CoordinatedGraphicsOperation::SetLayerRepaintCount::SetLayerRepaintCount):
(SetBackgroundColor):
(WebCore::CoordinatedGraphicsOperation::SetBackgroundColor::create):
(WebCore::CoordinatedGraphicsOperation::SetBackgroundColor::SetBackgroundColor):
(DidChangeScrollPosition):
(WebCore::CoordinatedGraphicsOperation::DidChangeScrollPosition::create):
(WebCore::CoordinatedGraphicsOperation::DidChangeScrollPosition::DidChangeScrollPosition):
(Queue):
(WebCore::CoordinatedGraphicsOperation::Queue::~Queue):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsOperations.h: Added.
(WebCore):
(CoordinatedGraphicsOperations):
(WebCore::CoordinatedGraphicsOperations::append):
(WebCore::CoordinatedGraphicsOperations::clear):
(WebCore::CoordinatedGraphicsOperations::isEmpty):
(WebCore::CoordinatedGraphicsOperations::size):
(WebCore::CoordinatedGraphicsOperations::at):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::didChangeScrollPosition):
    Remove m_pendingRenderedContentsScrollPosition because
    didChangeScrollPosition() is called at the moment of flushing.
(WebCore::CoordinatedGraphicsScene::commitCoordinatedGraphicsOperations):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
(WebCore):
(CoordinatedGraphicsScene):
(WebCore::CoordinatedGraphicsScene::setDrawsBackground):
* platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
(WebCore::CoordinatedImageBacking::create):
(WebCore::CoordinatedImageBacking::CoordinatedImageBacking):
(WebCore::CoordinatedImageBacking::removeHost):
(WebCore::CoordinatedImageBacking::update):
    FIXME: We don't deal with the case when sending an
    UpdateImageBacking operation fails because enqueueing an operation
    is async.
(WebCore::CoordinatedImageBacking::clearContentsTimerFired):
* platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
(CoordinatedImageBacking):
* platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h:
* platform/graphics/texmap/coordinated/UpdateAtlas.cpp:
(WebCore::UpdateAtlas::UpdateAtlas):
    FIXME: We don't deal with the case when sending a CreateUpdateAtlas
    operation fails because enqueueing an operation is async.
(WebCore::UpdateAtlas::~UpdateAtlas):
(WebCore::UpdateAtlas::beginPaintingOnAvailableBuffer):
* platform/graphics/texmap/coordinated/UpdateAtlas.h:
(WebCore):
(UpdateAtlas):

Source/WebKit2:

There are two changes in WK2.
1. Change CoordinatedLayerTreeHostProxy to use CoordinatedGraphicsOperation.
2. Add encode/decode of CoordinatedGraphicsOperation in
CoordinatedGraphicsArgumentCoders.

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
    Encoding UpdateImageBacking and CreateUpdateAtlas can fail when
    encoding WebCoordinatedSurface::Handle fails, but we don't
    recover in the case.
(CoreIPC):
(CoreIPC::::decode):
* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h:
(WebCore):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
(WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsOperations):
(WebKit::CoordinatedLayerTreeHostProxy::setAnimationsLocked):
(WebKit):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
(WebCore):
(CoordinatedLayerTreeHostProxy):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
(WebKit::CoordinatedLayerTreeHost::createCompositingLayers):
(WebKit::CoordinatedLayerTreeHost::deleteCompositingLayers):
(WebKit::CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded):
(WebKit::CoordinatedLayerTreeHost::checkCustomFilterProgramProxies):
(WebKit::CoordinatedLayerTreeHost::removeCustomFilterProgramProxy):
(WebKit::CoordinatedLayerTreeHost::enqueue):
(WebKit::CoordinatedLayerTreeHost::willEnqueueOperation):
(WebKit):
(WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
(WebKit::CoordinatedLayerTreeHost::setBackgroundColor):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
(CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::operationQueue):
Unifdef CoordGfx stuff
CG - Double buffering v2 (rebased)
Merge graphics operations