surface.h revision 116680a4aac90f2aa7413d9095a592090648e557
1// Copyright 2014 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_SURFACES_SURFACE_H_
6#define CC_SURFACES_SURFACE_H_
7
8#include "base/containers/hash_tables.h"
9#include "base/macros.h"
10#include "base/memory/scoped_ptr.h"
11#include "cc/surfaces/surface_id.h"
12#include "cc/surfaces/surfaces_export.h"
13#include "ui/gfx/size.h"
14
15namespace cc {
16class CompositorFrame;
17class SurfaceManager;
18class SurfaceFactory;
19class SurfaceResourceHolder;
20
21class CC_SURFACES_EXPORT Surface {
22 public:
23  Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory);
24  ~Surface();
25
26  const gfx::Size& size() const { return size_; }
27  SurfaceId surface_id() const { return surface_id_; }
28
29  void QueueFrame(scoped_ptr<CompositorFrame> frame);
30  // Returns the most recent frame that is eligible to be rendered.
31  CompositorFrame* GetEligibleFrame();
32
33  SurfaceFactory* factory() { return factory_; }
34
35 private:
36  SurfaceId surface_id_;
37  gfx::Size size_;
38  SurfaceFactory* factory_;
39  // TODO(jamesr): Support multiple frames in flight.
40  scoped_ptr<CompositorFrame> current_frame_;
41
42  DISALLOW_COPY_AND_ASSIGN(Surface);
43};
44
45}  // namespace cc
46
47#endif  // CC_SURFACES_SURFACE_H_
48