#ifndef CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_
#define CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_
#include "base/containers/hash_tables.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h"
#include "cc/layers/layer_impl.h"
namespace cc {
class DelegatedFrameData;
class RenderPassSink;
class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl {
public:
static scoped_ptr<DelegatedRendererLayerImpl> Create(
LayerTreeImpl* tree_impl, int id) {
return make_scoped_ptr(new DelegatedRendererLayerImpl(tree_impl, id));
}
virtual ~DelegatedRendererLayerImpl();
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
virtual bool HasDelegatedContent() const OVERRIDE;
virtual bool HasContributingDelegatedRenderPasses() const OVERRIDE;
virtual RenderPass::Id FirstContributingRenderPassId() const OVERRIDE;
virtual RenderPass::Id NextContributingRenderPassId(
RenderPass::Id previous) const OVERRIDE;
virtual void ReleaseResources() OVERRIDE;
virtual bool WillDraw(DrawMode draw_mode,
ResourceProvider* resource_provider) OVERRIDE;
virtual void AppendQuads(QuadSink* quad_sink,
AppendQuadsData* append_quads_data) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
void AppendContributingRenderPasses(RenderPassSink* render_pass_sink);
void CreateChildIdIfNeeded(const ReturnCallback& return_callback);
void SetFrameData(const DelegatedFrameData* frame_data,
const gfx::RectF& damage_in_frame);
void SetDisplaySize(const gfx::Size& size);
protected:
DelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, int id);
int ChildIdForTesting() const { return child_id_; }
const ScopedPtrVector<RenderPass>& RenderPassesInDrawOrderForTesting() const {
return render_passes_in_draw_order_;
}
const ResourceProvider::ResourceIdArray& ResourcesForTesting() const {
return resources_;
}
private:
void ClearChildId();
void AppendRainbowDebugBorder(QuadSink* quad_sink,
AppendQuadsData* append_quads_data);
void SetRenderPasses(
ScopedPtrVector<RenderPass>* render_passes_in_draw_order);
void ClearRenderPasses();
bool ConvertDelegatedRenderPassId(
RenderPass::Id delegated_render_pass_id,
RenderPass::Id* output_render_pass_id) const;
gfx::Transform DelegatedFrameToLayerSpaceTransform(
const gfx::Size& frame_size) const;
void AppendRenderPassQuads(
QuadSink* quad_sink,
AppendQuadsData* append_quads_data,
const RenderPass* delegated_render_pass,
const gfx::Size& frame_size) const;
virtual const char* LayerTypeAsString() const OVERRIDE;
bool have_render_passes_to_push_;
ScopedPtrVector<RenderPass> render_passes_in_draw_order_;
base::hash_map<RenderPass::Id, int> render_passes_index_by_id_;
ResourceProvider::ResourceIdArray resources_;
gfx::Size display_size_;
int child_id_;
bool own_child_id_;
DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayerImpl);
};
}
#endif