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

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: no ozone 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
11 namespace content { 11 namespace content {
12 12
13 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( 13 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface(
14 gfx::Size size, 14 gfx::Size size,
15 unsigned internalformat) 15 unsigned internalformat)
16 : GpuMemoryBufferImpl(size, internalformat), 16 : GpuMemoryBufferImpl(size,
17 internalformat,
18 gfx::GpuMemoryBuffer::READ_WRITE),
17 io_surface_support_(IOSurfaceSupport::Initialize()) { 19 io_surface_support_(IOSurfaceSupport::Initialize()) {
18 CHECK(io_surface_support_); 20 CHECK(io_surface_support_);
19 } 21 }
20 22
21 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} 23 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {}
22 24
23 // static 25 // static
24 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { 26 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) {
25 switch (internalformat) { 27 switch (internalformat) {
26 case GL_BGRA8_EXT: 28 case GL_BGRA8_EXT:
(...skipping 18 matching lines...) Expand all
45 gfx::GpuMemoryBufferHandle handle) { 47 gfx::GpuMemoryBufferHandle handle) {
46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); 48 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id));
47 if (!io_surface_) { 49 if (!io_surface_) {
48 VLOG(1) << "IOSurface lookup failed"; 50 VLOG(1) << "IOSurface lookup failed";
49 return false; 51 return false;
50 } 52 }
51 53
52 return true; 54 return true;
53 } 55 }
54 56
55 void* GpuMemoryBufferImplIOSurface::Map(AccessMode mode) { 57 void* GpuMemoryBufferImplIOSurface::Map() {
56 DCHECK(!mapped_); 58 DCHECK(!mapped_);
57 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL); 59 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL);
58 mapped_ = true; 60 mapped_ = true;
59 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_); 61 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_);
60 } 62 }
61 63
62 void GpuMemoryBufferImplIOSurface::Unmap() { 64 void GpuMemoryBufferImplIOSurface::Unmap() {
63 DCHECK(mapped_); 65 DCHECK(mapped_);
64 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL); 66 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL);
65 mapped_ = false; 67 mapped_ = false;
66 } 68 }
67 69
68 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { 70 uint32 GpuMemoryBufferImplIOSurface::GetStride() const {
69 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_); 71 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_);
70 } 72 }
71 73
72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 74 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
73 gfx::GpuMemoryBufferHandle handle; 75 gfx::GpuMemoryBufferHandle handle;
74 handle.type = gfx::IO_SURFACE_BUFFER; 76 handle.type = gfx::IO_SURFACE_BUFFER;
75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); 77 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_);
76 return handle; 78 return handle;
77 } 79 }
78 80
79 } // namespace content 81 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698