Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1841)

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc

Issue 1770073002: SurfaceTexture* => gpu/ipc/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restored BUILD.gn bits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/common/android/surface_texture_manager.h"
10 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" 9 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
10 #include "gpu/ipc/common/android/surface_texture_manager.h"
11 #include "ui/gfx/buffer_format_util.h" 11 #include "ui/gfx/buffer_format_util.h"
12 #include "ui/gl/android/surface_texture.h" 12 #include "ui/gl/android/surface_texture.h"
13 #include "ui/gl/gl_bindings.h" 13 #include "ui/gl/gl_bindings.h"
14 14
15 namespace content { 15 namespace content {
16 namespace { 16 namespace {
17 17
18 int WindowFormat(gfx::BufferFormat format) { 18 int WindowFormat(gfx::BufferFormat format) {
19 switch (format) { 19 switch (format) {
20 case gfx::BufferFormat::RGBA_8888: 20 case gfx::BufferFormat::RGBA_8888:
(...skipping 15 matching lines...) Expand all
36 return 0; 36 return 0;
37 } 37 }
38 38
39 NOTREACHED(); 39 NOTREACHED();
40 return 0; 40 return 0;
41 } 41 }
42 42
43 void FreeSurfaceTextureForTesting( 43 void FreeSurfaceTextureForTesting(
44 scoped_refptr<gfx::SurfaceTexture> surface_texture, 44 scoped_refptr<gfx::SurfaceTexture> surface_texture,
45 gfx::GpuMemoryBufferId id) { 45 gfx::GpuMemoryBufferId id) {
46 SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, 0); 46 gpu::SurfaceTextureManager::GetInstance()->UnregisterSurfaceTexture(id.id, 0);
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( 51 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture(
52 gfx::GpuMemoryBufferId id, 52 gfx::GpuMemoryBufferId id,
53 const gfx::Size& size, 53 const gfx::Size& size,
54 gfx::BufferFormat format, 54 gfx::BufferFormat format,
55 const DestructionCallback& callback, 55 const DestructionCallback& callback,
56 ANativeWindow* native_window) 56 ANativeWindow* native_window)
57 : GpuMemoryBufferImpl(id, size, format, callback), 57 : GpuMemoryBufferImpl(id, size, format, callback),
58 native_window_(native_window) {} 58 native_window_(native_window) {}
59 59
60 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { 60 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() {
61 ANativeWindow_release(native_window_); 61 ANativeWindow_release(native_window_);
62 } 62 }
63 63
64 // static 64 // static
65 scoped_ptr<GpuMemoryBufferImplSurfaceTexture> 65 scoped_ptr<GpuMemoryBufferImplSurfaceTexture>
66 GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( 66 GpuMemoryBufferImplSurfaceTexture::CreateFromHandle(
67 const gfx::GpuMemoryBufferHandle& handle, 67 const gfx::GpuMemoryBufferHandle& handle,
68 const gfx::Size& size, 68 const gfx::Size& size,
69 gfx::BufferFormat format, 69 gfx::BufferFormat format,
70 gfx::BufferUsage usage, 70 gfx::BufferUsage usage,
71 const DestructionCallback& callback) { 71 const DestructionCallback& callback) {
72 ANativeWindow* native_window = 72 ANativeWindow* native_window =
73 SurfaceTextureManager::GetInstance() 73 gpu::SurfaceTextureManager::GetInstance()
74 ->AcquireNativeWidgetForSurfaceTexture(handle.id.id); 74 ->AcquireNativeWidgetForSurfaceTexture(handle.id.id);
75 if (!native_window) 75 if (!native_window)
76 return nullptr; 76 return nullptr;
77 77
78 ANativeWindow_setBuffersGeometry( 78 ANativeWindow_setBuffersGeometry(
79 native_window, size.width(), size.height(), WindowFormat(format)); 79 native_window, size.width(), size.height(), WindowFormat(format));
80 80
81 return make_scoped_ptr(new GpuMemoryBufferImplSurfaceTexture( 81 return make_scoped_ptr(new GpuMemoryBufferImplSurfaceTexture(
82 handle.id, size, format, callback, native_window)); 82 handle.id, size, format, callback, native_window));
83 } 83 }
84 84
85 // static 85 // static
86 bool GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported( 86 bool GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(
87 gfx::BufferFormat format, 87 gfx::BufferFormat format,
88 gfx::BufferUsage usage) { 88 gfx::BufferUsage usage) {
89 return GpuMemoryBufferFactorySurfaceTexture:: 89 return GpuMemoryBufferFactorySurfaceTexture::
90 IsGpuMemoryBufferConfigurationSupported(format, usage); 90 IsGpuMemoryBufferConfigurationSupported(format, usage);
91 } 91 }
92 92
93 // static 93 // static
94 base::Closure GpuMemoryBufferImplSurfaceTexture::AllocateForTesting( 94 base::Closure GpuMemoryBufferImplSurfaceTexture::AllocateForTesting(
95 const gfx::Size& size, 95 const gfx::Size& size,
96 gfx::BufferFormat format, 96 gfx::BufferFormat format,
97 gfx::BufferUsage usage, 97 gfx::BufferUsage usage,
98 gfx::GpuMemoryBufferHandle* handle) { 98 gfx::GpuMemoryBufferHandle* handle) {
99 scoped_refptr<gfx::SurfaceTexture> surface_texture = 99 scoped_refptr<gfx::SurfaceTexture> surface_texture =
100 gfx::SurfaceTexture::Create(0); 100 gfx::SurfaceTexture::Create(0);
101 DCHECK(surface_texture); 101 DCHECK(surface_texture);
102 const gfx::GpuMemoryBufferId kBufferId(1); 102 const gfx::GpuMemoryBufferId kBufferId(1);
103 SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture( 103 gpu::SurfaceTextureManager::GetInstance()->RegisterSurfaceTexture(
104 kBufferId.id, 0, surface_texture.get()); 104 kBufferId.id, 0, surface_texture.get());
105 handle->type = gfx::SURFACE_TEXTURE_BUFFER; 105 handle->type = gfx::SURFACE_TEXTURE_BUFFER;
106 handle->id = kBufferId; 106 handle->id = kBufferId;
107 return base::Bind(&FreeSurfaceTextureForTesting, surface_texture, kBufferId); 107 return base::Bind(&FreeSurfaceTextureForTesting, surface_texture, kBufferId);
108 } 108 }
109 109
110 bool GpuMemoryBufferImplSurfaceTexture::Map() { 110 bool GpuMemoryBufferImplSurfaceTexture::Map() {
111 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map"); 111 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Map");
112 DCHECK(!mapped_); 112 DCHECK(!mapped_);
113 DCHECK(native_window_); 113 DCHECK(native_window_);
(...skipping 28 matching lines...) Expand all
142 142
143 gfx::GpuMemoryBufferHandle 143 gfx::GpuMemoryBufferHandle
144 GpuMemoryBufferImplSurfaceTexture::GetHandle() const { 144 GpuMemoryBufferImplSurfaceTexture::GetHandle() const {
145 gfx::GpuMemoryBufferHandle handle; 145 gfx::GpuMemoryBufferHandle handle;
146 handle.type = gfx::SURFACE_TEXTURE_BUFFER; 146 handle.type = gfx::SURFACE_TEXTURE_BUFFER;
147 handle.id = id_; 147 handle.id = id_;
148 return handle; 148 return handle;
149 } 149 }
150 150
151 } // namespace content 151 } // namespace content
OLDNEW
« no previous file with comments | « content/common/android/surface_texture_peer.cc ('k') | content/common/gpu/gpu_memory_buffer_factory_surface_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698