OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <deque> | 10 #include <deque> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "cc/scheduler/begin_frame_source.h" | 30 #include "cc/scheduler/begin_frame_source.h" |
31 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
32 #include "cc/trees/layer_tree_host.h" | 32 #include "cc/trees/layer_tree_host.h" |
33 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
34 #include "ui/compositor/compositor_observer.h" | 34 #include "ui/compositor/compositor_observer.h" |
35 #include "ui/compositor/compositor_switches.h" | 35 #include "ui/compositor/compositor_switches.h" |
36 #include "ui/compositor/compositor_vsync_manager.h" | 36 #include "ui/compositor/compositor_vsync_manager.h" |
37 #include "ui/compositor/dip_util.h" | 37 #include "ui/compositor/dip_util.h" |
38 #include "ui/compositor/layer.h" | 38 #include "ui/compositor/layer.h" |
39 #include "ui/compositor/layer_animator_collection.h" | 39 #include "ui/compositor/layer_animator_collection.h" |
40 #include "ui/gl/gl_context.h" | |
41 #include "ui/gl/gl_switches.h" | 40 #include "ui/gl/gl_switches.h" |
42 | 41 |
43 namespace { | 42 namespace { |
44 | 43 |
45 const double kDefaultRefreshRate = 60.0; | 44 const double kDefaultRefreshRate = 60.0; |
46 const double kTestRefreshRate = 200.0; | 45 const double kTestRefreshRate = 200.0; |
47 | 46 |
48 bool IsRunningInMojoShell(base::CommandLine* command_line) { | 47 bool IsRunningInMojoShell(base::CommandLine* command_line) { |
49 const char kMojoShellFlag[] = "mojo-platform-channel-handle"; | 48 const char kMojoShellFlag[] = "mojo-platform-channel-handle"; |
50 return command_line->HasSwitch(kMojoShellFlag); | 49 return command_line->HasSwitch(kMojoShellFlag); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures)) | 151 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures)) |
153 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; | 152 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; |
154 | 153 |
155 settings.use_layer_lists = | 154 settings.use_layer_lists = |
156 command_line->HasSwitch(cc::switches::kUIEnableLayerLists); | 155 command_line->HasSwitch(cc::switches::kUIEnableLayerLists); |
157 | 156 |
158 // UI compositor always uses partial raster if not using zero-copy. Zero copy | 157 // UI compositor always uses partial raster if not using zero-copy. Zero copy |
159 // doesn't currently support partial raster. | 158 // doesn't currently support partial raster. |
160 settings.use_partial_raster = !settings.use_zero_copy; | 159 settings.use_partial_raster = !settings.use_zero_copy; |
161 | 160 |
162 // Use CPU_READ_WRITE_PERSISTENT memory buffers to support partial tile | 161 // Populate buffer_to_texture_target_map for all buffer usage/formats. |
163 // raster if needed. | 162 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); |
164 gfx::BufferUsage usage = | 163 ++usage_idx) { |
165 settings.use_partial_raster | 164 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); |
166 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | 165 for (int format_idx = 0; |
167 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | 166 format_idx <= static_cast<int>(gfx::BufferFormat::LAST); |
168 | 167 ++format_idx) { |
169 for (size_t format = 0; | 168 gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); |
170 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { | 169 uint32_t target = context_factory_->GetImageTextureTarget(format, usage); |
171 DCHECK_GT(settings.use_image_texture_targets.size(), format); | 170 settings.renderer_settings.buffer_to_texture_target_map.insert( |
172 settings.use_image_texture_targets[format] = | 171 cc::BufferToTextureTargetMap::value_type( |
173 context_factory_->GetImageTextureTarget( | 172 cc::BufferToTextureTargetKey(usage, format), target)); |
174 static_cast<gfx::BufferFormat>(format), usage); | 173 } |
175 } | 174 } |
176 | 175 |
177 // Note: Only enable image decode tasks if we have more than one worker | 176 // Note: Only enable image decode tasks if we have more than one worker |
178 // thread. | 177 // thread. |
179 settings.image_decode_tasks_enabled = false; | 178 settings.image_decode_tasks_enabled = false; |
180 | 179 |
181 // TODO(crbug.com/603600): This should always be turned on once mus tells its | 180 // TODO(crbug.com/603600): This should always be turned on once mus tells its |
182 // clients about BeginFrame. | 181 // clients about BeginFrame. |
183 settings.use_output_surface_begin_frame_source = | 182 settings.use_output_surface_begin_frame_source = |
184 !IsRunningInMojoShell(command_line); | 183 !IsRunningInMojoShell(command_line); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 observer_list_, | 499 observer_list_, |
501 OnCompositingLockStateChanged(this)); | 500 OnCompositingLockStateChanged(this)); |
502 } | 501 } |
503 | 502 |
504 void Compositor::CancelCompositorLock() { | 503 void Compositor::CancelCompositorLock() { |
505 if (compositor_lock_) | 504 if (compositor_lock_) |
506 compositor_lock_->CancelLock(); | 505 compositor_lock_->CancelLock(); |
507 } | 506 } |
508 | 507 |
509 } // namespace ui | 508 } // namespace ui |
OLD | NEW |