summaryrefslogtreecommitdiff
path: root/content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h
blob: 15d91530e62198a13876dcd641fbdffe4e25ed88 (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
// Copyright 2014 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 CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_
#define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_

#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/x/x11_types.h"

namespace gfx {
class GLImage;
}

namespace content {

class GpuMemoryBufferFactoryX11Pixmap {
 public:
  GpuMemoryBufferFactoryX11Pixmap();
  ~GpuMemoryBufferFactoryX11Pixmap();

  // Create a GPU memory buffer for an existing X11 pixmap.
  void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferId& id, XID pixmap);

  // Destroy a previously created GPU memory buffer.
  void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferId& id);

  // Creates a GLImage instance for a GPU memory buffer.
  scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
      const gfx::GpuMemoryBufferId& id,
      const gfx::Size& size,
      unsigned internalformat);

 private:
  typedef std::pair<int, int> X11PixmapMapKey;
  typedef base::hash_map<X11PixmapMapKey, XID> X11PixmapMap;
  X11PixmapMap pixmaps_;
};

}  // namespace content

#endif  // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_