Add remoting and PPAPI tests to GN build
[chromium-blink-merge.git] / content / browser / android / in_process / synchronous_compositor_output_surface.h
blob584bedc864f4725a1f94379821d42d690c30bb04
1 // Copyright 2013 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_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "cc/output/compositor_frame.h"
16 #include "cc/output/managed_memory_policy.h"
17 #include "cc/output/output_surface.h"
18 #include "content/public/browser/android/synchronous_compositor.h"
19 #include "ipc/ipc_message.h"
20 #include "ui/gfx/transform.h"
22 namespace cc {
23 class ContextProvider;
24 class CompositorFrameMetadata;
27 namespace IPC {
28 class Message;
31 namespace content {
33 class FrameSwapMessageQueue;
34 class SynchronousCompositorClient;
35 class SynchronousCompositorExternalBeginFrameSource;
36 class SynchronousCompositorOutputSurface;
37 class WebGraphicsContext3DCommandBufferImpl;
39 // Specialization of the output surface that adapts it to implement the
40 // content::SynchronousCompositor public API. This class effects an "inversion
41 // of control" - enabling drawing to be orchestrated by the embedding
42 // layer, instead of driven by the compositor internals - hence it holds two
43 // 'client' pointers (|client_| in the OutputSurface baseclass and
44 // |delegate_|) which represent the consumers of the two roles in plays.
45 // This class can be created only on the main thread, but then becomes pinned
46 // to a fixed thread when BindToClient is called.
47 class SynchronousCompositorOutputSurface
48 : NON_EXPORTED_BASE(public cc::OutputSurface) {
49 public:
50 explicit SynchronousCompositorOutputSurface(
51 int routing_id,
52 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue);
53 ~SynchronousCompositorOutputSurface() override;
55 // OutputSurface.
56 bool BindToClient(cc::OutputSurfaceClient* surface_client) override;
57 void Reshape(const gfx::Size& size, float scale_factor) override;
58 void SwapBuffers(cc::CompositorFrame* frame) override;
60 void SetBeginFrameSource(
61 SynchronousCompositorExternalBeginFrameSource* begin_frame_source);
63 // Partial SynchronousCompositor API implementation.
64 bool InitializeHwDraw(
65 scoped_refptr<cc::ContextProvider> onscreen_context_provider,
66 scoped_refptr<cc::ContextProvider> worker_context_provider);
67 void ReleaseHwDraw();
68 scoped_ptr<cc::CompositorFrame> DemandDrawHw(
69 gfx::Size surface_size,
70 const gfx::Transform& transform,
71 gfx::Rect viewport,
72 gfx::Rect clip,
73 gfx::Rect viewport_rect_for_tile_priority,
74 const gfx::Transform& transform_for_tile_priority);
75 void ReturnResources(const cc::CompositorFrameAck& frame_ack);
76 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas);
77 void SetMemoryPolicy(size_t bytes_limit);
78 void SetTreeActivationCallback(const base::Closure& callback);
79 void GetMessagesToDeliver(ScopedVector<IPC::Message>* messages);
81 private:
82 class SoftwareDevice;
83 friend class SoftwareDevice;
85 void InvokeComposite(const gfx::Transform& transform,
86 gfx::Rect viewport,
87 gfx::Rect clip,
88 gfx::Rect viewport_rect_for_tile_priority,
89 gfx::Transform transform_for_tile_priority,
90 bool hardware_draw);
91 bool CalledOnValidThread() const;
93 const int routing_id_;
94 bool registered_;
96 gfx::Transform cached_hw_transform_;
97 gfx::Rect cached_hw_viewport_;
98 gfx::Rect cached_hw_clip_;
99 gfx::Rect cached_hw_viewport_rect_for_tile_priority_;
100 gfx::Transform cached_hw_transform_for_tile_priority_;
102 // Only valid (non-NULL) during a DemandDrawSw() call.
103 SkCanvas* current_sw_canvas_;
105 cc::ManagedMemoryPolicy memory_policy_;
107 cc::OutputSurfaceClient* output_surface_client_;
108 scoped_ptr<cc::CompositorFrame> frame_holder_;
110 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
112 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_;
114 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface);
117 } // namespace content
119 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_