Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/aura/mus/mus_context_factory.h" | 5 #include "ui/aura/mus/mus_context_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/base/switches.h" | |
| 8 #include "services/ui/public/cpp/gpu/gpu.h" | 10 #include "services/ui/public/cpp/gpu/gpu.h" |
| 9 #include "ui/aura/mus/window_port_mus.h" | 11 #include "ui/aura/mus/window_port_mus.h" |
| 10 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
| 13 #include "ui/compositor/compositor_switches.h" | |
| 14 #include "ui/display/display_switches.h" | |
| 15 #include "ui/gfx/switches.h" | |
| 11 #include "ui/gl/gl_bindings.h" | 16 #include "ui/gl/gl_bindings.h" |
| 12 | 17 |
| 13 namespace aura { | 18 namespace aura { |
| 14 | 19 |
| 15 MusContextFactory::MusContextFactory(ui::Gpu* gpu) | 20 MusContextFactory::MusContextFactory(ui::Gpu* gpu) |
| 16 : gpu_(gpu), weak_ptr_factory_(this) {} | 21 : gpu_(gpu), weak_ptr_factory_(this) { |
| 22 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 23 renderer_settings_.partial_swap_enabled = | |
| 24 !command_line->HasSwitch(switches::kUIDisablePartialSwap); | |
| 25 #if defined(OS_WIN) | |
| 26 renderer_settings_.finish_rendering_on_resize = true; | |
| 27 #elif defined(OS_MACOSX) | |
| 28 renderer_settings_.release_overlay_resources_after_gpu_query = true; | |
| 29 #endif | |
| 30 renderer_settings_.gl_composited_texture_quad_border = | |
|
danakj
2017/05/11 15:17:15
It won't take long for these to diverge from GPTF.
Alex Z.
2017/05/11 19:25:22
I added ui/compositor/compositor_util.* and put
I
| |
| 31 command_line->HasSwitch(cc::switches::kGlCompositedTextureQuadBorder); | |
| 32 renderer_settings_.show_overdraw_feedback = | |
| 33 command_line->HasSwitch(cc::switches::kShowOverdrawFeedback); | |
| 34 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures)) | |
| 35 renderer_settings_.preferred_tile_format = cc::RGBA_4444; | |
| 36 renderer_settings_.enable_color_correct_rendering = | |
| 37 command_line->HasSwitch(switches::kEnableColorCorrectRendering) || | |
| 38 command_line->HasSwitch(switches::kEnableHDR); | |
| 39 // Populate buffer_to_texture_target_map for all buffer usage/formats. | |
| 40 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); | |
| 41 ++usage_idx) { | |
| 42 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); | |
| 43 for (int format_idx = 0; | |
| 44 format_idx <= static_cast<int>(gfx::BufferFormat::LAST); | |
| 45 ++format_idx) { | |
| 46 gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); | |
| 47 // TODO(sad): http://crbug.com/675431 | |
| 48 uint32_t target = GL_TEXTURE_2D; | |
|
danakj
2017/05/11 15:17:15
This makes sharing the code harder, but we could p
Alex Z.
2017/05/11 17:28:32
This used to be ui::Compositor getting the texture
danakj
2017/05/11 17:34:53
Like if you need different behaviour in GPTF than
| |
| 49 renderer_settings_ | |
| 50 .buffer_to_texture_target_map[std::make_pair(usage, format)] = target; | |
| 51 } | |
| 52 } | |
| 53 renderer_settings_.disallow_non_exact_resource_reuse = | |
| 54 command_line->HasSwitch(cc::switches::kDisallowNonExactResourceReuse); | |
| 55 } | |
| 17 | 56 |
| 18 MusContextFactory::~MusContextFactory() {} | 57 MusContextFactory::~MusContextFactory() {} |
| 19 | 58 |
| 20 void MusContextFactory::OnEstablishedGpuChannel( | 59 void MusContextFactory::OnEstablishedGpuChannel( |
| 21 base::WeakPtr<ui::Compositor> compositor, | 60 base::WeakPtr<ui::Compositor> compositor, |
| 22 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 61 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
| 23 if (!compositor) | 62 if (!compositor) |
| 24 return; | 63 return; |
| 25 WindowTreeHost* host = | 64 WindowTreeHost* host = |
| 26 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); | 65 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 55 } | 94 } |
| 56 | 95 |
| 57 void MusContextFactory::RemoveCompositor(ui::Compositor* compositor) { | 96 void MusContextFactory::RemoveCompositor(ui::Compositor* compositor) { |
| 58 // NOTIMPLEMENTED(); | 97 // NOTIMPLEMENTED(); |
| 59 } | 98 } |
| 60 | 99 |
| 61 double MusContextFactory::GetRefreshRate() const { | 100 double MusContextFactory::GetRefreshRate() const { |
| 62 return 60.0; | 101 return 60.0; |
| 63 } | 102 } |
| 64 | 103 |
| 65 uint32_t MusContextFactory::GetImageTextureTarget(gfx::BufferFormat format, | |
| 66 gfx::BufferUsage usage) { | |
| 67 // TODO(sad): http://crbug.com/675431 | |
| 68 return GL_TEXTURE_2D; | |
| 69 } | |
| 70 | |
| 71 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { | 104 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { |
| 72 return gpu_->gpu_memory_buffer_manager(); | 105 return gpu_->gpu_memory_buffer_manager(); |
| 73 } | 106 } |
| 74 | 107 |
| 75 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { | 108 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { |
| 76 return raster_thread_helper_.task_graph_runner(); | 109 return raster_thread_helper_.task_graph_runner(); |
| 77 } | 110 } |
| 78 | 111 |
| 112 const cc::RendererSettings& MusContextFactory::GetRendererSettings() const { | |
| 113 return renderer_settings_; | |
| 114 } | |
| 115 | |
| 79 } // namespace aura | 116 } // namespace aura |
| OLD | NEW |