| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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/client/gpu_memory_buffer_impl_ozone.h" |
| 6 |
| 7 #include "base/debug/trace_event.h" |
| 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" |
| 9 #include "ui/gl/gl_bindings.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( |
| 14 gfx::GpuMemoryBufferHandle handle, |
| 15 gfx::Size size, |
| 16 unsigned internalformat, |
| 17 gfx::GpuMemoryBuffer::Usage usage) { |
| 18 switch (handle.type) { |
| 19 case gfx::SHARED_MEMORY_BUFFER: { |
| 20 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
| 21 new GpuMemoryBufferImplShm(size, internalformat)); |
| 22 if (!buffer->Initialize(handle)) |
| 23 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 24 |
| 25 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 26 } |
| 27 case gfx::OZONE_NATIVE_BUFFER: { |
| 28 scoped_ptr<GpuMemoryBufferImplOzone> buffer( |
| 29 new GpuMemoryBufferImplOzone(size, internalformat, usage)); |
| 30 if (!buffer->Initialize(handle)) |
| 31 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 32 |
| 33 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 34 } |
| 35 default: |
| 36 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 37 } |
| 38 } |
| 39 |
| 40 // static |
| 41 bool GpuMemoryBufferImplOzone::IsFormatSupported(unsigned internalformat) { |
| 42 switch (internalformat) { |
| 43 case GL_RGBA8_OES: |
| 44 return true; |
| 45 default: |
| 46 return false; |
| 47 } |
| 48 } |
| 49 |
| 50 GpuMemoryBufferImplOzone::GpuMemoryBufferImplOzone( |
| 51 gfx::Size size, |
| 52 unsigned internalformat, |
| 53 gfx::GpuMemoryBuffer::Usage usage) |
| 54 : GpuMemoryBufferImpl(size, internalformat, usage) { |
| 55 } |
| 56 |
| 57 GpuMemoryBufferImplOzone::~GpuMemoryBufferImplOzone() { |
| 58 } |
| 59 |
| 60 bool GpuMemoryBufferImplOzone::Initialize(gfx::GpuMemoryBufferHandle handle) { |
| 61 TRACE_EVENT0("gpu", "GpuMemoryBufferImplOzone::Initialize"); |
| 62 return true; |
| 63 } |
| 64 |
| 65 void* GpuMemoryBufferImplOzone::Map() { |
| 66 TRACE_EVENT0("gpu", "GpuMemoryBufferImplOzone::Map"); |
| 67 NOTREACHED(); |
| 68 return NULL; |
| 69 } |
| 70 |
| 71 void GpuMemoryBufferImplOzone::Unmap() { |
| 72 TRACE_EVENT0("gpu", "GpuMemoryBufferImplOzone::Unmap"); |
| 73 NOTREACHED(); |
| 74 } |
| 75 |
| 76 uint32 GpuMemoryBufferImplOzone::GetStride() const { |
| 77 return 0; |
| 78 } |
| 79 |
| 80 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzone::GetHandle() const { |
| 81 gfx::GpuMemoryBufferHandle handle; |
| 82 handle.type = gfx::OZONE_NATIVE_BUFFER; |
| 83 return handle; |
| 84 } |
| 85 |
| 86 } // namespace content |
| OLD | NEW |