Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 1 | #include "display_service.h" |
| 2 | |
Hendrik Wagenaar | eaa5522 | 2017-04-06 10:56:23 -0700 | [diff] [blame] | 3 | #include <unistd.h> |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 4 | #include <vector> |
| 5 | |
Hendrik Wagenaar | bcb03d0 | 2017-05-23 14:59:08 -0700 | [diff] [blame] | 6 | #include <android-base/file.h> |
| 7 | #include <android-base/properties.h> |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 8 | #include <dvr/dvr_display_types.h> |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 9 | #include <pdx/default_transport/service_endpoint.h> |
| 10 | #include <pdx/rpc/remote_method.h> |
Corey Tabaka | 3f82d31 | 2017-04-20 14:42:08 -0700 | [diff] [blame] | 11 | #include <private/dvr/display_protocol.h> |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 12 | #include <private/dvr/numeric.h> |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 13 | #include <private/dvr/types.h> |
| 14 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 15 | using android::dvr::display::DisplayProtocol; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 16 | using android::pdx::Channel; |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 17 | using android::pdx::ErrorStatus; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 18 | using android::pdx::Message; |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 19 | using android::pdx::Status; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 20 | using android::pdx::default_transport::Endpoint; |
| 21 | using android::pdx::rpc::DispatchRemoteMethod; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 22 | |
Hendrik Wagenaar | bcb03d0 | 2017-05-23 14:59:08 -0700 | [diff] [blame] | 23 | namespace { |
| 24 | |
| 25 | const char kDvrLensMetricsProperty[] = "ro.dvr.lens_metrics"; |
| 26 | const char kDvrDeviceMetricsProperty[] = "ro.dvr.device_metrics"; |
| 27 | const char kDvrDeviceConfigProperty[] = "ro.dvr.device_configuration"; |
| 28 | |
| 29 | } // namespace |
| 30 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace dvr { |
| 33 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 34 | DisplayService::DisplayService(Hwc2::Composer* hidl, |
| 35 | RequestDisplayCallback request_display_callback) |
| 36 | : BASE("DisplayService", |
| 37 | Endpoint::Create(display::DisplayProtocol::kClientPath)), |
| 38 | hardware_composer_(hidl, request_display_callback), |
| 39 | request_display_callback_(request_display_callback) { |
Stephen Kiazyk | 016e5e3 | 2017-02-21 17:09:22 -0800 | [diff] [blame] | 40 | hardware_composer_.Initialize(); |
| 41 | } |
| 42 | |
| 43 | bool DisplayService::IsInitialized() const { |
| 44 | return BASE::IsInitialized() && hardware_composer_.IsInitialized(); |
| 45 | } |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 46 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 47 | std::string DisplayService::DumpState(size_t /*max_length*/) { |
| 48 | return hardware_composer_.Dump(); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 51 | void DisplayService::OnChannelClose(pdx::Message& message, |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 52 | const std::shared_ptr<Channel>& channel) { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 53 | if (auto surface = std::static_pointer_cast<DisplaySurface>(channel)) { |
| 54 | surface->OnSetAttributes(message, |
| 55 | {{display::SurfaceAttribute::Visible, |
| 56 | display::SurfaceAttributeValue{false}}}); |
| 57 | SurfaceUpdated(surface->surface_type(), |
| 58 | display::SurfaceUpdateFlags::VisibilityChanged); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 59 | } |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // First-level dispatch for display service messages. Directly handles messages |
| 63 | // that are independent of the display surface (metrics, creation) and routes |
| 64 | // surface-specific messages to the per-instance handlers. |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 65 | Status<void> DisplayService::HandleMessage(pdx::Message& message) { |
| 66 | ALOGD_IF(TRACE, "DisplayService::HandleMessage: opcode=%d", message.GetOp()); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 67 | switch (message.GetOp()) { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 68 | case DisplayProtocol::GetMetrics::Opcode: |
| 69 | DispatchRemoteMethod<DisplayProtocol::GetMetrics>( |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 70 | *this, &DisplayService::OnGetMetrics, message); |
Alex Vakulenko | f0a7bd0 | 2017-03-31 18:06:19 -0700 | [diff] [blame] | 71 | return {}; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 72 | |
Hendrik Wagenaar | bcb03d0 | 2017-05-23 14:59:08 -0700 | [diff] [blame] | 73 | case DisplayProtocol::GetConfigurationData::Opcode: |
| 74 | DispatchRemoteMethod<DisplayProtocol::GetConfigurationData>( |
| 75 | *this, &DisplayService::OnGetConfigurationData, message); |
| 76 | return {}; |
| 77 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 78 | case DisplayProtocol::CreateSurface::Opcode: |
| 79 | DispatchRemoteMethod<DisplayProtocol::CreateSurface>( |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 80 | *this, &DisplayService::OnCreateSurface, message); |
Alex Vakulenko | f0a7bd0 | 2017-03-31 18:06:19 -0700 | [diff] [blame] | 81 | return {}; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 82 | |
Okan Arikan | 36d2380 | 2017-05-15 15:20:39 -0700 | [diff] [blame] | 83 | case DisplayProtocol::GetGlobalBuffer::Opcode: |
| 84 | DispatchRemoteMethod<DisplayProtocol::GetGlobalBuffer>( |
| 85 | *this, &DisplayService::OnGetGlobalBuffer, message); |
Alex Vakulenko | f0a7bd0 | 2017-03-31 18:06:19 -0700 | [diff] [blame] | 86 | return {}; |
Hendrik Wagenaar | 10e68eb | 2017-03-15 13:29:02 -0700 | [diff] [blame] | 87 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 88 | case DisplayProtocol::IsVrAppRunning::Opcode: |
| 89 | DispatchRemoteMethod<DisplayProtocol::IsVrAppRunning>( |
Albert Chaulk | b7c8a4b | 2017-03-20 13:03:39 -0400 | [diff] [blame] | 90 | *this, &DisplayService::IsVrAppRunning, message); |
Alex Vakulenko | f0a7bd0 | 2017-03-31 18:06:19 -0700 | [diff] [blame] | 91 | return {}; |
Albert Chaulk | b7c8a4b | 2017-03-20 13:03:39 -0400 | [diff] [blame] | 92 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 93 | // Direct the surface specific messages to the surface instance. |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 94 | case DisplayProtocol::SetAttributes::Opcode: |
| 95 | case DisplayProtocol::CreateQueue::Opcode: |
| 96 | case DisplayProtocol::GetSurfaceInfo::Opcode: |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 97 | return HandleSurfaceMessage(message); |
| 98 | |
| 99 | default: |
| 100 | return Service::HandleMessage(message); |
| 101 | } |
| 102 | } |
| 103 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 104 | Status<display::Metrics> DisplayService::OnGetMetrics( |
| 105 | pdx::Message& /*message*/) { |
| 106 | return {{static_cast<uint32_t>(GetDisplayMetrics().width), |
| 107 | static_cast<uint32_t>(GetDisplayMetrics().height), |
| 108 | static_cast<uint32_t>(GetDisplayMetrics().dpi.x), |
| 109 | static_cast<uint32_t>(GetDisplayMetrics().dpi.y), |
| 110 | static_cast<uint32_t>( |
| 111 | hardware_composer_.native_display_metrics().vsync_period_ns), |
| 112 | 0, |
| 113 | 0, |
| 114 | 0, |
| 115 | 0.0, |
| 116 | {}, |
| 117 | {}}}; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Hendrik Wagenaar | bcb03d0 | 2017-05-23 14:59:08 -0700 | [diff] [blame] | 120 | pdx::Status<std::string> DisplayService::OnGetConfigurationData( |
| 121 | pdx::Message& /*message*/, display::ConfigFileType config_type) { |
| 122 | std::string property_name; |
| 123 | switch (config_type) { |
| 124 | case display::ConfigFileType::kLensMetrics: |
| 125 | property_name = kDvrLensMetricsProperty; |
| 126 | break; |
| 127 | case display::ConfigFileType::kDeviceMetrics: |
| 128 | property_name = kDvrDeviceMetricsProperty; |
| 129 | break; |
| 130 | case display::ConfigFileType::kDeviceConfiguration: |
| 131 | property_name = kDvrDeviceConfigProperty; |
| 132 | break; |
| 133 | default: |
| 134 | return ErrorStatus(EINVAL); |
| 135 | } |
| 136 | std::string file_path = base::GetProperty(property_name, ""); |
| 137 | if (file_path.empty()) { |
| 138 | return ErrorStatus(ENOENT); |
| 139 | } |
| 140 | |
| 141 | std::string data; |
| 142 | if (!base::ReadFileToString(file_path, &data)) { |
| 143 | return ErrorStatus(errno); |
| 144 | } |
| 145 | |
| 146 | return std::move(data); |
| 147 | } |
| 148 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 149 | // Creates a new DisplaySurface and associates it with this channel. This may |
| 150 | // only be done once per channel. |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 151 | Status<display::SurfaceInfo> DisplayService::OnCreateSurface( |
| 152 | pdx::Message& message, const display::SurfaceAttributes& attributes) { |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 153 | // A surface may only be created once per channel. |
| 154 | if (message.GetChannel()) |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 155 | return ErrorStatus(EINVAL); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 156 | |
| 157 | ALOGI_IF(TRACE, "DisplayService::OnCreateSurface: cid=%d", |
| 158 | message.GetChannelId()); |
| 159 | |
| 160 | // Use the channel id as the unique surface id. |
| 161 | const int surface_id = message.GetChannelId(); |
| 162 | const int process_id = message.GetProcessId(); |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 163 | const int user_id = message.GetEffectiveUserId(); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 164 | |
| 165 | ALOGI_IF(TRACE, |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 166 | "DisplayService::OnCreateSurface: surface_id=%d process_id=%d", |
| 167 | surface_id, process_id); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 168 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 169 | auto surface_status = |
| 170 | DisplaySurface::Create(this, surface_id, process_id, user_id, attributes); |
| 171 | if (!surface_status) { |
| 172 | ALOGE("DisplayService::OnCreateSurface: Failed to create surface: %s", |
| 173 | surface_status.GetErrorMessage().c_str()); |
| 174 | return ErrorStatus(surface_status.error()); |
| 175 | } |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 176 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 177 | SurfaceType surface_type = surface_status.get()->surface_type(); |
| 178 | display::SurfaceUpdateFlags update_flags = |
| 179 | surface_status.get()->update_flags(); |
| 180 | display::SurfaceInfo surface_info{surface_status.get()->surface_id(), |
| 181 | surface_status.get()->visible(), |
| 182 | surface_status.get()->z_order()}; |
| 183 | |
| 184 | message.SetChannel(surface_status.take()); |
| 185 | |
| 186 | SurfaceUpdated(surface_type, update_flags); |
| 187 | return {surface_info}; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 190 | void DisplayService::SurfaceUpdated(SurfaceType surface_type, |
| 191 | display::SurfaceUpdateFlags update_flags) { |
| 192 | ALOGD_IF(TRACE, "DisplayService::SurfaceUpdated: update_flags=%x", |
| 193 | update_flags.value()); |
| 194 | if (update_flags.value() != 0) { |
| 195 | if (surface_type == SurfaceType::Application) |
| 196 | NotifyDisplayConfigurationUpdate(); |
| 197 | else |
| 198 | UpdateActiveDisplaySurfaces(); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 199 | } |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 200 | } |
| 201 | |
Okan Arikan | 36d2380 | 2017-05-15 15:20:39 -0700 | [diff] [blame] | 202 | pdx::Status<BorrowedNativeBufferHandle> DisplayService::OnGetGlobalBuffer( |
| 203 | pdx::Message& /* message */, DvrGlobalBufferKey key) { |
| 204 | ALOGD_IF(TRACE, "DisplayService::OnGetGlobalBuffer: key=%d", key); |
| 205 | auto global_buffer = global_buffers_.find(key); |
| 206 | if (global_buffer != global_buffers_.end()) |
| 207 | return {BorrowedNativeBufferHandle(*global_buffer->second, 0)}; |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 208 | else |
| 209 | return pdx::ErrorStatus(EINVAL); |
Hendrik Wagenaar | 10e68eb | 2017-03-15 13:29:02 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 212 | // Calls the message handler for the DisplaySurface associated with this |
| 213 | // channel. |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 214 | Status<void> DisplayService::HandleSurfaceMessage(pdx::Message& message) { |
| 215 | auto surface = std::static_pointer_cast<DisplaySurface>(message.GetChannel()); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 216 | ALOGW_IF(!surface, |
| 217 | "DisplayService::HandleSurfaceMessage: surface is nullptr!"); |
| 218 | |
| 219 | if (surface) |
| 220 | return surface->HandleMessage(message); |
| 221 | else |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 222 | return ErrorStatus(EINVAL); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | std::shared_ptr<DisplaySurface> DisplayService::GetDisplaySurface( |
| 226 | int surface_id) const { |
| 227 | return std::static_pointer_cast<DisplaySurface>(GetChannel(surface_id)); |
| 228 | } |
| 229 | |
| 230 | std::vector<std::shared_ptr<DisplaySurface>> |
| 231 | DisplayService::GetDisplaySurfaces() const { |
| 232 | return GetChannels<DisplaySurface>(); |
| 233 | } |
| 234 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 235 | std::vector<std::shared_ptr<DirectDisplaySurface>> |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 236 | DisplayService::GetVisibleDisplaySurfaces() const { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 237 | std::vector<std::shared_ptr<DirectDisplaySurface>> visible_surfaces; |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 238 | |
| 239 | ForEachDisplaySurface( |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 240 | SurfaceType::Direct, |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 241 | [&](const std::shared_ptr<DisplaySurface>& surface) mutable { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 242 | if (surface->visible()) { |
| 243 | visible_surfaces.push_back( |
| 244 | std::static_pointer_cast<DirectDisplaySurface>(surface)); |
| 245 | surface->ClearUpdate(); |
| 246 | } |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 247 | }); |
| 248 | |
| 249 | return visible_surfaces; |
| 250 | } |
| 251 | |
Steven Thomas | 050b2c8 | 2017-03-06 11:45:16 -0800 | [diff] [blame] | 252 | void DisplayService::UpdateActiveDisplaySurfaces() { |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 253 | auto visible_surfaces = GetVisibleDisplaySurfaces(); |
| 254 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 255 | std::sort(visible_surfaces.begin(), visible_surfaces.end(), |
| 256 | [](const std::shared_ptr<DisplaySurface>& a, |
| 257 | const std::shared_ptr<DisplaySurface>& b) { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 258 | return a->z_order() < b->z_order(); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 259 | }); |
| 260 | |
| 261 | ALOGD_IF(TRACE, |
| 262 | "DisplayService::UpdateActiveDisplaySurfaces: %zd visible surfaces", |
| 263 | visible_surfaces.size()); |
| 264 | |
Steven Thomas | 050b2c8 | 2017-03-06 11:45:16 -0800 | [diff] [blame] | 265 | hardware_composer_.SetDisplaySurfaces(std::move(visible_surfaces)); |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 266 | } |
| 267 | |
Okan Arikan | 36d2380 | 2017-05-15 15:20:39 -0700 | [diff] [blame] | 268 | pdx::Status<BorrowedNativeBufferHandle> DisplayService::SetupGlobalBuffer( |
| 269 | DvrGlobalBufferKey key, size_t size, uint64_t usage) { |
| 270 | auto global_buffer = global_buffers_.find(key); |
| 271 | if (global_buffer == global_buffers_.end()) { |
Jiwen 'Steve' Cai | 0057fdd | 2017-05-02 11:21:18 -0700 | [diff] [blame] | 272 | auto ion_buffer = std::make_unique<IonBuffer>(static_cast<int>(size), 1, |
| 273 | HAL_PIXEL_FORMAT_BLOB, usage); |
John Bates | 954796e | 2017-05-11 11:00:31 -0700 | [diff] [blame] | 274 | |
| 275 | // Some buffers are used internally. If they were configured with an |
| 276 | // invalid size or format, this will fail. |
| 277 | int result = hardware_composer_.OnNewGlobalBuffer(key, *ion_buffer.get()); |
| 278 | if (result < 0) |
| 279 | return ErrorStatus(result); |
Okan Arikan | 36d2380 | 2017-05-15 15:20:39 -0700 | [diff] [blame] | 280 | global_buffer = |
| 281 | global_buffers_.insert(std::make_pair(key, std::move(ion_buffer))) |
Hendrik Wagenaar | eaa5522 | 2017-04-06 10:56:23 -0700 | [diff] [blame] | 282 | .first; |
Hendrik Wagenaar | 10e68eb | 2017-03-15 13:29:02 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Okan Arikan | 36d2380 | 2017-05-15 15:20:39 -0700 | [diff] [blame] | 285 | return {BorrowedNativeBufferHandle(*global_buffer->second, 0)}; |
Hendrik Wagenaar | 10e68eb | 2017-03-15 13:29:02 -0700 | [diff] [blame] | 286 | } |
| 287 | |
John Bates | 954796e | 2017-05-11 11:00:31 -0700 | [diff] [blame] | 288 | pdx::Status<void> DisplayService::DeleteGlobalBuffer(DvrGlobalBufferKey key) { |
| 289 | auto global_buffer = global_buffers_.find(key); |
| 290 | if (global_buffer != global_buffers_.end()) { |
| 291 | // Some buffers are used internally. |
| 292 | hardware_composer_.OnDeletedGlobalBuffer(key); |
| 293 | global_buffers_.erase(global_buffer); |
| 294 | } |
| 295 | |
| 296 | return {0}; |
| 297 | } |
| 298 | |
Steven Thomas | 3cfac28 | 2017-02-06 12:29:30 -0800 | [diff] [blame] | 299 | void DisplayService::OnHardwareComposerRefresh() { |
| 300 | hardware_composer_.OnHardwareComposerRefresh(); |
| 301 | } |
| 302 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 303 | void DisplayService::SetDisplayConfigurationUpdateNotifier( |
| 304 | DisplayConfigurationUpdateNotifier update_notifier) { |
| 305 | update_notifier_ = update_notifier; |
| 306 | } |
| 307 | |
| 308 | void DisplayService::NotifyDisplayConfigurationUpdate() { |
| 309 | if (update_notifier_) |
| 310 | update_notifier_(); |
| 311 | } |
| 312 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 313 | Status<bool> DisplayService::IsVrAppRunning(pdx::Message& /*message*/) { |
Albert Chaulk | 356bc37 | 2017-04-05 18:01:58 -0400 | [diff] [blame] | 314 | bool visible = false; |
Hendrik Wagenaar | eaa5522 | 2017-04-06 10:56:23 -0700 | [diff] [blame] | 315 | ForEachDisplaySurface( |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 316 | SurfaceType::Application, |
Hendrik Wagenaar | eaa5522 | 2017-04-06 10:56:23 -0700 | [diff] [blame] | 317 | [&visible](const std::shared_ptr<DisplaySurface>& surface) { |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 318 | if (surface->visible()) |
Hendrik Wagenaar | eaa5522 | 2017-04-06 10:56:23 -0700 | [diff] [blame] | 319 | visible = true; |
| 320 | }); |
Albert Chaulk | b7c8a4b | 2017-03-20 13:03:39 -0400 | [diff] [blame] | 321 | |
Corey Tabaka | 2251d82 | 2017-04-20 16:04:07 -0700 | [diff] [blame] | 322 | return {visible}; |
Albert Chaulk | b7c8a4b | 2017-03-20 13:03:39 -0400 | [diff] [blame] | 323 | } |
| 324 | |
Alex Vakulenko | a8a9278 | 2017-01-27 14:41:57 -0800 | [diff] [blame] | 325 | } // namespace dvr |
| 326 | } // namespace android |