OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "content/common/gpu/gpu_memory_buffer_factory.h" | |
6 | |
7 #include "ui/gl/gl_image.h" | |
8 #include "ui/gl/gl_image_shared_memory.h" | |
9 #include "ui/gl/gl_image_surface_texture.h" | |
10 | |
11 namespace content { | |
12 namespace { | |
13 | |
14 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { | |
15 public: | |
16 // Overridden from GpuMemoryBufferFactory: | |
17 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | |
18 const gfx::GpuMemoryBufferHandle& handle, | |
19 const gfx::Size& size, | |
20 unsigned internalformat, | |
21 unsigned usage) OVERRIDE { | |
22 NOTREACHED(); | |
alexst (slow to review)
2014/07/11 19:50:03
Maybe NOTIMPLEMENTED() is better? It could be reac
danakj
2014/07/11 20:20:24
I'd agree if the renderer process can cause this,
reveman
2014/07/11 21:08:06
There's no missing implementation here as the brow
| |
23 return gfx::GpuMemoryBufferHandle(); | |
24 } | |
25 virtual void DestroyGpuMemoryBuffer( | |
26 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE { | |
27 NOTREACHED(); | |
28 } | |
29 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | |
30 const gfx::GpuMemoryBufferHandle& handle, | |
31 const gfx::Size& size, | |
32 unsigned internalformat, | |
33 int client_id) OVERRIDE { | |
34 switch (handle.type) { | |
35 case gfx::SHARED_MEMORY_BUFFER: { | |
36 scoped_refptr<gfx::GLImageSharedMemory> image( | |
37 new gfx::GLImageSharedMemory(size, internalformat)); | |
38 if (!image->Initialize(handle)) | |
39 return NULL; | |
40 | |
41 return image; | |
42 } | |
43 case gfx::SURFACE_TEXTURE_BUFFER: { | |
44 scoped_refptr<gfx::GLImageSurfaceTexture> image( | |
45 new gfx::GLImageSurfaceTexture(size)); | |
46 if (!image->Initialize(handle)) | |
47 return NULL; | |
48 | |
49 return image; | |
50 } | |
51 default: | |
52 NOTREACHED(); | |
53 return scoped_refptr<gfx::GLImage>(); | |
54 } | |
55 } | |
56 }; | |
57 | |
58 } // namespace | |
59 | |
60 // static | |
61 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | |
62 return make_scoped_ptr<GpuMemoryBufferFactory>( | |
63 new GpuMemoryBufferFactoryImpl); | |
64 } | |
65 | |
66 } // namespace content | |
OLD | NEW |