#ifndef InspectorLayerTreeAgent_h
#define InspectorLayerTreeAgent_h
#include "InspectorFrontend.h"
#include "InspectorTypeBuilder.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "core/rendering/RenderLayer.h"
#include "platform/Timer.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class InspectorDOMAgent;
class InstrumentingAgents;
class Page;
class RenderLayerCompositor;
struct LayerSnapshot;
typedef String ErrorString;
class InspectorLayerTreeAgent FINAL : public InspectorBaseAgent<InspectorLayerTreeAgent>, public InspectorBackendDispatcher::LayerTreeCommandHandler {
public:
static PassOwnPtr<InspectorLayerTreeAgent> create(InspectorDOMAgent* domAgent, Page* page)
{
return adoptPtr(new InspectorLayerTreeAgent(domAgent, page));
}
virtual ~InspectorLayerTreeAgent();
virtual void setFrontend(InspectorFrontend*) OVERRIDE;
virtual void clearFrontend() OVERRIDE;
virtual void restore() OVERRIDE;
void willAddPageOverlay(const GraphicsLayer*);
void didRemovePageOverlay(const GraphicsLayer*);
void layerTreeDidChange();
void didPaint(RenderObject*, const GraphicsLayer*, GraphicsContext*, const LayoutRect&);
virtual void enable(ErrorString*) OVERRIDE;
virtual void disable(ErrorString*) OVERRIDE;
virtual void compositingReasons(ErrorString*, const String& layerId, RefPtr<TypeBuilder::Array<String> >&) OVERRIDE;
virtual void makeSnapshot(ErrorString*, const String& layerId, String* snapshotId) OVERRIDE;
virtual void releaseSnapshot(ErrorString*, const String& snapshotId) OVERRIDE;
virtual void replaySnapshot(ErrorString*, const String& snapshotId, const int* fromStep, const int* toStep, String* dataURL) OVERRIDE;
virtual void profileSnapshot(ErrorString*, const String& snapshotId, const int* minRepeatCount, const double* minDuration, RefPtr<TypeBuilder::Array<TypeBuilder::Array<double> > >&) OVERRIDE;
PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > buildLayerTree(const String& nodeGroup);
private:
static unsigned s_lastSnapshotId;
InspectorLayerTreeAgent(InspectorDOMAgent*, Page*);
RenderLayerCompositor* renderLayerCompositor();
GraphicsLayer* layerById(ErrorString*, const String& layerId);
const LayerSnapshot* snapshotById(ErrorString*, const String& snapshotId);
typedef HashMap<int, int> LayerIdToNodeIdMap;
void buildLayerIdToNodeIdMap(RenderLayer*, const String& nodeGroup, LayerIdToNodeIdMap&);
void gatherGraphicsLayers(GraphicsLayer*, HashMap<int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> >&);
int idForNode(Node*, const String& nodeGroup);
InspectorFrontend::LayerTree* m_frontend;
Page* m_page;
InspectorDOMAgent* m_domAgent;
Vector<int, 2> m_pageOverlayLayerIds;
typedef HashMap<String, LayerSnapshot> SnapshotById;
SnapshotById m_snapshotById;
};
}
#endif