summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/transfer_buffer_manager.h
blob: 9f24e2cd3ba12c09db4ff72d6e877895e4739b4d (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
// 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 GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
#define GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_

#include <set>
#include <vector>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/shared_memory.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"

namespace gpu {

class GPU_EXPORT TransferBufferManagerInterface {
 public:
  virtual ~TransferBufferManagerInterface();

  virtual int32 CreateTransferBuffer(size_t size, int32 id_request) = 0;
  virtual int32 RegisterTransferBuffer(
      base::SharedMemory* shared_memory,
      size_t size,
      int32 id_request) = 0;
  virtual void DestroyTransferBuffer(int32 id) = 0;
  virtual Buffer GetTransferBuffer(int32 handle) = 0;

};

class GPU_EXPORT TransferBufferManager
    : public TransferBufferManagerInterface {
 public:
  TransferBufferManager();

  bool Initialize();
  virtual int32 CreateTransferBuffer(size_t size, int32 id_request) OVERRIDE;
  virtual int32 RegisterTransferBuffer(
      base::SharedMemory* shared_memory,
      size_t size,
      int32 id_request) OVERRIDE;
  virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
  virtual Buffer GetTransferBuffer(int32 handle) OVERRIDE;

 private:
  virtual ~TransferBufferManager();

  std::set<int32> unused_registered_object_elements_;
  std::vector<Buffer> registered_objects_;
  size_t shared_memory_bytes_allocated_;

  DISALLOW_COPY_AND_ASSIGN(TransferBufferManager);
};

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_