Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / gpu / mailbox_output_surface.h
blob8ba90b4be41d2afce7f656fc6d2223f314334ad4
1 // Copyright (c) 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 CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_
6 #define CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_
8 #include <queue>
10 #include "base/memory/ref_counted.h"
11 #include "cc/resources/resource_format.h"
12 #include "cc/resources/transferable_resource.h"
13 #include "content/renderer/gpu/compositor_output_surface.h"
14 #include "ui/gfx/size.h"
16 namespace cc {
17 class CompositorFrameAck;
20 namespace content {
21 class FrameSwapMessageQueue;
23 // Implementation of CompositorOutputSurface that renders to textures which
24 // are sent to the browser through the mailbox extension.
25 // This class can be created only on the main thread, but then becomes pinned
26 // to a fixed thread when bindToClient is called.
27 class MailboxOutputSurface : public CompositorOutputSurface {
28 public:
29 MailboxOutputSurface(
30 int32 routing_id,
31 uint32 output_surface_id,
32 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
33 scoped_ptr<cc::SoftwareOutputDevice> software_device,
34 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue,
35 cc::ResourceFormat format);
36 virtual ~MailboxOutputSurface();
38 // cc::OutputSurface implementation.
39 virtual void EnsureBackbuffer() OVERRIDE;
40 virtual void DiscardBackbuffer() OVERRIDE;
41 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE;
42 virtual void BindFramebuffer() OVERRIDE;
43 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
45 private:
46 // CompositorOutputSurface overrides.
47 virtual void OnSwapAck(uint32 output_surface_id,
48 const cc::CompositorFrameAck& ack) OVERRIDE;
50 size_t GetNumAcksPending();
52 struct TransferableFrame {
53 TransferableFrame() : texture_id(0), sync_point(0) {}
55 TransferableFrame(uint32 texture_id,
56 const gpu::Mailbox& mailbox,
57 const gfx::Size size)
58 : texture_id(texture_id), mailbox(mailbox), size(size), sync_point(0) {}
60 uint32 texture_id;
61 gpu::Mailbox mailbox;
62 gfx::Size size;
63 uint32 sync_point;
66 TransferableFrame current_backing_;
67 std::deque<TransferableFrame> pending_textures_;
68 std::queue<TransferableFrame> returned_textures_;
70 uint32 fbo_;
71 bool is_backbuffer_discarded_;
72 cc::ResourceFormat format_;
75 } // namespace content
77 #endif // CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_