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

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

Issue 1128113011: ozone: Introduce ClientPixmap and ClientPixmapFactory for non-GPU processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle zygote 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_factory.h"
8 #include "ui/ozone/public/ozone_platform.h" 9 #include "ui/ozone/public/ozone_platform.h"
9 #include "ui/ozone/public/surface_factory_ozone.h" 10 #include "ui/ozone/public/surface_factory_ozone.h"
10 11
11 namespace content { 12 namespace content {
12 namespace { 13 namespace {
13 14
14 const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { 15 void GetSupportedConfigurations(
15 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, 16 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) {
16 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; 17 std::vector<ui::ClientNativePixmapFactory::Configuration>
18 native_pixmap_configurations =
19 ui::ClientNativePixmapFactory::GetInstance()
20 ->GetSupportedConfigurations();
21 for (auto& native_pixmap_configuration : native_pixmap_configurations) {
22 configurations->push_back({native_pixmap_configuration.format,
23 native_pixmap_configuration.usage});
24 }
25 }
17 26
18 } // namespace 27 } // namespace
19 28
20 GpuMemoryBufferFactoryOzoneNativePixmap:: 29 GpuMemoryBufferFactoryOzoneNativePixmap::
21 GpuMemoryBufferFactoryOzoneNativePixmap() {} 30 GpuMemoryBufferFactoryOzoneNativePixmap() {}
22 31
23 GpuMemoryBufferFactoryOzoneNativePixmap:: 32 GpuMemoryBufferFactoryOzoneNativePixmap::
24 ~GpuMemoryBufferFactoryOzoneNativePixmap() {} 33 ~GpuMemoryBufferFactoryOzoneNativePixmap() {}
25 34
26 // static 35 // static
27 bool GpuMemoryBufferFactoryOzoneNativePixmap:: 36 bool GpuMemoryBufferFactoryOzoneNativePixmap::
28 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, 37 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format,
29 gfx::BufferUsage usage) { 38 gfx::BufferUsage usage) {
30 for (auto& configuration : kSupportedConfigurations) { 39 std::vector<Configuration> configurations;
40 GetSupportedConfigurations(&configurations);
41 for (auto& configuration : configurations) {
31 if (configuration.format == format && configuration.usage == usage) 42 if (configuration.format == format && configuration.usage == usage)
32 return true; 43 return true;
33 } 44 }
34 45
35 return false; 46 return false;
36 } 47 }
37 48
38 void GpuMemoryBufferFactoryOzoneNativePixmap:: 49 void GpuMemoryBufferFactoryOzoneNativePixmap::
39 GetSupportedGpuMemoryBufferConfigurations( 50 GetSupportedGpuMemoryBufferConfigurations(
40 std::vector<Configuration>* configurations) { 51 std::vector<Configuration>* configurations) {
41 if (!ui::OzonePlatform::GetInstance() 52 GetSupportedConfigurations(configurations);
42 ->GetSurfaceFactoryOzone()
43 ->CanCreateNativePixmap(gfx::BufferUsage::SCANOUT))
44 return;
45
46 configurations->assign(
47 kSupportedConfigurations,
48 kSupportedConfigurations + arraysize(kSupportedConfigurations));
49 } 53 }
50 54
51 gfx::GpuMemoryBufferHandle 55 gfx::GpuMemoryBufferHandle
52 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer( 56 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer(
53 gfx::GpuMemoryBufferId id, 57 gfx::GpuMemoryBufferId id,
54 const gfx::Size& size, 58 const gfx::Size& size,
55 gfx::BufferFormat format, 59 gfx::BufferFormat format,
56 gfx::BufferUsage usage, 60 gfx::BufferUsage usage,
57 int client_id, 61 int client_id,
58 gfx::PluginWindowHandle surface_handle) { 62 gfx::PluginWindowHandle surface_handle) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 117 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
114 new gfx::GLImageOzoneNativePixmap(size, internalformat)); 118 new gfx::GLImageOzoneNativePixmap(size, internalformat));
115 if (!image->Initialize(pixmap.get(), format)) { 119 if (!image->Initialize(pixmap.get(), format)) {
116 LOG(ERROR) << "Failed to create GLImage"; 120 LOG(ERROR) << "Failed to create GLImage";
117 return nullptr; 121 return nullptr;
118 } 122 }
119 return image; 123 return image;
120 } 124 }
121 125
122 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698