delegated_renderer_layer.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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.
4
5#ifndef CC_LAYERS_DELEGATED_RENDERER_LAYER_H_
6#define CC_LAYERS_DELEGATED_RENDERER_LAYER_H_
7
8#include "cc/base/cc_export.h"
9#include "cc/layers/layer.h"
10#include "cc/resources/returned_resource.h"
11
12namespace cc {
13
14class DelegatedFrameData;
15class DelegatedRendererLayerClient;
16
17class CC_EXPORT DelegatedRendererLayer : public Layer {
18 public:
19  static scoped_refptr<DelegatedRendererLayer> Create(
20      DelegatedRendererLayerClient* client);
21
22  virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
23      OVERRIDE;
24  virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
25  virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE;
26  virtual bool DrawsContent() const OVERRIDE;
27
28  // Set the size at which the frame should be displayed, with the origin at the
29  // layer's origin. This must always contain at least the layer's bounds. A
30  // value of (0, 0) implies that the frame should be displayed to fit exactly
31  // in the layer's bounds.
32  void SetDisplaySize(gfx::Size size);
33
34  void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data);
35
36  // Passes ownership of any unused resources that had been given by the child
37  // compositor to the given array, so they can be given back to the child.
38  void TakeUnusedResourcesForChildCompositor(ReturnedResourceArray* array);
39
40 protected:
41  explicit DelegatedRendererLayer(DelegatedRendererLayerClient* client);
42  virtual ~DelegatedRendererLayer();
43
44 private:
45  scoped_ptr<DelegatedFrameData> frame_data_;
46  gfx::RectF damage_in_frame_;
47  gfx::Size frame_size_;
48  gfx::Size display_size_;
49  ReturnedResourceArray unused_resources_for_child_compositor_;
50
51  DelegatedRendererLayerClient* client_;
52
53  DISALLOW_COPY_AND_ASSIGN(DelegatedRendererLayer);
54};
55
56}  // namespace cc
57#endif  // CC_LAYERS_DELEGATED_RENDERER_LAYER_H_
58