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_
10 #include "cc/resources/resource_format.h"
11 #include "cc/resources/transferable_resource.h"
12 #include "content/renderer/gpu/compositor_output_surface.h"
13 #include "ui/gfx/size.h"
16 class CompositorFrameAck;
21 // Implementation of CompositorOutputSurface that renders to textures which
22 // are sent to the browser through the mailbox extension.
23 // This class can be created only on the main thread, but then becomes pinned
24 // to a fixed thread when bindToClient is called.
25 class MailboxOutputSurface : public CompositorOutputSurface {
29 uint32 output_surface_id,
30 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
31 scoped_ptr<cc::SoftwareOutputDevice> software_device,
32 cc::ResourceFormat format);
33 virtual ~MailboxOutputSurface();
35 // cc::OutputSurface implementation.
36 virtual void EnsureBackbuffer() OVERRIDE;
37 virtual void DiscardBackbuffer() OVERRIDE;
38 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE;
39 virtual void BindFramebuffer() OVERRIDE;
40 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
43 // CompositorOutputSurface overrides.
44 virtual void OnSwapAck(uint32 output_surface_id,
45 const cc::CompositorFrameAck& ack) OVERRIDE;
47 size_t GetNumAcksPending();
49 struct TransferableFrame {
50 TransferableFrame() : texture_id(0), sync_point(0) {}
52 TransferableFrame(uint32 texture_id,
53 const gpu::Mailbox& mailbox,
55 : texture_id(texture_id), mailbox(mailbox), size(size), sync_point(0) {}
63 TransferableFrame current_backing_;
64 std::deque<TransferableFrame> pending_textures_;
65 std::queue<TransferableFrame> returned_textures_;
68 bool is_backbuffer_discarded_;
69 cc::ResourceFormat format_;
72 } // namespace content
74 #endif // CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_