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.
5 #ifndef CC_SURFACES_SURFACE_H_
6 #define CC_SURFACES_SURFACE_H_
11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "cc/base/scoped_ptr_vector.h"
17 #include "cc/output/copy_output_request.h"
18 #include "cc/quads/render_pass_id.h"
19 #include "cc/surfaces/surface_id.h"
20 #include "cc/surfaces/surfaces_export.h"
21 #include "ui/gfx/geometry/size.h"
28 class CompositorFrame
;
29 class CopyOutputRequest
;
32 class SurfaceResourceHolder
;
34 class CC_SURFACES_EXPORT Surface
{
36 Surface(SurfaceId id
, const gfx::Size
& size
, SurfaceFactory
* factory
);
39 const gfx::Size
& size() const { return size_
; }
40 SurfaceId
surface_id() const { return surface_id_
; }
42 void QueueFrame(scoped_ptr
<CompositorFrame
> frame
,
43 const base::Closure
& draw_callback
);
44 void RequestCopyOfOutput(scoped_ptr
<CopyOutputRequest
> copy_request
);
45 // Adds each CopyOutputRequest in the current frame to copy_requests. The
46 // caller takes ownership of them.
47 void TakeCopyOutputRequests(
48 std::multimap
<RenderPassId
, CopyOutputRequest
*>* copy_requests
);
49 // Returns the most recent frame that is eligible to be rendered.
50 const CompositorFrame
* GetEligibleFrame();
52 // Returns a number that increments by 1 every time a new frame is enqueued.
53 int frame_index() const { return frame_index_
; }
55 void TakeLatencyInfo(std::vector
<ui::LatencyInfo
>* latency_info
);
56 void RunDrawCallbacks();
58 base::WeakPtr
<SurfaceFactory
> factory() { return factory_
; }
61 void ClearCopyRequests();
63 SurfaceId surface_id_
;
65 base::WeakPtr
<SurfaceFactory
> factory_
;
66 // TODO(jamesr): Support multiple frames in flight.
67 scoped_ptr
<CompositorFrame
> current_frame_
;
70 base::Closure draw_callback_
;
72 DISALLOW_COPY_AND_ASSIGN(Surface
);
77 #endif // CC_SURFACES_SURFACE_H_