1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_
6 #define CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h"
11 #include "cc/base/scoped_ptr_vector.h"
12 #include "cc/layers/layer_impl.h"
15 class DelegatedFrameData
;
18 class CC_EXPORT DelegatedRendererLayerImpl
: public LayerImpl
{
20 static scoped_ptr
<DelegatedRendererLayerImpl
> Create(
21 LayerTreeImpl
* tree_impl
, int id
) {
22 return make_scoped_ptr(new DelegatedRendererLayerImpl(tree_impl
, id
));
24 ~DelegatedRendererLayerImpl() override
;
26 // LayerImpl overrides.
27 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
28 bool HasDelegatedContent() const override
;
29 bool HasContributingDelegatedRenderPasses() const override
;
30 RenderPassId
FirstContributingRenderPassId() const override
;
31 RenderPassId
NextContributingRenderPassId(
32 RenderPassId previous
) const override
;
33 void ReleaseResources() override
;
34 bool WillDraw(DrawMode draw_mode
,
35 ResourceProvider
* resource_provider
) override
;
36 void AppendQuads(RenderPass
* render_pass
,
37 const Occlusion
& occlusion_in_content_space
,
38 AppendQuadsData
* append_quads_data
) override
;
39 void PushPropertiesTo(LayerImpl
* layer
) override
;
41 void AppendContributingRenderPasses(RenderPassSink
* render_pass_sink
);
43 // Creates an ID with the resource provider for the child renderer
44 // that will be sending quads to the layer. Registers the callback to
45 // inform when resources are no longer in use.
46 void CreateChildIdIfNeeded(const ReturnCallback
& return_callback
);
48 void SetFrameData(const DelegatedFrameData
* frame_data
,
49 const gfx::RectF
& damage_in_frame
);
51 float inverse_device_scale_factor() const {
52 return inverse_device_scale_factor_
;
56 DelegatedRendererLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
58 int ChildIdForTesting() const { return child_id_
; }
59 const RenderPassList
& RenderPassesInDrawOrderForTesting() const {
60 return render_passes_in_draw_order_
;
62 const ResourceProvider::ResourceIdArray
& ResourcesForTesting() const {
69 void AppendRainbowDebugBorder(RenderPass
* render_pass
,
70 AppendQuadsData
* append_quads_data
);
72 void SetRenderPasses(RenderPassList
* render_passes_in_draw_order
);
73 void ClearRenderPasses();
75 // Returns |true| if the delegated_render_pass_id is part of the current
76 // frame and can be converted.
77 bool ConvertDelegatedRenderPassId(RenderPassId delegated_render_pass_id
,
78 RenderPassId
* output_render_pass_id
) const;
80 void AppendRenderPassQuads(RenderPass
* render_pass
,
81 const Occlusion
& occlusion_in_content_space
,
82 AppendQuadsData
* append_quads_data
,
83 const RenderPass
* delegated_render_pass
,
84 const gfx::Size
& frame_size
) const;
86 // LayerImpl overrides.
87 const char* LayerTypeAsString() const override
;
89 bool have_render_passes_to_push_
;
90 float inverse_device_scale_factor_
;
91 RenderPassList render_passes_in_draw_order_
;
92 base::hash_map
<RenderPassId
, int> render_passes_index_by_id_
;
93 ResourceProvider::ResourceIdArray resources_
;
98 DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayerImpl
);
103 #endif // CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_