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

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

Issue 1134993003: ozone: Implement zero/one-copy texture for Ozone GBM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: open VGEM device in renderer in ad-hoc manner 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_ozone_native_pixmap.h " 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h "
6 6
7 #include "ui/ozone/public/surface_factory_ozone.h" 7 #include "ui/ozone/public/client_native_pixmap_factory.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( 11 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap(
12 gfx::GpuMemoryBufferId id, 12 gfx::GpuMemoryBufferId id,
13 const gfx::Size& size, 13 const gfx::Size& size,
14 gfx::BufferFormat format, 14 gfx::BufferFormat format,
15 gfx::BufferUsage usage,
15 const DestructionCallback& callback) 16 const DestructionCallback& callback)
16 : GpuMemoryBufferImpl(id, size, format, callback) {} 17 : GpuMemoryBufferImpl(id, size, format, callback), usage_(usage) {}
17 18
18 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} 19 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {}
19 20
20 // static 21 // static
21 scoped_ptr<GpuMemoryBufferImpl> 22 scoped_ptr<GpuMemoryBufferImpl>
22 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( 23 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle(
23 const gfx::GpuMemoryBufferHandle& handle, 24 const gfx::GpuMemoryBufferHandle& handle,
24 const gfx::Size& size, 25 const gfx::Size& size,
25 gfx::BufferFormat format, 26 gfx::BufferFormat format,
26 gfx::BufferUsage usage, 27 gfx::BufferUsage usage,
27 const DestructionCallback& callback) { 28 const DestructionCallback& callback) {
28 return make_scoped_ptr<GpuMemoryBufferImpl>( 29 scoped_ptr<GpuMemoryBufferImplOzoneNativePixmap> buffer =
29 new GpuMemoryBufferImplOzoneNativePixmap(handle.id, size, format, 30 make_scoped_ptr(new GpuMemoryBufferImplOzoneNativePixmap(
30 callback)); 31 handle.id, size, format, usage, callback));
32
33 if (!buffer->Initialize(handle))
34 return nullptr;
35 return buffer.Pass();
31 } 36 }
32 37
33 bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) { 38 bool GpuMemoryBufferImplOzoneNativePixmap::Initialize(
39 const gfx::GpuMemoryBufferHandle& handle) {
40 DCHECK(ui::ClientNativePixmapFactory::GetInstance());
41 switch (usage_) {
42 case gfx::BufferUsage::MAP:
43 pixmap_ = ui::ClientNativePixmapFactory::GetInstance()
44 ->ImportNativePixmap(handle.handle, size_, format_, usage_)
45 .Pass();
46 return !!pixmap_;
47 case gfx::BufferUsage::PERSISTENT_MAP:
48 NOTREACHED();
49 return false;
50 case gfx::BufferUsage::SCANOUT:
51 return true;
52 }
34 NOTREACHED(); 53 NOTREACHED();
35 return false; 54 return false;
36 } 55 }
37 56
57 bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) {
58 DCHECK(!mapped_);
59 DCHECK(usage_ == gfx::BufferUsage::MAP);
60 DCHECK(pixmap_);
61 mapped_ = true;
62 return pixmap_->Map(data);
63 }
64
38 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() { 65 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() {
39 NOTREACHED(); 66 DCHECK(mapped_);
67 DCHECK(usage_ == gfx::BufferUsage::MAP);
68 DCHECK(pixmap_);
69 pixmap_->Unmap();
70 mapped_ = false;
40 } 71 }
41 72
42 void GpuMemoryBufferImplOzoneNativePixmap::GetStride(int* stride) const { 73 void GpuMemoryBufferImplOzoneNativePixmap::GetStride(int* stride) const {
43 NOTREACHED(); 74 DCHECK(usage_ == gfx::BufferUsage::MAP);
75 DCHECK(pixmap_);
76 pixmap_->GetStride(stride);
44 } 77 }
45 78
46 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() 79 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle()
47 const { 80 const {
48 gfx::GpuMemoryBufferHandle handle; 81 gfx::GpuMemoryBufferHandle handle;
49 handle.type = gfx::OZONE_NATIVE_PIXMAP; 82 handle.type = gfx::OZONE_NATIVE_PIXMAP;
50 handle.id = id_; 83 handle.id = id_;
51 return handle; 84 return handle;
52 } 85 }
53 86
54 } // namespace content 87 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698