Revert of Copy the contents of the ASan/Win blacklist to work around http://llvm...
[chromium-blink-merge.git] / content / renderer / gpu / compositor_output_surface.h
bloba8e1764e64833d415ff8c6c7d389a0a6745f143a
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_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h"
16 #include "cc/output/begin_frame_args.h"
17 #include "cc/output/output_surface.h"
18 #include "content/renderer/gpu/compositor_forwarding_message_filter.h"
19 #include "ipc/ipc_sync_message_filter.h"
21 namespace IPC {
22 class Message;
25 namespace cc {
26 class CompositorFrame;
27 class CompositorFrameAck;
28 class GLFrameData;
29 class SoftwareFrameData;
32 namespace content {
33 class ContextProviderCommandBuffer;
34 class FrameSwapMessageQueue;
36 // This class can be created only on the main thread, but then becomes pinned
37 // to a fixed thread when bindToClient is called.
38 class CompositorOutputSurface
39 : NON_EXPORTED_BASE(public cc::OutputSurface),
40 NON_EXPORTED_BASE(public base::NonThreadSafe) {
41 public:
42 CompositorOutputSurface(
43 int32 routing_id,
44 uint32 output_surface_id,
45 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
46 scoped_ptr<cc::SoftwareOutputDevice> software,
47 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue,
48 bool use_swap_compositor_frame_message);
49 ~CompositorOutputSurface() override;
51 // cc::OutputSurface implementation.
52 bool BindToClient(cc::OutputSurfaceClient* client) override;
53 void SwapBuffers(cc::CompositorFrame* frame) override;
55 // TODO(epenner): This seems out of place here and would be a better fit
56 // int CompositorThread after it is fully refactored (http://crbug/170828)
57 void UpdateSmoothnessTakesPriority(bool prefer_smoothness) override;
59 protected:
60 void ShortcutSwapAck(uint32 output_surface_id,
61 scoped_ptr<cc::GLFrameData> gl_frame_data,
62 scoped_ptr<cc::SoftwareFrameData> software_frame_data);
63 virtual void OnSwapAck(uint32 output_surface_id,
64 const cc::CompositorFrameAck& ack);
65 virtual void OnReclaimResources(uint32 output_surface_id,
66 const cc::CompositorFrameAck& ack);
67 uint32 output_surface_id_;
69 private:
70 class CompositorOutputSurfaceProxy :
71 public base::RefCountedThreadSafe<CompositorOutputSurfaceProxy> {
72 public:
73 explicit CompositorOutputSurfaceProxy(
74 CompositorOutputSurface* output_surface)
75 : output_surface_(output_surface) {}
76 void ClearOutputSurface() { output_surface_ = NULL; }
77 void OnMessageReceived(const IPC::Message& message) {
78 if (output_surface_)
79 output_surface_->OnMessageReceived(message);
82 private:
83 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>;
84 ~CompositorOutputSurfaceProxy() {}
85 CompositorOutputSurface* output_surface_;
87 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy);
90 void OnMessageReceived(const IPC::Message& message);
91 void OnUpdateVSyncParametersFromBrowser(base::TimeTicks timebase,
92 base::TimeDelta interval);
93 bool Send(IPC::Message* message);
95 bool use_swap_compositor_frame_message_;
97 scoped_refptr<CompositorForwardingMessageFilter> output_surface_filter_;
98 CompositorForwardingMessageFilter::Handler output_surface_filter_handler_;
99 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_;
100 scoped_refptr<IPC::SyncMessageFilter> message_sender_;
101 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
102 int routing_id_;
103 bool prefers_smoothness_;
104 base::PlatformThreadHandle main_thread_handle_;
106 // TODO(danakj): Remove this when crbug.com/311404
107 bool layout_test_mode_;
108 scoped_ptr<cc::CompositorFrameAck> layout_test_previous_frame_ack_;
109 base::WeakPtrFactory<CompositorOutputSurface> weak_ptrs_;
112 } // namespace content
114 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_