| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/common/android/surface_texture_lookup.h" | 9 #include "content/common/android/surface_texture_lookup.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported( | 15 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported( |
| 16 unsigned internalformat) { | 16 unsigned internalformat) { |
| 17 switch (internalformat) { | 17 switch (internalformat) { |
| 18 case GL_RGBA8_OES: | 18 case GL_RGBA8_OES: |
| 19 return true; | 19 return true; |
| 20 default: | 20 default: |
| 21 return false; | 21 return false; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 bool GpuMemoryBufferImplSurfaceTexture::IsUsageSupported(unsigned usage) { |
| 27 switch (usage) { |
| 28 case GL_IMAGE_MAP_CHROMIUM: |
| 29 return true; |
| 30 default: |
| 31 return false; |
| 32 } |
| 33 } |
| 34 |
| 35 // static |
| 26 int GpuMemoryBufferImplSurfaceTexture::WindowFormat(unsigned internalformat) { | 36 int GpuMemoryBufferImplSurfaceTexture::WindowFormat(unsigned internalformat) { |
| 27 switch (internalformat) { | 37 switch (internalformat) { |
| 28 case GL_RGBA8_OES: | 38 case GL_RGBA8_OES: |
| 29 return WINDOW_FORMAT_RGBA_8888; | 39 return WINDOW_FORMAT_RGBA_8888; |
| 30 default: | 40 default: |
| 31 NOTREACHED(); | 41 NOTREACHED(); |
| 32 return 0; | 42 return 0; |
| 33 } | 43 } |
| 34 } | 44 } |
| 35 | 45 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 | 68 |
| 59 ANativeWindow_setBuffersGeometry(native_window_, | 69 ANativeWindow_setBuffersGeometry(native_window_, |
| 60 size_.width(), | 70 size_.width(), |
| 61 size_.height(), | 71 size_.height(), |
| 62 WindowFormat(internalformat_)); | 72 WindowFormat(internalformat_)); |
| 63 | 73 |
| 64 surface_texture_id_ = handle.surface_texture_id; | 74 surface_texture_id_ = handle.surface_texture_id; |
| 65 return true; | 75 return true; |
| 66 } | 76 } |
| 67 | 77 |
| 68 void* GpuMemoryBufferImplSurfaceTexture::Map(AccessMode mode) { | 78 void* GpuMemoryBufferImplSurfaceTexture::Map() { |
| 69 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); | 79 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); |
| 70 | 80 |
| 71 DCHECK(!mapped_); | 81 DCHECK(!mapped_); |
| 72 DCHECK(native_window_); | 82 DCHECK(native_window_); |
| 73 ANativeWindow_Buffer buffer; | 83 ANativeWindow_Buffer buffer; |
| 74 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 84 int status = ANativeWindow_lock(native_window_, &buffer, NULL); |
| 75 if (status) { | 85 if (status) { |
| 76 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; | 86 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; |
| 77 return NULL; | 87 return NULL; |
| 78 } | 88 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 95 | 105 |
| 96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 106 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
| 97 const { | 107 const { |
| 98 gfx::GpuMemoryBufferHandle handle; | 108 gfx::GpuMemoryBufferHandle handle; |
| 99 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 109 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
| 100 handle.surface_texture_id = surface_texture_id_; | 110 handle.surface_texture_id = surface_texture_id_; |
| 101 return handle; | 111 return handle; |
| 102 } | 112 } |
| 103 | 113 |
| 104 } // namespace content | 114 } // namespace content |
| OLD | NEW |