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

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

Issue 1062853002: Add gfx::GpuMemoryBuffer::YUV_420 and GpuMemoryBufferImplSharedMemory support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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::GpuMemoryBuffer::Format format) {
16 switch (format) { 16 switch (format) {
17 case gfx::GpuMemoryBuffer::RGBA_8888: 17 case gfx::GpuMemoryBuffer::RGBA_8888:
18 return WINDOW_FORMAT_RGBA_8888; 18 return WINDOW_FORMAT_RGBA_8888;
19 case gfx::GpuMemoryBuffer::ATC: 19 case gfx::GpuMemoryBuffer::ATC:
20 case gfx::GpuMemoryBuffer::ATCIA: 20 case gfx::GpuMemoryBuffer::ATCIA:
21 case gfx::GpuMemoryBuffer::DXT1: 21 case gfx::GpuMemoryBuffer::DXT1:
22 case gfx::GpuMemoryBuffer::DXT5: 22 case gfx::GpuMemoryBuffer::DXT5:
23 case gfx::GpuMemoryBuffer::ETC1: 23 case gfx::GpuMemoryBuffer::ETC1:
24 case gfx::GpuMemoryBuffer::RGBX_8888: 24 case gfx::GpuMemoryBuffer::RGBX_8888:
25 case gfx::GpuMemoryBuffer::BGRA_8888: 25 case gfx::GpuMemoryBuffer::BGRA_8888:
26 case gfx::GpuMemoryBuffer::YUV_420:
26 NOTREACHED(); 27 NOTREACHED();
27 return 0; 28 return 0;
28 } 29 }
29 30
30 NOTREACHED(); 31 NOTREACHED();
31 return 0; 32 return 0;
32 } 33 }
33 34
34 } // namespace 35 } // namespace
35 36
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 DCHECK(!mapped_); 75 DCHECK(!mapped_);
75 DCHECK(native_window_); 76 DCHECK(native_window_);
76 ANativeWindow_Buffer buffer; 77 ANativeWindow_Buffer buffer;
77 int status = ANativeWindow_lock(native_window_, &buffer, NULL); 78 int status = ANativeWindow_lock(native_window_, &buffer, NULL);
78 if (status) { 79 if (status) {
79 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; 80 VLOG(1) << "ANativeWindow_lock failed with error code: " << status;
80 return false; 81 return false;
81 } 82 }
82 83
83 size_t stride_in_bytes = 0; 84 size_t stride_in_bytes = 0;
84 if (!StrideInBytes(buffer.stride, format_, &stride_in_bytes)) 85 if (!StrideInBytes(buffer.stride, format_, 0, &stride_in_bytes))
85 return false; 86 return false;
86 87
87 DCHECK_LE(size_.width(), buffer.stride); 88 DCHECK_LE(size_.width(), buffer.stride);
88 stride_ = stride_in_bytes; 89 stride_ = stride_in_bytes;
89 mapped_ = true; 90 mapped_ = true;
90 *data = buffer.bits; 91 *data = buffer.bits;
91 return true; 92 return true;
92 } 93 }
93 94
94 void GpuMemoryBufferImplSurfaceTexture::Unmap() { 95 void GpuMemoryBufferImplSurfaceTexture::Unmap() {
(...skipping 10 matching lines...) Expand all
105 106
106 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() 107 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle()
107 const { 108 const {
108 gfx::GpuMemoryBufferHandle handle; 109 gfx::GpuMemoryBufferHandle handle;
109 handle.type = gfx::SURFACE_TEXTURE_BUFFER; 110 handle.type = gfx::SURFACE_TEXTURE_BUFFER;
110 handle.id = id_; 111 handle.id = id_;
111 return handle; 112 return handle;
112 } 113 }
113 114
114 } // namespace content 115 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698