[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory_surface_texture.h
blob24679b06c574a702497e9e4958f3e4d8d4f52f24
1 // Copyright 2014 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_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_SURFACE_TEXTURE_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_SURFACE_TEXTURE_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h"
11 #include "content/common/gpu/gpu_memory_buffer_factory.h"
12 #include "gpu/command_buffer/service/image_factory.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/gpu_memory_buffer.h"
16 namespace gfx {
17 class GLImage;
18 class SurfaceTexture;
21 namespace content {
23 class GpuMemoryBufferFactorySurfaceTexture : public GpuMemoryBufferFactory,
24 public gpu::ImageFactory {
25 public:
26 GpuMemoryBufferFactorySurfaceTexture();
27 ~GpuMemoryBufferFactorySurfaceTexture() override;
29 static bool IsGpuMemoryBufferConfigurationSupported(
30 gfx::GpuMemoryBuffer::Format format,
31 gfx::GpuMemoryBuffer::Usage usage);
33 // Overridden from GpuMemoryBufferFactory:
34 void GetSupportedGpuMemoryBufferConfigurations(
35 std::vector<Configuration>* configurations) override;
36 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
37 gfx::GpuMemoryBufferId id,
38 const gfx::Size& size,
39 gfx::GpuMemoryBuffer::Format format,
40 gfx::GpuMemoryBuffer::Usage usage,
41 int client_id,
42 gfx::PluginWindowHandle surface_handle) override;
43 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
44 int client_id) override;
45 gpu::ImageFactory* AsImageFactory() override;
47 // Overridden from gpu::ImageFactory:
48 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
49 const gfx::GpuMemoryBufferHandle& handle,
50 const gfx::Size& size,
51 gfx::GpuMemoryBuffer::Format format,
52 unsigned internalformat,
53 int client_id) override;
55 private:
56 typedef std::pair<int, int> SurfaceTextureMapKey;
57 typedef base::hash_map<SurfaceTextureMapKey,
58 scoped_refptr<gfx::SurfaceTexture>> SurfaceTextureMap;
59 SurfaceTextureMap surface_textures_;
60 base::Lock surface_textures_lock_;
63 } // namespace content
65 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_SURFACE_TEXTURE_H_