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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return WINDOW_FORMAT_RGBA_8888; | 29 return WINDOW_FORMAT_RGBA_8888; |
30 default: | 30 default: |
31 NOTREACHED(); | 31 NOTREACHED(); |
32 return 0; | 32 return 0; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( | 36 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( |
37 gfx::Size size, | 37 gfx::Size size, |
38 unsigned internalformat) | 38 unsigned internalformat) |
39 : GpuMemoryBufferImpl(size, internalformat), | 39 : GpuMemoryBufferImpl(size, |
| 40 internalformat, |
| 41 gfx::GpuMemoryBuffer::READ_WRITE), |
40 native_window_(NULL), | 42 native_window_(NULL), |
41 stride_(0u) {} | 43 stride_(0u) { |
| 44 } |
42 | 45 |
43 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { | 46 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { |
44 if (native_window_) | 47 if (native_window_) |
45 ANativeWindow_release(native_window_); | 48 ANativeWindow_release(native_window_); |
46 } | 49 } |
47 | 50 |
48 bool GpuMemoryBufferImplSurfaceTexture::Initialize( | 51 bool GpuMemoryBufferImplSurfaceTexture::Initialize( |
49 gfx::GpuMemoryBufferHandle handle) { | 52 gfx::GpuMemoryBufferHandle handle) { |
50 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Initialize"); | 53 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Initialize"); |
51 | 54 |
52 DCHECK(!native_window_); | 55 DCHECK(!native_window_); |
53 native_window_ = SurfaceTextureLookup::GetInstance()->AcquireNativeWidget( | 56 native_window_ = SurfaceTextureLookup::GetInstance()->AcquireNativeWidget( |
54 handle.surface_texture_id.primary_id, | 57 handle.surface_texture_id.primary_id, |
55 handle.surface_texture_id.secondary_id); | 58 handle.surface_texture_id.secondary_id); |
56 if (!native_window_) | 59 if (!native_window_) |
57 return false; | 60 return false; |
58 | 61 |
59 ANativeWindow_setBuffersGeometry(native_window_, | 62 ANativeWindow_setBuffersGeometry(native_window_, |
60 size_.width(), | 63 size_.width(), |
61 size_.height(), | 64 size_.height(), |
62 WindowFormat(internalformat_)); | 65 WindowFormat(internalformat_)); |
63 | 66 |
64 surface_texture_id_ = handle.surface_texture_id; | 67 surface_texture_id_ = handle.surface_texture_id; |
65 return true; | 68 return true; |
66 } | 69 } |
67 | 70 |
68 void* GpuMemoryBufferImplSurfaceTexture::Map(AccessMode mode) { | 71 void* GpuMemoryBufferImplSurfaceTexture::Map() { |
69 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); | 72 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); |
70 | 73 |
71 DCHECK(!mapped_); | 74 DCHECK(!mapped_); |
72 DCHECK(native_window_); | 75 DCHECK(native_window_); |
73 ANativeWindow_Buffer buffer; | 76 ANativeWindow_Buffer buffer; |
74 int status = ANativeWindow_lock(native_window_, &buffer, NULL); | 77 int status = ANativeWindow_lock(native_window_, &buffer, NULL); |
75 if (status) { | 78 if (status) { |
76 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; | 79 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; |
77 return NULL; | 80 return NULL; |
78 } | 81 } |
(...skipping 16 matching lines...) Expand all Loading... |
95 | 98 |
96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 99 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
97 const { | 100 const { |
98 gfx::GpuMemoryBufferHandle handle; | 101 gfx::GpuMemoryBufferHandle handle; |
99 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 102 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
100 handle.surface_texture_id = surface_texture_id_; | 103 handle.surface_texture_id = surface_texture_id_; |
101 return handle; | 104 return handle; |
102 } | 105 } |
103 | 106 |
104 } // namespace content | 107 } // namespace content |
OLD | NEW |