• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "rs_screen.h"
17 
18 #include <algorithm>
19 #include <cinttypes>
20 
21 #include "platform/common/rs_log.h"
22 #include "rs_trace.h"
23 #include "string_utils.h"
24 #include "hisysevent.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 using namespace HiviewDFX;
29 
30 namespace impl {
31 std::map<GraphicColorGamut, GraphicCM_ColorSpaceType> RSScreen::RS_TO_COMMON_COLOR_SPACE_TYPE_MAP {
32     {GRAPHIC_COLOR_GAMUT_STANDARD_BT601, GRAPHIC_CM_BT601_EBU_FULL},
33     {GRAPHIC_COLOR_GAMUT_STANDARD_BT709, GRAPHIC_CM_BT709_FULL},
34     {GRAPHIC_COLOR_GAMUT_SRGB, GRAPHIC_CM_SRGB_FULL},
35     {GRAPHIC_COLOR_GAMUT_ADOBE_RGB, GRAPHIC_CM_ADOBERGB_FULL},
36     {GRAPHIC_COLOR_GAMUT_DISPLAY_P3, GRAPHIC_CM_P3_FULL},
37     {GRAPHIC_COLOR_GAMUT_BT2020, GRAPHIC_CM_DISPLAY_BT2020_SRGB},
38     {GRAPHIC_COLOR_GAMUT_BT2100_PQ, GRAPHIC_CM_BT2020_PQ_FULL},
39     {GRAPHIC_COLOR_GAMUT_BT2100_HLG, GRAPHIC_CM_BT2020_HLG_FULL},
40     {GRAPHIC_COLOR_GAMUT_DISPLAY_BT2020, GRAPHIC_CM_DISPLAY_BT2020_SRGB},
41 };
42 std::map<GraphicCM_ColorSpaceType, GraphicColorGamut> RSScreen::COMMON_COLOR_SPACE_TYPE_TO_RS_MAP {
43     {GRAPHIC_CM_BT601_EBU_FULL, GRAPHIC_COLOR_GAMUT_STANDARD_BT601},
44     {GRAPHIC_CM_BT709_FULL, GRAPHIC_COLOR_GAMUT_STANDARD_BT709},
45     {GRAPHIC_CM_SRGB_FULL, GRAPHIC_COLOR_GAMUT_SRGB},
46     {GRAPHIC_CM_ADOBERGB_FULL, GRAPHIC_COLOR_GAMUT_ADOBE_RGB},
47     {GRAPHIC_CM_P3_FULL, GRAPHIC_COLOR_GAMUT_DISPLAY_P3},
48     {GRAPHIC_CM_DISPLAY_BT2020_SRGB, GRAPHIC_COLOR_GAMUT_BT2020},
49     {GRAPHIC_CM_BT2020_PQ_FULL, GRAPHIC_COLOR_GAMUT_BT2100_PQ},
50     {GRAPHIC_CM_BT2020_HLG_FULL, GRAPHIC_COLOR_GAMUT_BT2100_HLG},
51     {GRAPHIC_CM_DISPLAY_BT2020_SRGB, GRAPHIC_COLOR_GAMUT_DISPLAY_BT2020},
52 };
53 std::map<GraphicHDRFormat, ScreenHDRFormat> RSScreen::HDI_HDR_FORMAT_TO_RS_MAP {
54     {GRAPHIC_NOT_SUPPORT_HDR, NOT_SUPPORT_HDR},
55     {GRAPHIC_DOLBY_VISION, NOT_SUPPORT_HDR},
56     {GRAPHIC_HDR10, VIDEO_HDR10},
57     {GRAPHIC_HLG, VIDEO_HLG},
58     {GRAPHIC_HDR10_PLUS, NOT_SUPPORT_HDR},
59     {GRAPHIC_HDR_VIVID, VIDEO_HDR_VIVID},
60 };
61 std::map<ScreenHDRFormat, GraphicHDRFormat> RSScreen::RS_TO_HDI_HDR_FORMAT_MAP {
62     {NOT_SUPPORT_HDR, GRAPHIC_NOT_SUPPORT_HDR},
63     {VIDEO_HLG, GRAPHIC_HLG},
64     {VIDEO_HDR10, GRAPHIC_HDR10},
65     {VIDEO_HDR_VIVID, GRAPHIC_HDR_VIVID},
66     {IMAGE_HDR_VIVID_DUAL, GRAPHIC_HDR_VIVID},
67     {IMAGE_HDR_VIVID_SINGLE, GRAPHIC_HDR_VIVID},
68     {IMAGE_HDR_ISO_DUAL, GRAPHIC_NOT_SUPPORT_HDR},
69     {IMAGE_HDR_ISO_SINGLE, GRAPHIC_NOT_SUPPORT_HDR},
70 };
71 
72 constexpr int MAX_LUM = 1000;
73 
RSScreen(ScreenId id,bool isVirtual,std::shared_ptr<HdiOutput> output,sptr<Surface> surface)74 RSScreen::RSScreen(ScreenId id,
75     bool isVirtual,
76     std::shared_ptr<HdiOutput> output,
77     sptr<Surface> surface)
78     : id_(id),
79       isVirtual_(isVirtual),
80       hdiOutput_(std::move(output)),
81       producerSurface_(std::move(surface))
82 {
83     if (!IsVirtual()) {
84         hdrCapability_.formatCount = 0;
85         name_ = "Screen_" + std::to_string(id_);
86         PhysicalScreenInit();
87         RS_LOGD_IF(DEBUG_SCREEN, "RSSCreen init physical: {id: %{public}" PRIu64 ", w * h: [%{public}u * %{public}u],"
88             "screenType: %{public}u}", id_, width_, height_, screenType_);
89     }
90     capability_.props.clear();
91 }
92 
RSScreen(const VirtualScreenConfigs & configs)93 RSScreen::RSScreen(const VirtualScreenConfigs &configs)
94     : id_(configs.id),
95       mirrorId_(configs.mirrorId),
96       name_(configs.name),
97       width_(configs.width),
98       height_(configs.height),
99       isVirtual_(true),
100       producerSurface_(configs.surface),
101       pixelFormat_(configs.pixelFormat),
102       screenType_(RSScreenType::VIRTUAL_TYPE_SCREEN),
103       whiteList_(configs.whiteList)
104 {
105     VirtualScreenInit();
106     RS_LOGD_IF(DEBUG_SCREEN, "RSSCreen init virtual: {id: %{public}" PRIu64 ", mirrorId: %{public}" PRIu64 ", "
107         "w * h: [%{public}u * %{public}u], name: %{public}s, screenType: %{public}u}",
108         id_, mirrorId_, width_, height_, name_.c_str(), screenType_);
109 }
110 
~RSScreen()111 RSScreen::~RSScreen() noexcept
112 {
113 }
114 
VirtualScreenInit()115 void RSScreen::VirtualScreenInit() noexcept
116 {
117     hdrCapability_.formatCount = 0;
118     for (auto item : supportedVirtualHDRFormats_) {
119         hdrCapability_.formats.emplace_back(RS_TO_HDI_HDR_FORMAT_MAP[item]);
120         ++hdrCapability_.formatCount;
121     }
122 }
123 
PhysicalScreenInit()124 void RSScreen::PhysicalScreenInit() noexcept
125 {
126     hdiScreen_ = HdiScreen::CreateHdiScreen(ScreenPhysicalId(id_));
127     if (hdiScreen_ == nullptr) {
128         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to CreateHdiScreens.",
129             __func__, id_);
130         return;
131     }
132 
133     hdiScreen_->Init();
134     if (hdiScreen_->GetScreenSupportedModes(supportedModes_) < 0) {
135         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to GetScreenSupportedModes.",
136             __func__, id_);
137     }
138 
139     if (hdiScreen_->GetHDRCapabilityInfos(hdrCapability_) < 0) {
140         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to GetHDRCapabilityInfos.",
141             __func__, id_);
142     }
143     std::transform(hdrCapability_.formats.begin(), hdrCapability_.formats.end(),
144                    back_inserter(supportedPhysicalHDRFormats_),
145                    [](GraphicHDRFormat item) -> ScreenHDRFormat {return HDI_HDR_FORMAT_TO_RS_MAP[item];});
146     auto status = GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON;
147     if (hdiScreen_->SetScreenPowerStatus(status) < 0) {
148         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to SetScreenPowerStatus.",
149             __func__, id_);
150     }
151     auto activeMode = GetActiveMode();
152     if (activeMode) {
153         phyWidth_ = activeMode->width;
154         phyHeight_ = activeMode->height;
155         width_ = phyWidth_;
156         height_ = phyHeight_;
157     }
158     if (hdiScreen_->GetScreenPowerStatus(powerStatus_) < 0) {
159         powerStatus_ = static_cast<GraphicDispPowerStatus>(INVALID_POWER_STATUS);
160     }
161     if (capability_.type == GraphicInterfaceType::GRAPHIC_DISP_INTF_MIPI) {
162         screenType_ = RSScreenType::BUILT_IN_TYPE_SCREEN;
163     } else {
164         screenType_ = RSScreenType::EXTERNAL_TYPE_SCREEN;
165     }
166     ScreenCapabilityInit();
167 
168     std::vector<GraphicColorGamut> supportedColorGamuts;
169     if (hdiScreen_->GetScreenSupportedColorGamuts(supportedColorGamuts) != GRAPHIC_DISPLAY_SUCCESS) {
170         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to GetScreenSupportedColorGamuts.",
171             __func__, id_);
172     } else {
173         int index = 0;
174         for (auto item : supportedColorGamuts) {
175             supportedPhysicalColorGamuts_.push_back(static_cast<ScreenColorGamut>(item));
176             if (item == GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB) {
177                 currentPhysicalColorGamutIdx_ = index;
178             }
179             ++index;
180         }
181     }
182     screenBacklightLevel_ = GetScreenBacklight();
183 }
184 
ScreenCapabilityInit()185 void RSScreen::ScreenCapabilityInit() noexcept
186 {
187     if (!hdiScreen_) {
188         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
189         return;
190     }
191     if (IsVirtual()) {
192         RS_LOGW("RSScreen %{public}s: this is virtual screen, use the default display capability.",  __func__);
193         return;
194     }
195     int32_t ret = hdiScreen_->GetScreenCapability(capability_);
196     if (ret != GRAPHIC_DISPLAY_SUCCESS) {
197         RS_LOGW("RSScreen %{public}s: get display capability failed, ret is %{public}d, use the default"
198             " display capability.", __func__, ret);
199         capability_ = {
200             .name = "test1",
201             .type = GRAPHIC_DISP_INTF_HDMI,
202             .phyWidth = 1921,
203             .phyHeight = 1081,
204             .supportLayers = 0,
205             .virtualDispCount = 0,
206             .supportWriteBack = true,
207             .propertyCount = 0
208         };
209     }
210 }
211 
Id() const212 ScreenId RSScreen::Id() const
213 {
214     return id_;
215 }
216 
MirrorId() const217 ScreenId RSScreen::MirrorId() const
218 {
219     return mirrorId_;
220 }
221 
SetMirror(ScreenId mirrorId)222 void RSScreen::SetMirror(ScreenId mirrorId)
223 {
224     mirrorId_ = mirrorId;
225 }
226 
Name() const227 const std::string& RSScreen::Name() const
228 {
229     return name_;
230 }
231 
Width() const232 uint32_t RSScreen::Width() const
233 {
234     return width_;
235 }
236 
Height() const237 uint32_t RSScreen::Height() const
238 {
239     return height_;
240 }
241 
PhyWidth() const242 uint32_t RSScreen::PhyWidth() const
243 {
244     return phyWidth_;
245 }
246 
PhyHeight() const247 uint32_t RSScreen::PhyHeight() const
248 {
249     return phyHeight_;
250 }
251 
IsEnable() const252 bool RSScreen::IsEnable() const
253 {
254     if (id_ == INVALID_SCREEN_ID) {
255         return false;
256     }
257 
258     if (!hdiOutput_ && !producerSurface_) {
259         return false;
260     }
261 
262     // [PLANNING]: maybe need more information to judge whether this screen is enable.
263     return true;
264 }
265 
IsVirtual() const266 bool RSScreen::IsVirtual() const
267 {
268     return isVirtual_;
269 }
270 
SetActiveMode(uint32_t modeId)271 void RSScreen::SetActiveMode(uint32_t modeId)
272 {
273     if (IsVirtual()) {
274         RS_LOGW("RSScreen %{public}s: virtual screen not support SetActiveMode.", __func__);
275         return;
276     }
277     if (!hdiScreen_) {
278         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
279         return;
280     }
281 
282     if (modeId >= supportedModes_.size()) {
283         RS_LOGE("RSScreen %{public}s: set fails because the index is out of bounds.", __func__);
284         return;
285     }
286     RS_LOGD_IF(DEBUG_SCREEN, "RSScreen set active mode: %{public}u", modeId);
287     int32_t selectModeId = supportedModes_[modeId].id;
288     if (hdiScreen_->SetScreenMode(static_cast<uint32_t>(selectModeId)) < 0) {
289         RS_LOGE("RSScreen %{public}s: Hdi SetScreenMode fails.", __func__);
290         return;
291     }
292     auto activeMode = GetActiveMode();
293     if (activeMode) {
294         phyWidth_ = activeMode->width;
295         phyHeight_ = activeMode->height;
296         static GraphicDisplayModeInfo modeInfo;
297         if ((modeInfo.freshRate != activeMode->freshRate)
298             || modeInfo.width != activeMode->width || modeInfo.height != activeMode->height) {
299             HiSysEventWrite(HiSysEvent::Domain::GRAPHIC, "EPS_LCD_FREQ",
300                 HiSysEvent::EventType::STATISTIC, "SOURCERATE", modeInfo.freshRate,
301                 "TARGETRATE", activeMode->freshRate, "WIDTH", phyWidth_, "HEIGHT", phyHeight_);
302             modeInfo = activeMode.value();
303         }
304     }
305 }
306 
SetRogResolution(uint32_t width,uint32_t height)307 void RSScreen::SetRogResolution(uint32_t width, uint32_t height)
308 {
309     if (!hdiScreen_) {
310         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
311         return;
312     }
313     if ((width == 0 || height == 0) ||
314         (width == width_ && height == height_) ||
315         (width > phyWidth_ || height > phyHeight_)) {
316         RS_LOGD("RSScreen:%{public}s: width: %{public}d, height: %{public}d.", __func__, width, height);
317         return;
318     }
319     if (hdiScreen_->SetScreenOverlayResolution(width, height) < 0) {
320         RS_LOGD("RSScreen:%{public}s: hdi set screen rog resolution failed.", __func__);
321     }
322     width_ = width;
323     height_ = height;
324     RS_LOGI("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 "), width: %{public}d,"
325         " height: %{public}d, phywidth: %{public}d, phyHeight: %{public}d.",
326 	    __func__, id_, width_, height_, phyWidth_, phyHeight_);
327 }
328 
329 
SetResolution(uint32_t width,uint32_t height)330 void RSScreen::SetResolution(uint32_t width, uint32_t height)
331 {
332     if (!IsVirtual()) {
333         RS_LOGW("RSScreen %{public}s: physical screen not support SetResolution.", __func__);
334         return;
335     }
336     RS_LOGD_IF(DEBUG_SCREEN, "RSScreen set resolution, w * h: [%{public}u * %{public}u]", width, height);
337     width_ = width;
338     height_ = height;
339 }
340 
GetActiveModePosByModeId(int32_t modeId) const341 int32_t RSScreen::GetActiveModePosByModeId(int32_t modeId) const
342 {
343     decltype(supportedModes_.size()) modeIndex = 0;
344     for (; modeIndex < supportedModes_.size(); ++modeIndex) {
345         if (supportedModes_[modeIndex].id == modeId) {
346             return static_cast<int32_t>(modeIndex);
347         }
348     }
349     return -1;
350 }
351 
SetPowerStatus(uint32_t powerStatus)352 void RSScreen::SetPowerStatus(uint32_t powerStatus)
353 {
354     if (!hdiScreen_) {
355         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
356         return;
357     }
358     if (IsVirtual()) {
359         RS_LOGW("[UL_POWER]RSScreen %{public}s: virtual screen not support SetPowerStatus.", __func__);
360         return;
361     }
362 
363     RS_LOGI("[UL_POWER]RSScreen_%{public}" PRIu64 " SetPowerStatus, status is %{public}u", id_, powerStatus);
364     RS_TRACE_NAME_FMT("[UL_POWER]Screen_%llu SetPowerStatus %u", id_, powerStatus);
365     if (hdiScreen_->SetScreenPowerStatus(static_cast<GraphicDispPowerStatus>(powerStatus)) < 0) {
366         return;
367     }
368 
369     if (powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON ||
370         powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON_ADVANCED) {
371         RS_LOGD("RSScreen %{public}s Enable hardware vsync", __func__);
372         if (hdiScreen_->SetScreenVsyncEnabled(true) != GRAPHIC_DISPLAY_SUCCESS) {
373             RS_LOGE("RSScreen %{public}s SetScreenVsyncEnabled failed", __func__);
374         }
375     }
376 }
377 
GetActiveMode() const378 std::optional<GraphicDisplayModeInfo> RSScreen::GetActiveMode() const
379 {
380     if (IsVirtual()) {
381         RS_LOGW("RSScreen %{public}s: virtual screen not support GetActiveMode.", __func__);
382         return {};
383     }
384 
385     uint32_t modeId = 0;
386 
387     if (hdiScreen_ == nullptr) {
388         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") hdiScreen is null.",
389             __func__, id_);
390         return {};
391     }
392 
393     if (hdiScreen_->GetScreenMode(modeId) < 0) {
394         RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") GetScreenMode failed.",
395             __func__, id_);
396         return {};
397     }
398 
399     auto iter = std::find_if(supportedModes_.cbegin(), supportedModes_.cend(),
400         [modeId](const auto &mode) { return static_cast<uint32_t>(mode.id) == modeId; });
401     if (iter == supportedModes_.cend()) {
402         return {};
403     }
404 
405     return *iter;
406 }
407 
GetSupportedModes() const408 const std::vector<GraphicDisplayModeInfo>& RSScreen::GetSupportedModes() const
409 {
410     return supportedModes_;
411 }
412 
GetCapability() const413 const GraphicDisplayCapability& RSScreen::GetCapability() const
414 {
415     return capability_;
416 }
417 
GetPowerStatus() const418 uint32_t RSScreen::GetPowerStatus() const
419 {
420     if (IsVirtual()) {
421         RS_LOGW("RSScreen %{public}s: virtual screen not support GetPowerStatus.", __func__);
422         return ScreenPowerStatus::INVALID_POWER_STATUS;
423     }
424 
425     if (!hdiScreen_) {
426         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
427         return INVALID_POWER_STATUS;
428     }
429     GraphicDispPowerStatus status;
430     if (!hdiScreen_) {
431         RS_LOGW("RSScreen %{public}s: hdiScreen_ is nullptr.", __func__);
432         return INVALID_POWER_STATUS;
433     }
434     if (hdiScreen_->GetScreenPowerStatus(status) < 0) {
435         return INVALID_POWER_STATUS;
436     }
437     return static_cast<uint32_t>(status);
438 }
439 
GetOutput() const440 std::shared_ptr<HdiOutput> RSScreen::GetOutput() const
441 {
442     return hdiOutput_;
443 }
444 
GetProducerSurface() const445 sptr<Surface> RSScreen::GetProducerSurface() const
446 {
447     return producerSurface_;
448 }
449 
SetProducerSurface(sptr<Surface> producerSurface)450 void RSScreen::SetProducerSurface(sptr<Surface> producerSurface)
451 {
452     producerSurface_ = producerSurface;
453     isVirtualSurfaceUpdateFlag_ = true;
454 }
455 
GetAndResetVirtualSurfaceUpdateFlag()456 bool RSScreen::GetAndResetVirtualSurfaceUpdateFlag()
457 {
458     if (isVirtualSurfaceUpdateFlag_) {
459         isVirtualSurfaceUpdateFlag_ = false;
460         return true;
461     }
462     return false;
463 }
464 
ModeInfoDump(std::string & dumpString)465 void RSScreen::ModeInfoDump(std::string& dumpString)
466 {
467     decltype(supportedModes_.size()) modeIndex = 0;
468     for (; modeIndex < supportedModes_.size(); ++modeIndex) {
469         AppendFormat(dumpString, "  supportedMode[%d]: %dx%d, refreshrate=%d\n",
470                      modeIndex, supportedModes_[modeIndex].width,
471                      supportedModes_[modeIndex].height, supportedModes_[modeIndex].freshRate);
472     }
473     std::optional<GraphicDisplayModeInfo> activeMode = GetActiveMode();
474     if (activeMode) {
475         AppendFormat(dumpString, "  activeMode: %dx%d, refreshrate=%d\n",
476             activeMode->width, activeMode->height, activeMode->freshRate);
477     }
478 }
479 
CapabilityTypeDump(GraphicInterfaceType capabilityType,std::string & dumpString)480 void RSScreen::CapabilityTypeDump(GraphicInterfaceType capabilityType, std::string& dumpString)
481 {
482     dumpString += "type=";
483     switch (capabilityType) {
484         case GRAPHIC_DISP_INTF_HDMI: {
485             dumpString += "DISP_INTF_HDMI, ";
486             break;
487         }
488         case GRAPHIC_DISP_INTF_LCD: {
489             dumpString += "DISP_INTF_LCD, ";
490             break;
491         }
492         case GRAPHIC_DISP_INTF_BT1120: {
493             dumpString += "DISP_INTF_BT1120, ";
494             break;
495         }
496         case GRAPHIC_DISP_INTF_BT656: {
497             dumpString += "DISP_INTF_BT656, ";
498             break;
499         }
500         default:
501             dumpString += "INVILID_DISP_INTF, ";
502             break;
503     }
504 }
505 
CapabilityDump(std::string & dumpString)506 void RSScreen::CapabilityDump(std::string& dumpString)
507 {
508     AppendFormat(dumpString, "  capability: name=%s, phywidth=%d, phyheight=%d,"
509                  "supportlayers=%d, virtualDispCount=%d, propCount=%d, ",
510                  capability_.name.c_str(), capability_.phyWidth, capability_.phyHeight,
511                  capability_.supportLayers, capability_.virtualDispCount, capability_.propertyCount);
512     CapabilityTypeDump(capability_.type, dumpString);
513     dumpString += "supportWriteBack=";
514     dumpString += (capability_.supportWriteBack) ? "true" : "false";
515     dumpString += "\n";
516     PropDump(dumpString);
517 }
518 
PropDump(std::string & dumpString)519 void RSScreen::PropDump(std::string& dumpString)
520 {
521     decltype(capability_.propertyCount) propIndex = 0;
522     for (; propIndex < capability_.propertyCount; ++propIndex) {
523         AppendFormat(dumpString, "prop[%u]: name=%s, propid=%d, value=%d\n",
524                      propIndex, capability_.props[propIndex].name.c_str(), capability_.props[propIndex].propId,
525                      capability_.props[propIndex].value);
526     }
527 }
528 
PowerStatusDump(std::string & dumpString)529 void RSScreen::PowerStatusDump(std::string& dumpString)
530 {
531     dumpString += "powerstatus=";
532     switch (GetPowerStatus()) {
533         case GRAPHIC_POWER_STATUS_ON: {
534             dumpString += "POWER_STATUS_ON";
535             break;
536         }
537         case GRAPHIC_POWER_STATUS_STANDBY: {
538             dumpString += "POWER_STATUS_STANDBY";
539             break;
540         }
541         case GRAPHIC_POWER_STATUS_SUSPEND: {
542             dumpString += "POWER_STATUS_SUSPEND";
543             break;
544         }
545         case GRAPHIC_POWER_STATUS_OFF: {
546             dumpString += "POWER_STATUS_OFF";
547             break;
548         }
549         case GRAPHIC_POWER_STATUS_OFF_FAKE: {
550             dumpString += "POWER_STATUS_OFF_FAKE";
551             break;
552         }
553         case GRAPHIC_POWER_STATUS_BUTT: {
554             dumpString += "POWER_STATUS_BUTT";
555             break;
556         }
557         case GRAPHIC_POWER_STATUS_ON_ADVANCED: {
558             dumpString += "POWER_STATUS_ON_ADVANCED";
559             break;
560         }
561         case GRAPHIC_POWER_STATUS_OFF_ADVANCED: {
562             dumpString += "POWER_STATUS_OFF_ADVANCED";
563             break;
564         }
565         default: {
566             dumpString += "INVALID_POWER_STATUS";
567             break;
568         }
569     }
570 }
571 
572 
DisplayDump(int32_t screenIndex,std::string & dumpString)573 void RSScreen::DisplayDump(int32_t screenIndex, std::string& dumpString)
574 {
575     dumpString += "-- ScreenInfo\n";
576     if (IsVirtual()) {
577         dumpString += "screen[" + std::to_string(screenIndex) + "]: ";
578         dumpString += "id=";
579         dumpString += (id_ == INVALID_SCREEN_ID) ? "INVALID_SCREEN_ID" : std::to_string(id_);
580         dumpString += ", ";
581         dumpString += "mirrorId=";
582         dumpString += (mirrorId_ == INVALID_SCREEN_ID) ? "INVALID_SCREEN_ID" : std::to_string(mirrorId_);
583         dumpString += ", ";
584         AppendFormat(dumpString, ", render size: %dx%d, isvirtual=true, skipFrameInterval_:%d\n",
585             width_, height_, skipFrameInterval_);
586     } else {
587         dumpString += "screen[" + std::to_string(screenIndex) + "]: ";
588         dumpString += "id=";
589         dumpString += (id_ == INVALID_SCREEN_ID) ? "INVALID_SCREEN_ID" : std::to_string(id_);
590         dumpString += ", ";
591         PowerStatusDump(dumpString);
592         dumpString += ", ";
593         dumpString += "backlight=" + std::to_string(GetScreenBacklight());
594         dumpString += ", ";
595         ScreenTypeDump(dumpString);
596         AppendFormat(dumpString,
597             ", render size: %dx%d, physical screen resolution: %dx%d, isvirtual=false, skipFrameInterval_:%d\n",
598             width_, height_, phyWidth_, phyHeight_, skipFrameInterval_);
599         dumpString += "\n";
600         ModeInfoDump(dumpString);
601         CapabilityDump(dumpString);
602     }
603 }
604 
ScreenTypeDump(std::string & dumpString)605 void RSScreen::ScreenTypeDump(std::string& dumpString)
606 {
607     dumpString += "screenType=";
608     switch (screenType_) {
609         case RSScreenType::BUILT_IN_TYPE_SCREEN: {
610             dumpString += "BUILT_IN_TYPE";
611             break;
612         }
613         case RSScreenType::EXTERNAL_TYPE_SCREEN: {
614             dumpString += "EXTERNAL_TYPE";
615             break;
616         }
617         case RSScreenType::VIRTUAL_TYPE_SCREEN: {
618             dumpString += "VIRTUAL_TYPE";
619             break;
620         }
621         default: {
622             dumpString += "UNKNOWN_TYPE";
623             break;
624         }
625     }
626 }
627 
SurfaceDump(int32_t screenIndex,std::string & dumpString)628 void RSScreen::SurfaceDump(int32_t screenIndex, std::string& dumpString)
629 {
630     if (hdiOutput_ == nullptr) {
631         RS_LOGW("RSScreen %{public}s: hdiOutput_ is nullptr.", __func__);
632         return;
633     }
634     hdiOutput_->Dump(dumpString);
635 }
636 
FpsDump(int32_t screenIndex,std::string & dumpString,std::string & arg)637 void RSScreen::FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg)
638 {
639     if (hdiOutput_ == nullptr) {
640         RS_LOGW("RSScreen %{public}s: hdiOutput_ is nullptr.", __func__);
641         return;
642     }
643     hdiOutput_->DumpFps(dumpString, arg);
644 }
645 
ClearFpsDump(int32_t screenIndex,std::string & dumpString,std::string & arg)646 void RSScreen::ClearFpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg)
647 {
648     if (hdiOutput_ == nullptr) {
649         RS_LOGW("RSScreen %{public}s: hdiOutput_ is nullptr.", __func__);
650         return;
651     }
652     hdiOutput_->ClearFpsDump(dumpString, arg);
653 }
654 
HitchsDump(int32_t screenIndex,std::string & dumpString,std::string & arg)655 void RSScreen::HitchsDump(int32_t screenIndex, std::string& dumpString, std::string& arg)
656 {
657     if (hdiOutput_ == nullptr) {
658         RS_LOGW("RSScreen %{public}s: hdiOutput_ is nullptr.", __func__);
659         return;
660     }
661     hdiOutput_->DumpHitchs(dumpString, arg);
662 }
663 
ResizeVirtualScreen(uint32_t width,uint32_t height)664 void RSScreen::ResizeVirtualScreen(uint32_t width, uint32_t height)
665 {
666     if (!IsVirtual()) {
667         RS_LOGW("RSScreen %{public}s: physical screen not support ResizeVirtualScreen.", __func__);
668         return;
669     }
670     width_ = width;
671     height_ = height;
672 }
673 
SetScreenBacklight(uint32_t level)674 void RSScreen::SetScreenBacklight(uint32_t level)
675 {
676     if (!hdiScreen_) {
677         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
678         return;
679     }
680     if (IsVirtual()) {
681         RS_LOGW("RSScreen %{public}s: virtual screen not support SetScreenBacklight.", __func__);
682         return;
683     }
684 
685     RS_LOGD("RSScreen_%{public}" PRIu64 " SetScreenBacklight, level is %{public}u", id_, level);
686     if (hdiScreen_->SetScreenBacklight(level) < 0) {
687         return;
688     }
689     screenBacklightLevel_ = static_cast<int32_t>(level);
690 }
691 
GetScreenBacklight() const692 int32_t RSScreen::GetScreenBacklight() const
693 {
694     if (IsVirtual()) {
695         RS_LOGW("RSScreen %{public}s: virtual screen not support GetScreenBacklight.", __func__);
696         return INVALID_BACKLIGHT_VALUE;
697     }
698     uint32_t level = 0;
699     if (screenBacklightLevel_ != INVALID_BACKLIGHT_VALUE) {
700         return screenBacklightLevel_;
701     }
702     if (!hdiScreen_) {
703         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
704         return INVALID_BACKLIGHT_VALUE;
705     }
706     if (hdiScreen_->GetScreenBacklight(level) < 0) {
707         return INVALID_BACKLIGHT_VALUE;
708     }
709     return static_cast<int32_t>(level);
710 }
711 
GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut> & mode) const712 int32_t RSScreen::GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut> &mode) const
713 {
714     mode.clear();
715     if (IsVirtual()) {
716         mode = supportedVirtualColorGamuts_;
717     } else {
718         mode = supportedPhysicalColorGamuts_;
719     }
720     if (mode.size() == 0) {
721         return StatusCode::HDI_ERROR;
722     }
723     return StatusCode::SUCCESS;
724 }
725 
GetScreenSupportedMetaDataKeys(std::vector<ScreenHDRMetadataKey> & keys) const726 int32_t RSScreen::GetScreenSupportedMetaDataKeys(std::vector<ScreenHDRMetadataKey> &keys) const
727 {
728     if (IsVirtual()) {
729         RS_LOGW("RSScreen %{public}s: virtual screen not support GetScreenSupportedMetaDataKeys.", __func__);
730         return INVALID_BACKLIGHT_VALUE;
731     }
732 
733     // ScreenHDRMetadataKey now is mock data.
734     keys.push_back(ScreenHDRMetadataKey::MATAKEY_RED_PRIMARY_X);
735     keys.push_back(ScreenHDRMetadataKey::MATAKEY_RED_PRIMARY_Y);
736     keys.push_back(ScreenHDRMetadataKey::MATAKEY_GREEN_PRIMARY_X);
737     keys.push_back(ScreenHDRMetadataKey::MATAKEY_GREEN_PRIMARY_Y);
738     keys.push_back(ScreenHDRMetadataKey::MATAKEY_BLUE_PRIMARY_X);
739     keys.push_back(ScreenHDRMetadataKey::MATAKEY_BLUE_PRIMARY_Y);
740     keys.push_back(ScreenHDRMetadataKey::MATAKEY_WHITE_PRIMARY_X);
741     keys.push_back(ScreenHDRMetadataKey::MATAKEY_WHITE_PRIMARY_Y);
742     keys.push_back(ScreenHDRMetadataKey::MATAKEY_MAX_LUMINANCE);
743     keys.push_back(ScreenHDRMetadataKey::MATAKEY_MIN_LUMINANCE);
744     keys.push_back(ScreenHDRMetadataKey::MATAKEY_MAX_CONTENT_LIGHT_LEVEL);
745     keys.push_back(ScreenHDRMetadataKey::MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL);
746     keys.push_back(ScreenHDRMetadataKey::MATAKEY_HDR10_PLUS);
747     keys.push_back(ScreenHDRMetadataKey::MATAKEY_HDR_VIVID);
748     return StatusCode::SUCCESS;
749 }
750 
GetScreenColorGamut(ScreenColorGamut & mode) const751 int32_t RSScreen::GetScreenColorGamut(ScreenColorGamut &mode) const
752 {
753     if (IsVirtual()) {
754         mode = supportedVirtualColorGamuts_[currentVirtualColorGamutIdx_];
755         return StatusCode::SUCCESS;
756     } else {
757         if (supportedPhysicalColorGamuts_.size() == 0) {
758             return StatusCode::HDI_ERROR;
759         }
760         mode = supportedPhysicalColorGamuts_[currentPhysicalColorGamutIdx_];
761         return StatusCode::SUCCESS;
762     }
763     return StatusCode::HDI_ERROR;
764 }
765 
SetScreenColorGamut(int32_t modeIdx)766 int32_t RSScreen::SetScreenColorGamut(int32_t modeIdx)
767 {
768     if (modeIdx < 0) {
769         return StatusCode::INVALID_ARGUMENTS;
770     }
771     if (IsVirtual()) {
772         if (modeIdx >= static_cast<int32_t>(supportedVirtualColorGamuts_.size())) {
773             return StatusCode::INVALID_ARGUMENTS;
774         }
775         currentVirtualColorGamutIdx_ = modeIdx;
776         return StatusCode::SUCCESS;
777     }
778     if (!hdiScreen_) {
779         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
780         return StatusCode::HDI_ERROR;
781     }
782     std::vector<GraphicColorGamut> hdiMode;
783     if (hdiScreen_->GetScreenSupportedColorGamuts(hdiMode) != GRAPHIC_DISPLAY_SUCCESS) {
784         return StatusCode::HDI_ERROR;
785     }
786     if (modeIdx >= static_cast<int32_t>(hdiMode.size())) {
787         return StatusCode::INVALID_ARGUMENTS;
788     }
789     int32_t result = hdiScreen_->SetScreenColorGamut(hdiMode[modeIdx]);
790     if (result == GRAPHIC_DISPLAY_SUCCESS) {
791         currentPhysicalColorGamutIdx_ = modeIdx;
792         return StatusCode::SUCCESS;
793     }
794     return StatusCode::HDI_ERROR;
795 }
796 
SetScreenGamutMap(ScreenGamutMap mode)797 int32_t RSScreen::SetScreenGamutMap(ScreenGamutMap mode)
798 {
799     if (IsVirtual()) {
800         currentVirtualGamutMap_ = mode;
801         return StatusCode::SUCCESS;
802     }
803     if (!hdiScreen_) {
804         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
805         return StatusCode::HDI_ERROR;
806     }
807     int32_t result = hdiScreen_->SetScreenGamutMap(static_cast<GraphicGamutMap>(mode));
808     if (result == GRAPHIC_DISPLAY_SUCCESS) {
809         return StatusCode::SUCCESS;
810     }
811     return StatusCode::HDI_ERROR;
812 }
813 
SetScreenCorrection(ScreenRotation screenRotation)814 void RSScreen::SetScreenCorrection(ScreenRotation screenRotation)
815 {
816     RS_LOGD("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") ,ScreenRotation: %{public}d.",
817             __func__, id_, static_cast<uint32_t>(screenRotation));
818     screenRotation_ = screenRotation;
819 }
820 
GetScreenCorrection() const821 ScreenRotation RSScreen::GetScreenCorrection() const
822 {
823     return screenRotation_;
824 }
825 
GetScreenGamutMap(ScreenGamutMap & mode) const826 int32_t RSScreen::GetScreenGamutMap(ScreenGamutMap &mode) const
827 {
828     if (IsVirtual()) {
829         mode = currentVirtualGamutMap_;
830         return StatusCode::SUCCESS;
831     }
832     if (!hdiScreen_) {
833         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
834         return StatusCode::HDI_ERROR;
835     }
836     GraphicGamutMap hdiMode;
837     int32_t result = hdiScreen_->GetScreenGamutMap(hdiMode);
838     if (result == GRAPHIC_DISPLAY_SUCCESS) {
839         mode = static_cast<ScreenGamutMap>(hdiMode);
840         return StatusCode::SUCCESS;
841     }
842     return StatusCode::HDI_ERROR;
843 }
844 
GetHDRCapability()845 const GraphicHDRCapability& RSScreen::GetHDRCapability()
846 {
847     hdrCapability_.maxLum = MAX_LUM; // mock data
848     return hdrCapability_;
849 }
850 
GetScreenType() const851 const RSScreenType& RSScreen::GetScreenType() const
852 {
853     return screenType_;
854 }
855 
SetScreenSkipFrameInterval(uint32_t skipFrameInterval)856 void RSScreen::SetScreenSkipFrameInterval(uint32_t skipFrameInterval)
857 {
858     skipFrameInterval_ = skipFrameInterval;
859 }
860 
GetScreenSkipFrameInterval() const861 uint32_t RSScreen::GetScreenSkipFrameInterval() const
862 {
863     return skipFrameInterval_;
864 }
865 
SetScreenVsyncEnabled(bool enabled) const866 void RSScreen::SetScreenVsyncEnabled(bool enabled) const
867 {
868     if (IsVirtual()) {
869         return;
870     }
871     if (hdiScreen_ != nullptr) {
872         hdiScreen_->SetScreenVsyncEnabled(enabled);
873     }
874 }
875 
SetVirtualMirrorScreenCanvasRotation(bool canvasRotation)876 bool RSScreen::SetVirtualMirrorScreenCanvasRotation(bool canvasRotation)
877 {
878     if (IsVirtual()) {
879         canvasRotation_ = canvasRotation;
880         return true;
881     }
882     return false;
883 }
884 
GetCanvasRotation() const885 bool RSScreen::GetCanvasRotation() const
886 {
887     return canvasRotation_;
888 }
889 
SetVirtualMirrorScreenScaleMode(ScreenScaleMode scaleMode)890 bool RSScreen::SetVirtualMirrorScreenScaleMode(ScreenScaleMode scaleMode)
891 {
892     if (IsVirtual()) {
893         scaleMode_ = scaleMode;
894         return true;
895     }
896     return false;
897 }
898 
GetScaleMode() const899 ScreenScaleMode RSScreen::GetScaleMode() const
900 {
901     return scaleMode_;
902 }
903 
GetScreenSupportedHDRFormats(std::vector<ScreenHDRFormat> & hdrFormats) const904 int32_t RSScreen::GetScreenSupportedHDRFormats(std::vector<ScreenHDRFormat>& hdrFormats) const
905 {
906     hdrFormats.clear();
907     if (IsVirtual()) {
908         hdrFormats = supportedVirtualHDRFormats_;
909     } else {
910         hdrFormats = supportedPhysicalHDRFormats_;
911     }
912     if (hdrFormats.size() == 0) {
913         return StatusCode::HDI_ERROR;
914     }
915     return StatusCode::SUCCESS;
916 }
917 
GetScreenHDRFormat(ScreenHDRFormat & hdrFormat) const918 int32_t RSScreen::GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const
919 {
920     if (IsVirtual()) {
921         hdrFormat = supportedVirtualHDRFormats_[currentVirtualHDRFormatIdx_];
922         return StatusCode::SUCCESS;
923     } else {
924         if (supportedPhysicalHDRFormats_.size() == 0) {
925             return StatusCode::HDI_ERROR;
926         }
927         hdrFormat = supportedPhysicalHDRFormats_[currentPhysicalHDRFormatIdx_];
928         return StatusCode::SUCCESS;
929     }
930     return StatusCode::HDI_ERROR;
931 }
932 
SetScreenHDRFormat(int32_t modeIdx)933 int32_t RSScreen::SetScreenHDRFormat(int32_t modeIdx)
934 {
935     if (modeIdx < 0) {
936         return StatusCode::INVALID_ARGUMENTS;
937     }
938     if (IsVirtual()) {
939         if (modeIdx >= static_cast<int32_t>(supportedVirtualHDRFormats_.size())) {
940             return StatusCode::INVALID_ARGUMENTS;
941         }
942         currentVirtualHDRFormatIdx_ = modeIdx;
943         return StatusCode::SUCCESS;
944     } else {
945         // There should be some hdi operation
946         if (modeIdx >= static_cast<int32_t>(hdrCapability_.formats.size())) {
947             return StatusCode::INVALID_ARGUMENTS;
948         }
949         currentPhysicalHDRFormatIdx_ = modeIdx;
950         return StatusCode::SUCCESS;
951     }
952     return StatusCode::HDI_ERROR;
953 }
954 
GetPixelFormat(GraphicPixelFormat & pixelFormat) const955 int32_t RSScreen::GetPixelFormat(GraphicPixelFormat& pixelFormat) const
956 {
957     pixelFormat = pixelFormat_;
958     return StatusCode::SUCCESS;
959 }
960 
SetPixelFormat(GraphicPixelFormat pixelFormat)961 int32_t RSScreen::SetPixelFormat(GraphicPixelFormat pixelFormat)
962 {
963     pixelFormat_ = pixelFormat;
964     return StatusCode::SUCCESS;
965 }
966 
GetScreenSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType> & colorSpaces) const967 int32_t RSScreen::GetScreenSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType>& colorSpaces) const
968 {
969     colorSpaces.clear();
970     if (IsVirtual()) {
971         std::transform(supportedVirtualColorGamuts_.begin(), supportedVirtualColorGamuts_.end(),
972                        back_inserter(colorSpaces),
973                        [](ScreenColorGamut item) -> GraphicCM_ColorSpaceType {
974                             return RS_TO_COMMON_COLOR_SPACE_TYPE_MAP[static_cast<GraphicColorGamut>(item)];
975                         });
976     } else {
977         std::transform(supportedPhysicalColorGamuts_.begin(), supportedPhysicalColorGamuts_.end(),
978                        back_inserter(colorSpaces),
979                        [](ScreenColorGamut item) -> GraphicCM_ColorSpaceType {
980                             return RS_TO_COMMON_COLOR_SPACE_TYPE_MAP[static_cast<GraphicColorGamut>(item)];
981                         });
982     }
983     if (colorSpaces.size() == 0) {
984         return StatusCode::HDI_ERROR;
985     }
986     return StatusCode::SUCCESS;
987 }
988 
GetScreenColorSpace(GraphicCM_ColorSpaceType & colorSpace) const989 int32_t RSScreen::GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const
990 {
991     ScreenColorGamut curGamut;
992     int32_t result = GetScreenColorGamut(curGamut);
993     colorSpace = RS_TO_COMMON_COLOR_SPACE_TYPE_MAP[static_cast<GraphicColorGamut>(curGamut)];
994     return result;
995 }
996 
SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace)997 int32_t RSScreen::SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace)
998 {
999     auto iter = COMMON_COLOR_SPACE_TYPE_TO_RS_MAP.find(colorSpace);
1000     if (iter == COMMON_COLOR_SPACE_TYPE_TO_RS_MAP.end()) {
1001         return StatusCode::INVALID_ARGUMENTS;
1002     }
1003     ScreenColorGamut dstColorGamut = static_cast<ScreenColorGamut>(iter->second);
1004     int32_t curIdx;
1005     if (IsVirtual()) {
1006         auto it = std::find(supportedVirtualColorGamuts_.begin(), supportedVirtualColorGamuts_.end(), dstColorGamut);
1007         if (it == supportedVirtualColorGamuts_.end()) {
1008             return StatusCode::INVALID_ARGUMENTS;
1009         }
1010         curIdx = std::distance(supportedVirtualColorGamuts_.begin(), it);
1011         currentVirtualColorGamutIdx_ = curIdx;
1012         return StatusCode::SUCCESS;
1013     }
1014     if (!hdiScreen_) {
1015         RS_LOGE("RSScreen %{public}s failed, hdiScreen_ is nullptr",  __func__);
1016         return StatusCode::HDI_ERROR;
1017     }
1018     std::vector<GraphicColorGamut> hdiMode;
1019     if (hdiScreen_->GetScreenSupportedColorGamuts(hdiMode) != GRAPHIC_DISPLAY_SUCCESS) {
1020         return StatusCode::HDI_ERROR;
1021     }
1022     auto it = std::find(hdiMode.begin(), hdiMode.end(), static_cast<GraphicColorGamut>(dstColorGamut));
1023     if (it == hdiMode.end()) {
1024         return StatusCode::INVALID_ARGUMENTS;
1025     }
1026     curIdx = std::distance(hdiMode.begin(), it);
1027     int32_t result = hdiScreen_->SetScreenColorGamut(hdiMode[curIdx]);
1028     if (result == GRAPHIC_DISPLAY_SUCCESS) {
1029         currentPhysicalColorGamutIdx_ = curIdx;
1030         return StatusCode::SUCCESS;
1031     }
1032     return StatusCode::HDI_ERROR;
1033 }
GetWhiteList() const1034 const std::unordered_set<uint64_t>& RSScreen::GetWhiteList() const
1035 {
1036     return whiteList_;
1037 }
1038 
SetBlackList(const std::unordered_set<uint64_t> & blackList)1039 void RSScreen::SetBlackList(const std::unordered_set<uint64_t>& blackList)
1040 {
1041     blackList_ = blackList;
1042 }
1043 
AddBlackList(const std::vector<uint64_t> & blackList)1044 void RSScreen::AddBlackList(const std::vector<uint64_t>& blackList)
1045 {
1046     for (auto& list : blackList) {
1047         blackList_.emplace(list);
1048     }
1049 }
1050 
RemoveBlackList(const std::vector<uint64_t> & blackList)1051 void RSScreen::RemoveBlackList(const std::vector<uint64_t>& blackList)
1052 {
1053     for (auto& list : blackList) {
1054         blackList_.erase(list);
1055     }
1056 }
1057 
SetCastScreenEnableSkipWindow(bool enable)1058 void RSScreen::SetCastScreenEnableSkipWindow(bool enable)
1059 {
1060     skipWindow_ = enable;
1061 }
1062 
GetCastScreenEnableSkipWindow()1063 bool RSScreen::GetCastScreenEnableSkipWindow()
1064 {
1065     return skipWindow_;
1066 }
1067 
GetBlackList() const1068 const std::unordered_set<uint64_t>& RSScreen::GetBlackList() const
1069 {
1070     return blackList_;
1071 }
1072 
SetScreenConstraint(uint64_t frameId,uint64_t timestamp,ScreenConstraintType type)1073 int32_t RSScreen::SetScreenConstraint(uint64_t frameId, uint64_t timestamp, ScreenConstraintType type)
1074 {
1075     if (IsVirtual()) {
1076         return StatusCode::SUCCESS;
1077     }
1078     if (hdiScreen_ != nullptr) {
1079         int32_t result = hdiScreen_->SetScreenConstraint(frameId, timestamp, static_cast<uint32_t>(type));
1080         if (result == GRAPHIC_DISPLAY_SUCCESS) {
1081             return StatusCode::SUCCESS;
1082         }
1083     }
1084     return StatusCode::HDI_ERROR;
1085 }
1086 
SetSecurityExemptionList(const std::vector<uint64_t> & securityExemptionList)1087 void RSScreen::SetSecurityExemptionList(const std::vector<uint64_t>& securityExemptionList)
1088 {
1089     securityExemptionList_ = securityExemptionList;
1090 }
1091 
GetSecurityExemptionList() const1092 const std::vector<uint64_t>& RSScreen::GetSecurityExemptionList() const
1093 {
1094     return securityExemptionList_;
1095 }
1096 } // namespace impl
1097 } // namespace Rosen
1098 } // namespace OHOS
1099