blob: 015ce38e132bbccec9c944a44103a5cf10333e59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_
#define PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_
#pragma once
#include "base/callback.h"
#include "base/hash_tables.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/host_resource.h"
#include "gpu/ipc/command_buffer_proxy.h"
namespace IPC {
class Message;
}
namespace ppapi {
namespace proxy {
class ProxyChannel;
class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public CommandBufferProxy {
public:
PpapiCommandBufferProxy(const HostResource& resource,
ProxyChannel* channel);
virtual ~PpapiCommandBufferProxy();
void ReportChannelError();
// CommandBufferProxy implementation:
virtual int GetRouteID() const OVERRIDE;
virtual bool Echo(const base::Closure& callback) OVERRIDE;
virtual bool SetSurfaceVisible(bool visible) OVERRIDE;
virtual bool DiscardBackbuffer() OVERRIDE;
virtual bool EnsureBackbuffer() OVERRIDE;
virtual void SetMemoryAllocationChangedCallback(
const base::Callback<void(const GpuMemoryAllocationForRenderer&)>&
callback) OVERRIDE;
virtual bool SetParent(CommandBufferProxy* parent_command_buffer,
uint32 parent_texture_id) OVERRIDE;
virtual void SetChannelErrorCallback(const base::Closure& callback) OVERRIDE;
virtual void SetNotifyRepaintTask(const base::Closure& callback) OVERRIDE;
virtual void SetOnConsoleMessageCallback(
const GpuConsoleMessageCallback& callback) OVERRIDE;
// gpu::CommandBuffer implementation:
virtual bool Initialize();
virtual State GetState();
virtual State GetLastState();
virtual void Flush(int32 put_offset);
virtual State FlushSync(int32 put_offset, int32 last_known_get);
virtual void SetGetBuffer(int32 transfer_buffer_id);
virtual void SetGetOffset(int32 get_offset);
virtual int32 CreateTransferBuffer(size_t size, int32 id_request);
virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory,
size_t size,
int32 id_request);
virtual void DestroyTransferBuffer(int32 id);
virtual gpu::Buffer GetTransferBuffer(int32 handle);
virtual void SetToken(int32 token);
virtual void SetParseError(gpu::error::Error error);
virtual void SetContextLostReason(gpu::error::ContextLostReason reason);
private:
bool Send(IPC::Message* msg);
void UpdateState(const gpu::CommandBuffer::State& state, bool success);
typedef base::hash_map<int32, gpu::Buffer> TransferBufferMap;
TransferBufferMap transfer_buffers_;
State last_state_;
HostResource resource_;
ProxyChannel* channel_;
base::Closure channel_error_callback_;
DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_
|