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

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: fix extensions_unittests 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 if (!ui::ClientNativePixmapFactory::GetInstance()) {
18 // unittests don't have to set ClientNativePixmapFactory.
19 return;
20 }
21 std::vector<ui::ClientNativePixmapFactory::Configuration>
22 native_pixmap_configurations =
23 ui::ClientNativePixmapFactory::GetInstance()
24 ->GetSupportedConfigurations();
25 for (auto& native_pixmap_configuration : native_pixmap_configurations) {
26 configurations->push_back({native_pixmap_configuration.format,
27 native_pixmap_configuration.usage});
28 }
29 }
17 30
18 } // namespace 31 } // namespace
19 32
20 GpuMemoryBufferFactoryOzoneNativePixmap:: 33 GpuMemoryBufferFactoryOzoneNativePixmap::
21 GpuMemoryBufferFactoryOzoneNativePixmap() {} 34 GpuMemoryBufferFactoryOzoneNativePixmap() {}
22 35
23 GpuMemoryBufferFactoryOzoneNativePixmap:: 36 GpuMemoryBufferFactoryOzoneNativePixmap::
24 ~GpuMemoryBufferFactoryOzoneNativePixmap() {} 37 ~GpuMemoryBufferFactoryOzoneNativePixmap() {}
25 38
26 // static 39 // static
27 bool GpuMemoryBufferFactoryOzoneNativePixmap:: 40 bool GpuMemoryBufferFactoryOzoneNativePixmap::
28 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, 41 IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format,
29 gfx::BufferUsage usage) { 42 gfx::BufferUsage usage) {
30 for (auto& configuration : kSupportedConfigurations) { 43 std::vector<Configuration> configurations;
44 GetSupportedConfigurations(&configurations);
45 for (auto& configuration : configurations) {
31 if (configuration.format == format && configuration.usage == usage) 46 if (configuration.format == format && configuration.usage == usage)
32 return true; 47 return true;
33 } 48 }
34 49
35 return false; 50 return false;
36 } 51 }
37 52
38 void GpuMemoryBufferFactoryOzoneNativePixmap:: 53 void GpuMemoryBufferFactoryOzoneNativePixmap::
39 GetSupportedGpuMemoryBufferConfigurations( 54 GetSupportedGpuMemoryBufferConfigurations(
40 std::vector<Configuration>* configurations) { 55 std::vector<Configuration>* configurations) {
41 if (!ui::OzonePlatform::GetInstance() 56 GetSupportedConfigurations(configurations);
42 ->GetSurfaceFactoryOzone()
43 ->CanCreateNativePixmap(gfx::BufferUsage::SCANOUT))
44 return;
45
46 configurations->assign(
47 kSupportedConfigurations,
48 kSupportedConfigurations + arraysize(kSupportedConfigurations));
49 } 57 }
50 58
51 gfx::GpuMemoryBufferHandle 59 gfx::GpuMemoryBufferHandle
52 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer( 60 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer(
53 gfx::GpuMemoryBufferId id, 61 gfx::GpuMemoryBufferId id,
54 const gfx::Size& size, 62 const gfx::Size& size,
55 gfx::BufferFormat format, 63 gfx::BufferFormat format,
56 gfx::BufferUsage usage, 64 gfx::BufferUsage usage,
57 int client_id, 65 int client_id,
58 gfx::PluginWindowHandle surface_handle) { 66 gfx::PluginWindowHandle surface_handle) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 121 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
114 new gfx::GLImageOzoneNativePixmap(size, internalformat)); 122 new gfx::GLImageOzoneNativePixmap(size, internalformat));
115 if (!image->Initialize(pixmap.get(), format)) { 123 if (!image->Initialize(pixmap.get(), format)) {
116 LOG(ERROR) << "Failed to create GLImage"; 124 LOG(ERROR) << "Failed to create GLImage";
117 return nullptr; 125 return nullptr;
118 } 126 }
119 return image; 127 return image;
120 } 128 }
121 129
122 } // namespace content 130 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698