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

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

Issue 255713008: Change glimage to accept a type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_io_surface.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/io_surface_support_mac.h" 9 #include "ui/gl/io_surface_support_mac.h"
10 10
(...skipping 13 matching lines...) Expand all
24 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { 24 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) {
25 switch (internalformat) { 25 switch (internalformat) {
26 case GL_BGRA8_EXT: 26 case GL_BGRA8_EXT:
27 return true; 27 return true;
28 default: 28 default:
29 return false; 29 return false;
30 } 30 }
31 } 31 }
32 32
33 // static 33 // static
34 bool GpuMemoryBufferImplIOSurface::IsUsageSupported(unsigned usage) {
35 switch (usage) {
36 case GL_IMAGE_MAP_CHROMIUM:
37 return true;
38 default:
39 return false;
40 }
41 }
42
43 // static
34 uint32 GpuMemoryBufferImplIOSurface::PixelFormat(unsigned internalformat) { 44 uint32 GpuMemoryBufferImplIOSurface::PixelFormat(unsigned internalformat) {
35 switch (internalformat) { 45 switch (internalformat) {
36 case GL_BGRA8_EXT: 46 case GL_BGRA8_EXT:
37 return 'BGRA'; 47 return 'BGRA';
38 default: 48 default:
39 NOTREACHED(); 49 NOTREACHED();
40 return 0; 50 return 0;
41 } 51 }
42 } 52 }
43 53
44 bool GpuMemoryBufferImplIOSurface::Initialize( 54 bool GpuMemoryBufferImplIOSurface::Initialize(
45 gfx::GpuMemoryBufferHandle handle) { 55 gfx::GpuMemoryBufferHandle handle) {
46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); 56 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id));
47 if (!io_surface_) { 57 if (!io_surface_) {
48 VLOG(1) << "IOSurface lookup failed"; 58 VLOG(1) << "IOSurface lookup failed";
49 return false; 59 return false;
50 } 60 }
51 61
52 return true; 62 return true;
53 } 63 }
54 64
55 void* GpuMemoryBufferImplIOSurface::Map(AccessMode mode) { 65 void* GpuMemoryBufferImplIOSurface::Map() {
56 DCHECK(!mapped_); 66 DCHECK(!mapped_);
57 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL); 67 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL);
58 mapped_ = true; 68 mapped_ = true;
59 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_); 69 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_);
60 } 70 }
61 71
62 void GpuMemoryBufferImplIOSurface::Unmap() { 72 void GpuMemoryBufferImplIOSurface::Unmap() {
63 DCHECK(mapped_); 73 DCHECK(mapped_);
64 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL); 74 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL);
65 mapped_ = false; 75 mapped_ = false;
66 } 76 }
67 77
68 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { 78 uint32 GpuMemoryBufferImplIOSurface::GetStride() const {
69 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_); 79 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_);
70 } 80 }
71 81
72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 82 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
73 gfx::GpuMemoryBufferHandle handle; 83 gfx::GpuMemoryBufferHandle handle;
74 handle.type = gfx::IO_SURFACE_BUFFER; 84 handle.type = gfx::IO_SURFACE_BUFFER;
75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); 85 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_);
76 return handle; 86 return handle;
77 } 87 }
78 88
79 } // namespace content 89 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698