OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ |
6 #define CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ | 6 #define CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <queue> | 11 #include <queue> |
9 | 12 |
10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
11 #include "cc/resources/resource_format.h" | 14 #include "cc/resources/resource_format.h" |
12 #include "cc/resources/transferable_resource.h" | 15 #include "cc/resources/transferable_resource.h" |
13 #include "content/renderer/gpu/compositor_output_surface.h" | 16 #include "content/renderer/gpu/compositor_output_surface.h" |
14 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
15 | 18 |
16 namespace cc { | 19 namespace cc { |
17 class CompositorFrameAck; | 20 class CompositorFrameAck; |
18 } | 21 } |
19 | 22 |
20 namespace content { | 23 namespace content { |
21 class FrameSwapMessageQueue; | 24 class FrameSwapMessageQueue; |
22 | 25 |
23 // Implementation of CompositorOutputSurface that renders to textures which | 26 // Implementation of CompositorOutputSurface that renders to textures which |
24 // are sent to the browser through the mailbox extension. | 27 // are sent to the browser through the mailbox extension. |
25 // This class can be created only on the main thread, but then becomes pinned | 28 // This class can be created only on the main thread, but then becomes pinned |
26 // to a fixed thread when bindToClient is called. | 29 // to a fixed thread when bindToClient is called. |
27 class MailboxOutputSurface : public CompositorOutputSurface { | 30 class MailboxOutputSurface : public CompositorOutputSurface { |
28 public: | 31 public: |
29 MailboxOutputSurface( | 32 MailboxOutputSurface( |
30 int32 routing_id, | 33 int32_t routing_id, |
31 uint32 output_surface_id, | 34 uint32_t output_surface_id, |
32 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 35 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
33 const scoped_refptr<ContextProviderCommandBuffer>& | 36 const scoped_refptr<ContextProviderCommandBuffer>& |
34 worker_context_provider, | 37 worker_context_provider, |
35 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue, | 38 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue, |
36 cc::ResourceFormat format); | 39 cc::ResourceFormat format); |
37 ~MailboxOutputSurface() override; | 40 ~MailboxOutputSurface() override; |
38 | 41 |
39 // cc::OutputSurface implementation. | 42 // cc::OutputSurface implementation. |
40 void DetachFromClient() override; | 43 void DetachFromClient() override; |
41 void EnsureBackbuffer() override; | 44 void EnsureBackbuffer() override; |
42 void DiscardBackbuffer() override; | 45 void DiscardBackbuffer() override; |
43 void Reshape(const gfx::Size& size, float scale_factor, bool alpha) override; | 46 void Reshape(const gfx::Size& size, float scale_factor, bool alpha) override; |
44 void BindFramebuffer() override; | 47 void BindFramebuffer() override; |
45 void SwapBuffers(cc::CompositorFrame* frame) override; | 48 void SwapBuffers(cc::CompositorFrame* frame) override; |
46 | 49 |
47 private: | 50 private: |
48 // CompositorOutputSurface overrides. | 51 // CompositorOutputSurface overrides. |
49 void OnSwapAck(uint32 output_surface_id, | 52 void OnSwapAck(uint32_t output_surface_id, |
50 const cc::CompositorFrameAck& ack) override; | 53 const cc::CompositorFrameAck& ack) override; |
51 | 54 |
52 size_t GetNumAcksPending(); | 55 size_t GetNumAcksPending(); |
53 | 56 |
54 struct TransferableFrame { | 57 struct TransferableFrame { |
55 TransferableFrame(); | 58 TransferableFrame(); |
56 TransferableFrame(uint32 texture_id, | 59 TransferableFrame(uint32_t texture_id, |
57 const gpu::Mailbox& mailbox, | 60 const gpu::Mailbox& mailbox, |
58 const gfx::Size size); | 61 const gfx::Size size); |
59 | 62 |
60 uint32 texture_id; | 63 uint32_t texture_id; |
61 gpu::Mailbox mailbox; | 64 gpu::Mailbox mailbox; |
62 gpu::SyncToken sync_token; | 65 gpu::SyncToken sync_token; |
63 gfx::Size size; | 66 gfx::Size size; |
64 }; | 67 }; |
65 | 68 |
66 TransferableFrame current_backing_; | 69 TransferableFrame current_backing_; |
67 std::deque<TransferableFrame> pending_textures_; | 70 std::deque<TransferableFrame> pending_textures_; |
68 std::queue<TransferableFrame> returned_textures_; | 71 std::queue<TransferableFrame> returned_textures_; |
69 | 72 |
70 uint32 fbo_; | 73 uint32_t fbo_; |
71 bool is_backbuffer_discarded_; | 74 bool is_backbuffer_discarded_; |
72 cc::ResourceFormat format_; | 75 cc::ResourceFormat format_; |
73 }; | 76 }; |
74 | 77 |
75 } // namespace content | 78 } // namespace content |
76 | 79 |
77 #endif // CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ | 80 #endif // CONTENT_RENDERER_GPU_MAILBOX_OUTPUT_SURFACE_H_ |
OLD | NEW |