Fix app list and overflow icon drawing problems
[chromium-blink-merge.git] / gpu / ipc / command_buffer_proxy.h
blob156d28dd856ae18ffa6ff4c4f731aa536394f8f1
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 GPU_IPC_COMMAND_BUFFER_PROXY_H_
6 #define GPU_IPC_COMMAND_BUFFER_PROXY_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "gpu/command_buffer/common/command_buffer_shared.h"
14 struct GpuMemoryAllocationForRenderer;
16 // Client side proxy that forwards messages synchronously to a
17 // CommandBufferStub.
18 class GPU_EXPORT CommandBufferProxy : public gpu::CommandBuffer {
19 public:
20 typedef base::Callback<void(
21 const std::string& msg, int id)> GpuConsoleMessageCallback;
23 CommandBufferProxy() { }
25 virtual ~CommandBufferProxy() { }
27 virtual int GetRouteID() const = 0;
29 // Invoke the task when the channel has been flushed. Takes care of deleting
30 // the task whether the echo succeeds or not.
31 virtual bool Echo(const base::Closure& callback) = 0;
33 // Sends an IPC message with the new state of surface visibility.
34 virtual bool SetSurfaceVisible(bool visible) = 0;
36 virtual bool DiscardBackbuffer() = 0;
37 virtual bool EnsureBackbuffer() = 0;
39 // Inserts a sync point, returning its ID. This is handled on the IO thread of
40 // the GPU process, and so should be relatively fast, but its effect is
41 // ordered wrt other messages (in particular, Flush). Sync point IDs are
42 // global and can be used for cross-channel synchronization.
43 virtual uint32 InsertSyncPoint() = 0;
45 // Makes this command buffer wait on a sync point. This command buffer will be
46 // unscheduled until the command buffer that inserted that sync point reaches
47 // it, or gets destroyed.
48 virtual void WaitSyncPoint(uint32) = 0;
50 // Makes this command buffer invoke a task when a sync point is reached, or
51 // the command buffer that inserted that sync point is destroyed.
52 virtual bool SignalSyncPoint(uint32 sync_point,
53 const base::Closure& callback) = 0;
55 // Register a callback to invoke whenever we recieve a new memory allocation.
56 virtual void SetMemoryAllocationChangedCallback(
57 const base::Callback<void(const GpuMemoryAllocationForRenderer&)>&
58 callback) = 0;
60 // Reparent a command buffer. TODO(apatrick): going forward, the notion of
61 // the parent / child relationship between command buffers is going away in
62 // favor of the notion of surfaces that can be drawn to in one command buffer
63 // and bound as a texture in any other.
64 virtual bool SetParent(CommandBufferProxy* parent_command_buffer,
65 uint32 parent_texture_id) = 0;
67 virtual void SetChannelErrorCallback(const base::Closure& callback) = 0;
69 // Set a task that will be invoked the next time the window becomes invalid
70 // and needs to be repainted. Takes ownership of task.
71 virtual void SetNotifyRepaintTask(const base::Closure& callback) = 0;
73 virtual void SetOnConsoleMessageCallback(
74 const GpuConsoleMessageCallback& callback) = 0;
76 private:
77 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy);
80 #endif // GPU_IPC_COMMAND_BUFFER_PROXY_H_