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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_ozone_native_buffer.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: Introduce NativePixmapClient Created 5 years, 6 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_buffer.h" 5 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gl/gl_image.h" 8 #include "ui/gl/gl_image.h"
9 #include "ui/ozone/public/surface_factory_ozone.h" 9 #include "ui/ozone/public/native_pixmap_client.h"
10 10
11 namespace content { 11 namespace content {
12 namespace { 12 namespace {
13 13
14 const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { 14 gfx::GpuMemoryBuffer::Format ConvertFormat(
reveman 2015/06/05 20:26:06 nit: the name ConvertFormat is a bit ambiguous. ma
dshwang 2015/06/08 11:15:14 Done.
15 { gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::SCANOUT }, 15 ui::SurfaceFactoryOzone::BufferFormat ozone_format) {
16 { gfx::GpuMemoryBuffer::RGBX_8888, gfx::GpuMemoryBuffer::SCANOUT } 16 switch (ozone_format) {
17 }; 17 case ui::SurfaceFactoryOzone::BGRA_8888:
18 return gfx::GpuMemoryBuffer::BGRA_8888;
19 case ui::SurfaceFactoryOzone::RGBX_8888:
20 return gfx::GpuMemoryBuffer::RGBX_8888;
21 default:
reveman 2015/06/05 20:26:07 nit: avoid a default case if possible
dshwang 2015/06/08 11:15:14 Done.
22 NOTREACHED();
23 }
24 NOTREACHED();
25 return gfx::GpuMemoryBuffer::BGRA_8888;
26 }
27
28 gfx::GpuMemoryBuffer::Usage ConvertUsage(
reveman 2015/06/05 20:26:06 nit: maybe UsageFromOzoneBufferUsage
dshwang 2015/06/08 11:15:14 Done.
29 ui::SurfaceFactoryOzone::BufferUsage ozone_usage) {
30 switch (ozone_usage) {
31 case ui::SurfaceFactoryOzone::MAP:
32 return gfx::GpuMemoryBuffer::MAP;
33 case ui::SurfaceFactoryOzone::PERSISTENT_MAP:
34 return gfx::GpuMemoryBuffer::PERSISTENT_MAP;
35 case ui::SurfaceFactoryOzone::SCANOUT:
36 return gfx::GpuMemoryBuffer::SCANOUT;
37 }
38 NOTREACHED();
39 return gfx::GpuMemoryBuffer::MAP;
40 }
41
42 void ConvertConfigurations(
43 const std::vector<ui::NativePixmapClient::Configuration>&
44 ozone_configurations,
45 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) {
46 for (auto& ozone_conf : ozone_configurations) {
47 configurations->push_back(
48 {ConvertFormat(ozone_conf.format), ConvertUsage(ozone_conf.usage)});
49 }
50 }
51
52 void GetSupportedConfigurations(
53 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) {
54 std::vector<ui::NativePixmapClient::Configuration> ozone_configurations =
55 ui::NativePixmapClient::GetInstance()
56 ->GetSupportedNativePixmapConfigurations();
57 ConvertConfigurations(ozone_configurations, configurations);
58 }
18 59
19 } // namespace 60 } // namespace
20 61
21 GpuMemoryBufferFactoryOzoneNativeBuffer:: 62 GpuMemoryBufferFactoryOzoneNativeBuffer::
22 GpuMemoryBufferFactoryOzoneNativeBuffer() { 63 GpuMemoryBufferFactoryOzoneNativeBuffer() {
23 } 64 }
24 65
25 GpuMemoryBufferFactoryOzoneNativeBuffer:: 66 GpuMemoryBufferFactoryOzoneNativeBuffer::
26 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { 67 ~GpuMemoryBufferFactoryOzoneNativeBuffer() {
27 } 68 }
28 69
29 // static 70 // static
30 bool GpuMemoryBufferFactoryOzoneNativeBuffer:: 71 bool GpuMemoryBufferFactoryOzoneNativeBuffer::
31 IsGpuMemoryBufferConfigurationSupported(gfx::GpuMemoryBuffer::Format format, 72 IsGpuMemoryBufferConfigurationSupported(gfx::GpuMemoryBuffer::Format format,
32 gfx::GpuMemoryBuffer::Usage usage) { 73 gfx::GpuMemoryBuffer::Usage usage) {
33 for (auto& configuration : kSupportedConfigurations) { 74 std::vector<Configuration> configurations;
75 GetSupportedConfigurations(&configurations);
76 for (auto& configuration : configurations) {
34 if (configuration.format == format && configuration.usage == usage) 77 if (configuration.format == format && configuration.usage == usage)
35 return true; 78 return true;
36 } 79 }
37 80
38 return false; 81 return false;
39 } 82 }
40 83
41 void GpuMemoryBufferFactoryOzoneNativeBuffer:: 84 void GpuMemoryBufferFactoryOzoneNativeBuffer::
42 GetSupportedGpuMemoryBufferConfigurations( 85 GetSupportedGpuMemoryBufferConfigurations(
43 std::vector<Configuration>* configurations) { 86 std::vector<Configuration>* configurations) {
44 if (!ui::SurfaceFactoryOzone::GetInstance()->CanCreateNativePixmap( 87 GetSupportedConfigurations(configurations);
45 ui::SurfaceFactoryOzone::SCANOUT))
46 return;
47
48 configurations->assign(
49 kSupportedConfigurations,
50 kSupportedConfigurations + arraysize(kSupportedConfigurations));
51 } 88 }
52 89
53 gfx::GpuMemoryBufferHandle 90 gfx::GpuMemoryBufferHandle
54 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( 91 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer(
55 gfx::GpuMemoryBufferId id, 92 gfx::GpuMemoryBufferId id,
56 const gfx::Size& size, 93 const gfx::Size& size,
57 gfx::GpuMemoryBuffer::Format format, 94 gfx::GpuMemoryBuffer::Format format,
58 gfx::GpuMemoryBuffer::Usage usage, 95 gfx::GpuMemoryBuffer::Usage usage,
59 int client_id, 96 int client_id,
60 gfx::PluginWindowHandle surface_handle) { 97 gfx::PluginWindowHandle surface_handle) {
(...skipping 23 matching lines...) Expand all
84 const gfx::Size& size, 121 const gfx::Size& size,
85 gfx::GpuMemoryBuffer::Format format, 122 gfx::GpuMemoryBuffer::Format format,
86 unsigned internalformat, 123 unsigned internalformat,
87 int client_id) { 124 int client_id) {
88 DCHECK_EQ(handle.type, gfx::OZONE_NATIVE_BUFFER); 125 DCHECK_EQ(handle.type, gfx::OZONE_NATIVE_BUFFER);
89 return ozone_native_buffer_factory_.CreateImageForGpuMemoryBuffer( 126 return ozone_native_buffer_factory_.CreateImageForGpuMemoryBuffer(
90 handle.id, size, format, internalformat, client_id); 127 handle.id, size, format, internalformat, client_id);
91 } 128 }
92 129
93 } // namespace content 130 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698