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

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

Issue 1269503007: Unify graphics buffer format & usage enums for GpuMemoryBuffer & SurfaceFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add header to BUILD.gn Created 5 years, 4 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" 9 #include "content/common/android/surface_texture_manager.h"
10 #include "ui/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
11 11
12 namespace content { 12 namespace content {
13 namespace { 13 namespace {
14 14
15 int WindowFormat(gfx::GpuMemoryBuffer::Format format) { 15 int WindowFormat(gfx::BufferFormat format) {
16 switch (format) { 16 switch (format) {
17 case gfx::GpuMemoryBuffer::RGBA_8888: 17 case gfx::BufferFormat::RGBA_8888:
18 return WINDOW_FORMAT_RGBA_8888; 18 return WINDOW_FORMAT_RGBA_8888;
19 case gfx::GpuMemoryBuffer::ATC: 19 case gfx::BufferFormat::ATC:
20 case gfx::GpuMemoryBuffer::ATCIA: 20 case gfx::BufferFormat::ATCIA:
21 case gfx::GpuMemoryBuffer::DXT1: 21 case gfx::BufferFormat::DXT1:
22 case gfx::GpuMemoryBuffer::DXT5: 22 case gfx::BufferFormat::DXT5:
23 case gfx::GpuMemoryBuffer::ETC1: 23 case gfx::BufferFormat::ETC1:
24 case gfx::GpuMemoryBuffer::R_8: 24 case gfx::BufferFormat::R_8:
25 case gfx::GpuMemoryBuffer::RGBA_4444: 25 case gfx::BufferFormat::RGBA_4444:
26 case gfx::GpuMemoryBuffer::RGBX_8888: 26 case gfx::BufferFormat::RGBX_8888:
27 case gfx::GpuMemoryBuffer::BGRA_8888: 27 case gfx::BufferFormat::BGRA_8888:
28 case gfx::GpuMemoryBuffer::YUV_420: 28 case gfx::BufferFormat::YUV_420:
29 NOTREACHED(); 29 NOTREACHED();
30 return 0; 30 return 0;
31 } 31 }
32 32
33 NOTREACHED(); 33 NOTREACHED();
34 return 0; 34 return 0;
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( 39 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture(
40 gfx::GpuMemoryBufferId id, 40 gfx::GpuMemoryBufferId id,
41 const gfx::Size& size, 41 const gfx::Size& size,
42 Format format, 42 gfx::BufferFormat format,
43 const DestructionCallback& callback, 43 const DestructionCallback& callback,
44 ANativeWindow* native_window) 44 ANativeWindow* native_window)
45 : GpuMemoryBufferImpl(id, size, format, callback), 45 : GpuMemoryBufferImpl(id, size, format, callback),
46 native_window_(native_window), 46 native_window_(native_window),
47 stride_(0) { 47 stride_(0) {}
48 }
49 48
50 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { 49 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() {
51 ANativeWindow_release(native_window_); 50 ANativeWindow_release(native_window_);
52 } 51 }
53 52
54 // static 53 // static
55 scoped_ptr<GpuMemoryBufferImpl> 54 scoped_ptr<GpuMemoryBufferImpl>
56 GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( 55 GpuMemoryBufferImplSurfaceTexture::CreateFromHandle(
57 const gfx::GpuMemoryBufferHandle& handle, 56 const gfx::GpuMemoryBufferHandle& handle,
58 const gfx::Size& size, 57 const gfx::Size& size,
59 Format format, 58 gfx::BufferFormat format,
60 const DestructionCallback& callback) { 59 const DestructionCallback& callback) {
61 ANativeWindow* native_window = SurfaceTextureManager::GetInstance()-> 60 ANativeWindow* native_window = SurfaceTextureManager::GetInstance()->
62 AcquireNativeWidgetForSurfaceTexture(handle.id); 61 AcquireNativeWidgetForSurfaceTexture(handle.id);
63 if (!native_window) 62 if (!native_window)
64 return scoped_ptr<GpuMemoryBufferImpl>(); 63 return scoped_ptr<GpuMemoryBufferImpl>();
65 64
66 ANativeWindow_setBuffersGeometry( 65 ANativeWindow_setBuffersGeometry(
67 native_window, size.width(), size.height(), WindowFormat(format)); 66 native_window, size.width(), size.height(), WindowFormat(format));
68 67
69 return make_scoped_ptr<GpuMemoryBufferImpl>( 68 return make_scoped_ptr<GpuMemoryBufferImpl>(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 108
110 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() 109 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle()
111 const { 110 const {
112 gfx::GpuMemoryBufferHandle handle; 111 gfx::GpuMemoryBufferHandle handle;
113 handle.type = gfx::SURFACE_TEXTURE_BUFFER; 112 handle.type = gfx::SURFACE_TEXTURE_BUFFER;
114 handle.id = id_; 113 handle.id = id_;
115 return handle; 114 return handle;
116 } 115 }
117 116
118 } // namespace content 117 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698