Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / layers / delegated_renderer_layer_impl.h
blobe26450d500e3f94edead7f93352c7c8c61d1b179
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"
14 namespace cc {
15 class DelegatedFrameData;
16 class RenderPassSink;
18 class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl {
19 public:
20 static scoped_ptr<DelegatedRendererLayerImpl> Create(
21 LayerTreeImpl* tree_impl, int id) {
22 return make_scoped_ptr(new DelegatedRendererLayerImpl(tree_impl, id));
24 virtual ~DelegatedRendererLayerImpl();
26 // LayerImpl overrides.
27 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
28 OVERRIDE;
29 virtual bool HasDelegatedContent() const OVERRIDE;
30 virtual bool HasContributingDelegatedRenderPasses() const OVERRIDE;
31 virtual RenderPass::Id FirstContributingRenderPassId() const OVERRIDE;
32 virtual RenderPass::Id NextContributingRenderPassId(
33 RenderPass::Id previous) const OVERRIDE;
34 virtual void ReleaseResources() OVERRIDE;
35 virtual bool WillDraw(DrawMode draw_mode,
36 ResourceProvider* resource_provider) OVERRIDE;
37 virtual void AppendQuads(RenderPass* render_pass,
38 const OcclusionTracker<LayerImpl>& occlusion_tracker,
39 AppendQuadsData* append_quads_data) OVERRIDE;
40 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
42 void AppendContributingRenderPasses(RenderPassSink* render_pass_sink);
44 // Creates an ID with the resource provider for the child renderer
45 // that will be sending quads to the layer. Registers the callback to
46 // inform when resources are no longer in use.
47 void CreateChildIdIfNeeded(const ReturnCallback& return_callback);
49 void SetFrameData(const DelegatedFrameData* frame_data,
50 const gfx::RectF& damage_in_frame);
52 float inverse_device_scale_factor() const {
53 return inverse_device_scale_factor_;
56 protected:
57 DelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, int id);
59 int ChildIdForTesting() const { return child_id_; }
60 const RenderPassList& RenderPassesInDrawOrderForTesting() const {
61 return render_passes_in_draw_order_;
63 const ResourceProvider::ResourceIdArray& ResourcesForTesting() const {
64 return resources_;
67 private:
68 void ClearChildId();
70 void AppendRainbowDebugBorder(RenderPass* render_pass,
71 AppendQuadsData* append_quads_data);
73 void SetRenderPasses(RenderPassList* render_passes_in_draw_order);
74 void ClearRenderPasses();
76 // Returns |true| if the delegated_render_pass_id is part of the current
77 // frame and can be converted.
78 bool ConvertDelegatedRenderPassId(
79 RenderPass::Id delegated_render_pass_id,
80 RenderPass::Id* output_render_pass_id) const;
82 void AppendRenderPassQuads(
83 RenderPass* render_pass,
84 const OcclusionTracker<LayerImpl>& occlusion_tracker,
85 AppendQuadsData* append_quads_data,
86 const RenderPass* delegated_render_pass,
87 const gfx::Size& frame_size) const;
89 // LayerImpl overrides.
90 virtual const char* LayerTypeAsString() const OVERRIDE;
92 bool have_render_passes_to_push_;
93 float inverse_device_scale_factor_;
94 RenderPassList render_passes_in_draw_order_;
95 base::hash_map<RenderPass::Id, int> render_passes_index_by_id_;
96 ResourceProvider::ResourceIdArray resources_;
98 int child_id_;
99 bool own_child_id_;
101 DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayerImpl);
104 } // namespace cc
106 #endif // CC_LAYERS_DELEGATED_RENDERER_LAYER_IMPL_H_