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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc

Issue 1263323004: Add NativePixmapHandle type & interface for exporting them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/gpu_memory_buffer_factory_ozone_native_pixmap.h" 5 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
6 6
7 #include "ui/gl/gl_image_ozone_native_pixmap.h" 7 #include "ui/gl/gl_image_ozone_native_pixmap.h"
8 #include "ui/ozone/public/client_native_pixmap.h"
8 #include "ui/ozone/public/client_native_pixmap_factory.h" 9 #include "ui/ozone/public/client_native_pixmap_factory.h"
9 #include "ui/ozone/public/ozone_platform.h" 10 #include "ui/ozone/public/ozone_platform.h"
10 #include "ui/ozone/public/surface_factory_ozone.h" 11 #include "ui/ozone/public/surface_factory_ozone.h"
11 12
12 namespace content { 13 namespace content {
13 namespace { 14 namespace {
14 15
15 void GetSupportedConfigurations( 16 void GetSupportedConfigurations(
16 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) { 17 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) {
17 std::vector<ui::ClientNativePixmapFactory::Configuration> 18 std::vector<ui::ClientNativePixmapFactory::Configuration>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 scoped_refptr<ui::NativePixmap> pixmap = 64 scoped_refptr<ui::NativePixmap> pixmap =
64 ui::OzonePlatform::GetInstance() 65 ui::OzonePlatform::GetInstance()
65 ->GetSurfaceFactoryOzone() 66 ->GetSurfaceFactoryOzone()
66 ->CreateNativePixmap(surface_handle, size, format, usage); 67 ->CreateNativePixmap(surface_handle, size, format, usage);
67 if (!pixmap.get()) { 68 if (!pixmap.get()) {
68 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" 69 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x"
69 << size.height() << " format " << static_cast<int>(format) 70 << size.height() << " format " << static_cast<int>(format)
70 << ", usage " << static_cast<int>(usage); 71 << ", usage " << static_cast<int>(usage);
71 return gfx::GpuMemoryBufferHandle(); 72 return gfx::GpuMemoryBufferHandle();
72 } 73 }
73 base::AutoLock lock(native_pixmaps_lock_);
74 NativePixmapMapKey key(id, client_id);
75 DCHECK(native_pixmaps_.find(key) == native_pixmaps_.end())
76 << "pixmap with this key must not exist";
77 native_pixmaps_[key] = pixmap;
78 74
79 gfx::GpuMemoryBufferHandle handle; 75 gfx::GpuMemoryBufferHandle handle;
80 handle.type = gfx::OZONE_NATIVE_PIXMAP; 76 handle.type = gfx::OZONE_NATIVE_PIXMAP;
81 handle.id = id; 77 handle.id = id;
78
79 if (usage == gfx::BufferUsage::MAP &&
reveman 2015/08/05 04:18:00 Can you remove the MAP check from here and not fai
spang 2015/08/05 13:26:15 Done.. now it imports scanout as well. It is not
80 !pixmap->ExportHandle(&handle.native_pixmap_handle))
81 return gfx::GpuMemoryBufferHandle();
82
83 {
84 base::AutoLock lock(native_pixmaps_lock_);
85 NativePixmapMapKey key(id, client_id);
86 DCHECK(native_pixmaps_.find(key) == native_pixmaps_.end())
87 << "pixmap with this key must not exist";
88 native_pixmaps_[key] = pixmap;
89 }
90
82 return handle; 91 return handle;
83 } 92 }
84 93
85 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer( 94 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer(
86 gfx::GpuMemoryBufferId id, 95 gfx::GpuMemoryBufferId id,
87 int client_id) { 96 int client_id) {
88 base::AutoLock lock(native_pixmaps_lock_); 97 base::AutoLock lock(native_pixmaps_lock_);
89 auto it = native_pixmaps_.find(NativePixmapMapKey(id, client_id)); 98 auto it = native_pixmaps_.find(NativePixmapMapKey(id, client_id));
90 DCHECK(it != native_pixmaps_.end()) << "pixmap with this key must exist"; 99 DCHECK(it != native_pixmaps_.end()) << "pixmap with this key must exist";
91 native_pixmaps_.erase(it); 100 native_pixmaps_.erase(it);
(...skipping 25 matching lines...) Expand all
117 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 126 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
118 new gfx::GLImageOzoneNativePixmap(size, internalformat)); 127 new gfx::GLImageOzoneNativePixmap(size, internalformat));
119 if (!image->Initialize(pixmap.get(), format)) { 128 if (!image->Initialize(pixmap.get(), format)) {
120 LOG(ERROR) << "Failed to create GLImage"; 129 LOG(ERROR) << "Failed to create GLImage";
121 return nullptr; 130 return nullptr;
122 } 131 }
123 return image; 132 return image;
124 } 133 }
125 134
126 } // namespace content 135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698