1 /*
2 * Copyright (c) 2023 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 "session/screen/include/screen_property.h"
17 #include "parameters.h"
18 #include "fold_screen_state_internel.h"
19
20 namespace OHOS::Rosen {
21 namespace {
22 constexpr int32_t PHONE_SCREEN_WIDTH = 1344;
23 constexpr int32_t PHONE_SCREEN_HEIGHT = 2772;
24 constexpr float PHONE_SCREEN_DENSITY = 3.5f;
25 constexpr float ELSE_SCREEN_DENSITY = 1.5f;
26 constexpr float INCH_2_MM = 25.4f;
27 constexpr int32_t HALF_VALUE = 2;
28 constexpr int32_t TRUNCATE_TWO_DECIMALS = 100;
29 constexpr int32_t TRUNCATE_THREE_DECIMALS = 1000;
30 constexpr float SECONDARY_ROTATION_90 = 90.0F;
31 constexpr float SECONDARY_ROTATION_270 = 270.0F;
32 constexpr int32_t SECONDARY_FULL_OFFSETY = 1136;
33 constexpr int32_t FULL_STATUS_WIDTH = 2048;
34 constexpr int32_t SCREEN_HEIGHT = 2232;
35 constexpr float EPSILON = 1e-6f;
36 constexpr float PPI_TO_DPI = 1.6f;
37 }
38
SetRotation(float rotation)39 void ScreenProperty::SetRotation(float rotation)
40 {
41 rotation_ = rotation;
42 }
43
GetRotation() const44 float ScreenProperty::GetRotation() const
45 {
46 return rotation_;
47 }
48
SetPhysicalRotation(float rotation)49 void ScreenProperty::SetPhysicalRotation(float rotation)
50 {
51 physicalRotation_ = rotation;
52 }
53
GetPhysicalRotation() const54 float ScreenProperty::GetPhysicalRotation() const
55 {
56 return physicalRotation_;
57 }
58
SetScreenComponentRotation(float rotation)59 void ScreenProperty::SetScreenComponentRotation(float rotation)
60 {
61 screenComponentRotation_ = rotation;
62 }
63
GetScreenComponentRotation() const64 float ScreenProperty::GetScreenComponentRotation() const
65 {
66 return screenComponentRotation_;
67 }
68
SetBounds(const RRect & bounds)69 void ScreenProperty::SetBounds(const RRect& bounds)
70 {
71 bounds_ = bounds;
72 if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) {
73 physicalTouchBounds_.rect_.width_ = bounds_.rect_.width_;
74 physicalTouchBounds_.rect_.height_ = bounds_.rect_.height_;
75 physicalTouchBounds_.rect_.left_ = bounds_.rect_.left_;
76 physicalTouchBounds_.rect_.top_ = bounds_.rect_.top_;
77 }
78 UpdateXDpi();
79 UpdateYDpi();
80 }
81
GetBounds() const82 RRect ScreenProperty::GetBounds() const
83 {
84 return bounds_;
85 }
86
SetFakeBounds(const RRect & fakeBounds)87 void ScreenProperty::SetFakeBounds(const RRect& fakeBounds)
88 {
89 fakeBounds_ = fakeBounds;
90 }
91
GetFakeBounds() const92 RRect ScreenProperty::GetFakeBounds() const
93 {
94 return fakeBounds_;
95 }
96
SetIsFakeInUse(bool isFakeInUse)97 void ScreenProperty::SetIsFakeInUse(bool isFakeInUse)
98 {
99 isFakeInUse_ = isFakeInUse;
100 }
101
GetIsFakeInUse() const102 bool ScreenProperty::GetIsFakeInUse() const
103 {
104 return isFakeInUse_;
105 }
106
SetScaleX(float scaleX)107 void ScreenProperty::SetScaleX(float scaleX)
108 {
109 scaleX_ = scaleX;
110 }
111
GetScaleX() const112 float ScreenProperty::GetScaleX() const
113 {
114 return scaleX_;
115 }
116
SetScaleY(float scaleY)117 void ScreenProperty::SetScaleY(float scaleY)
118 {
119 scaleY_ = scaleY;
120 }
121
GetScaleY() const122 float ScreenProperty::GetScaleY() const
123 {
124 return scaleY_;
125 }
126
SetPivotX(float pivotX)127 void ScreenProperty::SetPivotX(float pivotX)
128 {
129 pivotX_ = pivotX;
130 }
131
GetPivotX() const132 float ScreenProperty::GetPivotX() const
133 {
134 return pivotX_;
135 }
136
SetPivotY(float pivotY)137 void ScreenProperty::SetPivotY(float pivotY)
138 {
139 pivotY_ = pivotY;
140 }
141
GetPivotY() const142 float ScreenProperty::GetPivotY() const
143 {
144 return pivotY_;
145 }
146
SetTranslateX(float translateX)147 void ScreenProperty::SetTranslateX(float translateX)
148 {
149 translateX_ = translateX;
150 }
151
GetTranslateX() const152 float ScreenProperty::GetTranslateX() const
153 {
154 return translateX_;
155 }
156
SetTranslateY(float translateY)157 void ScreenProperty::SetTranslateY(float translateY)
158 {
159 translateY_ = translateY;
160 }
161
GetTranslateY() const162 float ScreenProperty::GetTranslateY() const
163 {
164 return translateY_;
165 }
166
SetPhyBounds(const RRect & phyBounds)167 void ScreenProperty::SetPhyBounds(const RRect& phyBounds)
168 {
169 phyBounds_ = phyBounds;
170 }
171
GetPhyBounds() const172 RRect ScreenProperty::GetPhyBounds() const
173 {
174 return phyBounds_;
175 }
176
GetDensity()177 float ScreenProperty::GetDensity()
178 {
179 return virtualPixelRatio_;
180 }
181
GetDefaultDensity()182 float ScreenProperty::GetDefaultDensity()
183 {
184 return defaultDensity_;
185 }
186
SetDefaultDensity(float defaultDensity)187 void ScreenProperty::SetDefaultDensity(float defaultDensity)
188 {
189 defaultDensity_ = defaultDensity;
190 }
191
GetDensityInCurResolution() const192 float ScreenProperty::GetDensityInCurResolution() const
193 {
194 return densityInCurResolution_;
195 }
196
SetDensityInCurResolution(float densityInCurResolution)197 void ScreenProperty::SetDensityInCurResolution(float densityInCurResolution)
198 {
199 densityInCurResolution_ = densityInCurResolution;
200 }
201
SetValidHeight(uint32_t validHeight)202 void ScreenProperty::SetValidHeight(uint32_t validHeight)
203 {
204 validHeight_ = validHeight;
205 }
206
GetValidHeight() const207 uint32_t ScreenProperty::GetValidHeight() const
208 {
209 return validHeight_;
210 }
211
SetValidWidth(uint32_t validWidth)212 void ScreenProperty::SetValidWidth(uint32_t validWidth)
213 {
214 validWidth_ = validWidth;
215 }
216
GetValidWidth() const217 uint32_t ScreenProperty::GetValidWidth() const
218 {
219 return validWidth_;
220 }
221
SetPhyWidth(uint32_t phyWidth)222 void ScreenProperty::SetPhyWidth(uint32_t phyWidth)
223 {
224 phyWidth_ = phyWidth;
225 }
226
GetPhyWidth() const227 int32_t ScreenProperty::GetPhyWidth() const
228 {
229 return phyWidth_;
230 }
231
SetPhyHeight(uint32_t phyHeight)232 void ScreenProperty::SetPhyHeight(uint32_t phyHeight)
233 {
234 phyHeight_ = phyHeight;
235 }
236
GetPhyHeight() const237 int32_t ScreenProperty::GetPhyHeight() const
238 {
239 return phyHeight_;
240 }
241
SetDpiPhyBounds(uint32_t phyWidth,uint32_t phyHeight)242 void ScreenProperty::SetDpiPhyBounds(uint32_t phyWidth, uint32_t phyHeight)
243 {
244 dpiPhyWidth_ = phyWidth;
245 dpiPhyHeight_ = phyHeight;
246 }
247
SetRefreshRate(uint32_t refreshRate)248 void ScreenProperty::SetRefreshRate(uint32_t refreshRate)
249 {
250 refreshRate_ = refreshRate;
251 }
252
GetRefreshRate() const253 uint32_t ScreenProperty::GetRefreshRate() const
254 {
255 return refreshRate_;
256 }
257
SetRsId(ScreenId rsId)258 void ScreenProperty::SetRsId(ScreenId rsId)
259 {
260 rsId_ = rsId;
261 }
262
GetRsId() const263 ScreenId ScreenProperty::GetRsId() const
264 {
265 return rsId_;
266 }
267
SetPropertyChangeReason(std::string propertyChangeReason)268 void ScreenProperty::SetPropertyChangeReason(std::string propertyChangeReason)
269 {
270 propertyChangeReason_ = propertyChangeReason;
271 }
272
GetPropertyChangeReason() const273 std::string ScreenProperty::GetPropertyChangeReason() const
274 {
275 return propertyChangeReason_;
276 }
277
SetVirtualPixelRatio(float virtualPixelRatio)278 void ScreenProperty::SetVirtualPixelRatio(float virtualPixelRatio)
279 {
280 virtualPixelRatio_ = virtualPixelRatio;
281 }
282
GetVirtualPixelRatio() const283 float ScreenProperty::GetVirtualPixelRatio() const
284 {
285 return virtualPixelRatio_;
286 }
287
SetScreenRotation(Rotation rotation)288 void ScreenProperty::SetScreenRotation(Rotation rotation)
289 {
290 bool enableRotation = (system::GetParameter("persist.window.rotation.enabled", "1") == "1");
291 if (!enableRotation) {
292 return;
293 }
294 if (IsVertical(rotation) != IsVertical(screenRotation_)) {
295 std::swap(bounds_.rect_.width_, bounds_.rect_.height_);
296 int32_t width = bounds_.rect_.width_;
297 int32_t height = bounds_.rect_.height_;
298 if (IsVertical(screenRotation_)) {
299 bounds_.rect_.left_ -= static_cast<float>(width - height) / static_cast<float>(HALF_VALUE) -
300 static_cast<float>(offsetY_);
301 bounds_.rect_.top_ += static_cast<float>(width - height) / static_cast<float>(HALF_VALUE);
302 } else {
303 bounds_.rect_.left_ += static_cast<float>(height - width) / static_cast<float>(HALF_VALUE);
304 bounds_.rect_.top_ -= static_cast<float>(height - width) / static_cast<float>(HALF_VALUE) +
305 static_cast<float>(offsetY_);
306 }
307 }
308 switch (rotation) {
309 case Rotation::ROTATION_90:
310 rotation_ = 90.f;
311 break;
312 case Rotation::ROTATION_180:
313 rotation_ = 180.f;
314 break;
315 case Rotation::ROTATION_270:
316 rotation_ = 270.f;
317 break;
318 default:
319 rotation_ = 0.f;
320 break;
321 }
322 screenRotation_ = rotation;
323 }
324
SetRotationAndScreenRotationOnly(Rotation rotation)325 void ScreenProperty::SetRotationAndScreenRotationOnly(Rotation rotation)
326 {
327 bool enableRotation = (system::GetParameter("persist.window.rotation.enabled", "1") == "1");
328 if (!enableRotation) {
329 return;
330 }
331 switch (rotation) {
332 case Rotation::ROTATION_90:
333 rotation_ = 90.f;
334 break;
335 case Rotation::ROTATION_180:
336 rotation_ = 180.f;
337 break;
338 case Rotation::ROTATION_270:
339 rotation_ = 270.f;
340 break;
341 default:
342 rotation_ = 0.f;
343 break;
344 }
345 screenRotation_ = rotation;
346 deviceRotation_ = rotation;
347 }
348
UpdateScreenRotation(Rotation rotation)349 void ScreenProperty::UpdateScreenRotation(Rotation rotation)
350 {
351 screenRotation_ = rotation;
352 }
353
GetScreenRotation() const354 Rotation ScreenProperty::GetScreenRotation() const
355 {
356 return screenRotation_;
357 }
358
UpdateDeviceRotation(Rotation rotation)359 void ScreenProperty::UpdateDeviceRotation(Rotation rotation)
360 {
361 deviceRotation_ = rotation;
362 }
363
GetDeviceRotation() const364 Rotation ScreenProperty::GetDeviceRotation() const
365 {
366 return deviceRotation_;
367 }
368
SetOrientation(Orientation orientation)369 void ScreenProperty::SetOrientation(Orientation orientation)
370 {
371 orientation_ = orientation;
372 }
373
GetOrientation() const374 Orientation ScreenProperty::GetOrientation() const
375 {
376 return orientation_;
377 }
378
SetDisplayState(DisplayState displayState)379 void ScreenProperty::SetDisplayState(DisplayState displayState)
380 {
381 displayState_ = displayState;
382 }
383
GetDisplayState() const384 DisplayState ScreenProperty::GetDisplayState() const
385 {
386 return displayState_;
387 }
388
SetDisplayOrientation(DisplayOrientation displayOrientation)389 void ScreenProperty::SetDisplayOrientation(DisplayOrientation displayOrientation)
390 {
391 displayOrientation_ = displayOrientation;
392 }
393
GetDisplayOrientation() const394 DisplayOrientation ScreenProperty::GetDisplayOrientation() const
395 {
396 return displayOrientation_;
397 }
398
SetDeviceOrientation(DisplayOrientation displayOrientation)399 void ScreenProperty::SetDeviceOrientation(DisplayOrientation displayOrientation)
400 {
401 deviceOrientation_ = displayOrientation;
402 }
403
GetDeviceOrientation() const404 DisplayOrientation ScreenProperty::GetDeviceOrientation() const
405 {
406 return deviceOrientation_;
407 }
408
UpdateXDpi()409 void ScreenProperty::UpdateXDpi()
410 {
411 if (dpiPhyWidth_ != UINT32_MAX) {
412 int32_t width = phyBounds_.rect_.width_;
413 xDpi_ = width * INCH_2_MM / dpiPhyWidth_;
414 xDpi_ = std::floor(xDpi_ * TRUNCATE_THREE_DECIMALS) / TRUNCATE_THREE_DECIMALS;
415 }
416 }
417
UpdateYDpi()418 void ScreenProperty::UpdateYDpi()
419 {
420 if (dpiPhyHeight_ != UINT32_MAX) {
421 int32_t height_ = phyBounds_.rect_.height_;
422 yDpi_ = height_ * INCH_2_MM / dpiPhyHeight_;
423 yDpi_ = std::floor(yDpi_ * TRUNCATE_THREE_DECIMALS) / TRUNCATE_THREE_DECIMALS;
424 }
425 }
426
UpdateVirtualPixelRatio(const RRect & bounds)427 void ScreenProperty::UpdateVirtualPixelRatio(const RRect& bounds)
428 {
429 int32_t width = bounds.rect_.width_;
430 int32_t height = bounds.rect_.height_;
431
432 if (width == PHONE_SCREEN_WIDTH && height == PHONE_SCREEN_HEIGHT) { // telephone
433 virtualPixelRatio_ = PHONE_SCREEN_DENSITY;
434 } else {
435 virtualPixelRatio_ = ELSE_SCREEN_DENSITY;
436 }
437 defaultDensity_ = virtualPixelRatio_;
438 }
439
CalcDefaultDisplayOrientation()440 void ScreenProperty::CalcDefaultDisplayOrientation()
441 {
442 if (bounds_.rect_.width_ > bounds_.rect_.height_) {
443 displayOrientation_ = DisplayOrientation::LANDSCAPE;
444 deviceOrientation_ = DisplayOrientation::LANDSCAPE;
445 } else {
446 displayOrientation_ = DisplayOrientation::PORTRAIT;
447 deviceOrientation_ = DisplayOrientation::PORTRAIT;
448 }
449 }
450
CalculateXYDpi(uint32_t phyWidth,uint32_t phyHeight)451 void ScreenProperty::CalculateXYDpi(uint32_t phyWidth, uint32_t phyHeight)
452 {
453 if (phyWidth == 0 || phyHeight == 0) {
454 return;
455 }
456
457 phyWidth_ = phyWidth;
458 phyHeight_ = phyHeight;
459 int32_t width_ = phyBounds_.rect_.width_;
460 int32_t height_ = phyBounds_.rect_.height_;
461 xDpi_ = width_ * INCH_2_MM / phyWidth_;
462 yDpi_ = height_ * INCH_2_MM / phyHeight_;
463 xDpi_ = std::floor(xDpi_ * TRUNCATE_THREE_DECIMALS) / TRUNCATE_THREE_DECIMALS;
464 yDpi_ = std::floor(yDpi_ * TRUNCATE_THREE_DECIMALS) / TRUNCATE_THREE_DECIMALS;
465 }
466
GetXDpi() const467 float ScreenProperty::GetXDpi() const
468 {
469 return xDpi_;
470 }
471
GetYDpi() const472 float ScreenProperty::GetYDpi() const
473 {
474 return yDpi_;
475 }
476
SetOffsetX(int32_t offsetX)477 void ScreenProperty::SetOffsetX(int32_t offsetX)
478 {
479 offsetX_ = offsetX;
480 }
481
GetOffsetX() const482 int32_t ScreenProperty::GetOffsetX() const
483 {
484 return offsetX_;
485 }
486
SetOffsetY(int32_t offsetY)487 void ScreenProperty::SetOffsetY(int32_t offsetY)
488 {
489 offsetY_ = offsetY;
490 }
491
GetOffsetY() const492 int32_t ScreenProperty::GetOffsetY() const
493 {
494 return offsetY_;
495 }
496
SetMirrorWidth(uint32_t mirrorWidth)497 void ScreenProperty::SetMirrorWidth(uint32_t mirrorWidth)
498 {
499 mirrorWidth_ = mirrorWidth;
500 }
501
GetMirrorWidth() const502 uint32_t ScreenProperty::GetMirrorWidth() const
503 {
504 return mirrorWidth_;
505 }
506
SetMirrorHeight(uint32_t mirrorHeight)507 void ScreenProperty::SetMirrorHeight(uint32_t mirrorHeight)
508 {
509 mirrorHeight_ = mirrorHeight;
510 }
511
GetMirrorHeight() const512 uint32_t ScreenProperty::GetMirrorHeight() const
513 {
514 return mirrorHeight_;
515 }
516
SetOffset(int32_t offsetX,int32_t offsetY)517 void ScreenProperty::SetOffset(int32_t offsetX, int32_t offsetY)
518 {
519 offsetX_ = offsetX;
520 offsetY_ = offsetY;
521 }
522
SetStartX(uint32_t startX)523 void ScreenProperty::SetStartX(uint32_t startX)
524 {
525 startX_ = startX;
526 }
527
GetStartX() const528 uint32_t ScreenProperty::GetStartX() const
529 {
530 return startX_;
531 }
532
SetStartY(uint32_t startY)533 void ScreenProperty::SetStartY(uint32_t startY)
534 {
535 startY_ = startY;
536 }
537
GetStartY() const538 uint32_t ScreenProperty::GetStartY() const
539 {
540 return startY_;
541 }
542
SetStartPosition(uint32_t startX,uint32_t startY)543 void ScreenProperty::SetStartPosition(uint32_t startX, uint32_t startY)
544 {
545 startX_ = startX;
546 startY_ = startY;
547 }
548
SetScreenType(ScreenType type)549 void ScreenProperty::SetScreenType(ScreenType type)
550 {
551 type_ = type;
552 }
553
GetScreenType() const554 ScreenType ScreenProperty::GetScreenType() const
555 {
556 return type_;
557 }
558
SetScreenRequestedOrientation(Orientation orientation)559 void ScreenProperty::SetScreenRequestedOrientation(Orientation orientation)
560 {
561 screenRequestedOrientation_ = orientation;
562 }
563
GetScreenRequestedOrientation() const564 Orientation ScreenProperty::GetScreenRequestedOrientation() const
565 {
566 return screenRequestedOrientation_;
567 }
568
SetDefaultDeviceRotationOffset(uint32_t defaultRotationOffset)569 void ScreenProperty::SetDefaultDeviceRotationOffset(uint32_t defaultRotationOffset)
570 {
571 defaultDeviceRotationOffset_ = defaultRotationOffset;
572 }
573
GetDefaultDeviceRotationOffset() const574 uint32_t ScreenProperty::GetDefaultDeviceRotationOffset() const
575 {
576 return defaultDeviceRotationOffset_;
577 }
578
SetScreenShape(ScreenShape screenShape)579 void ScreenProperty::SetScreenShape(ScreenShape screenShape)
580 {
581 screenShape_ = screenShape;
582 }
583
GetScreenShape() const584 ScreenShape ScreenProperty::GetScreenShape() const
585 {
586 return screenShape_;
587 }
588
SetX(int32_t x)589 void ScreenProperty::SetX(int32_t x)
590 {
591 x_ = x;
592 }
593
GetX() const594 int32_t ScreenProperty::GetX() const
595 {
596 return x_;
597 }
598
SetY(int32_t y)599 void ScreenProperty::SetY(int32_t y)
600 {
601 y_ = y;
602 }
603
GetY() const604 int32_t ScreenProperty::GetY() const
605 {
606 return y_;
607 }
608
SetXYPosition(int32_t x,int32_t y)609 void ScreenProperty::SetXYPosition(int32_t x, int32_t y)
610 {
611 x_ = x;
612 y_ = y;
613 }
614
GetPhysicalTouchBounds()615 RRect ScreenProperty::GetPhysicalTouchBounds()
616 {
617 return physicalTouchBounds_;
618 }
619
SetPhysicalTouchBounds()620 void ScreenProperty::SetPhysicalTouchBounds()
621 {
622 if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) {
623 physicalTouchBounds_.rect_.width_ = bounds_.rect_.width_;
624 physicalTouchBounds_.rect_.height_ = bounds_.rect_.height_;
625 return;
626 }
627 if (rotation_ == SECONDARY_ROTATION_90 || rotation_ == SECONDARY_ROTATION_270) {
628 physicalTouchBounds_.rect_.width_ = phyBounds_.rect_.width_;
629 physicalTouchBounds_.rect_.height_ = phyBounds_.rect_.height_;
630 } else {
631 physicalTouchBounds_.rect_.width_ = phyBounds_.rect_.height_;
632 physicalTouchBounds_.rect_.height_ = phyBounds_.rect_.width_;
633 }
634 }
635
GetInputOffsetX()636 int32_t ScreenProperty::GetInputOffsetX()
637 {
638 return inputOffsetX_;
639 }
640
GetInputOffsetY()641 int32_t ScreenProperty::GetInputOffsetY()
642 {
643 return inputOffsetY_;
644 }
645
IsWidthHeightMatch(float width,float height,float targetWidth,float targetHeight)646 static inline bool IsWidthHeightMatch(float width, float height, float targetWidth, float targetHeight)
647 {
648 return (width == targetWidth && height == targetHeight) || (width == targetHeight && height == targetWidth);
649 }
650
SetInputOffsetY()651 void ScreenProperty::SetInputOffsetY()
652 {
653 inputOffsetX_ = 0;
654 if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) {
655 return;
656 }
657 if (IsWidthHeightMatch(bounds_.rect_.GetWidth(), bounds_.rect_.GetHeight(), FULL_STATUS_WIDTH, SCREEN_HEIGHT)) {
658 inputOffsetX_ = SECONDARY_FULL_OFFSETY;
659 }
660 }
661
CalculatePPI()662 float ScreenProperty::CalculatePPI()
663 {
664 int32_t phywidth = GetPhyWidth();
665 int32_t phyHeight = GetPhyHeight();
666 float phyDiagonal = std::sqrt(static_cast<float>(phywidth * phywidth + phyHeight * phyHeight));
667 if (phyDiagonal < EPSILON) {
668 return 0.0f;
669 }
670 RRect bounds = GetBounds();
671 int32_t width = bounds.rect_.GetWidth();
672 int32_t height = bounds.rect_.GetHeight();
673 float ppi = std::sqrt(static_cast<float>(width * width + height * height)) * INCH_2_MM / phyDiagonal;
674 return std::round(ppi * TRUNCATE_TWO_DECIMALS) / TRUNCATE_TWO_DECIMALS;
675 }
676
CalculateDPI()677 uint32_t ScreenProperty::CalculateDPI()
678 {
679 return static_cast<uint32_t>(std::round(CalculatePPI() * PPI_TO_DPI));
680 }
681
SetPointerActiveWidth(uint32_t pointerActiveWidth)682 void ScreenProperty::SetPointerActiveWidth(uint32_t pointerActiveWidth)
683 {
684 pointerActiveWidth_ = pointerActiveWidth;
685 }
686
GetPointerActiveWidth()687 uint32_t ScreenProperty::GetPointerActiveWidth()
688 {
689 return pointerActiveWidth_;
690 }
691
SetPointerActiveHeight(uint32_t pointerActiveHeight)692 void ScreenProperty::SetPointerActiveHeight(uint32_t pointerActiveHeight)
693 {
694 pointerActiveHeight_ = pointerActiveHeight;
695 }
696
GetPointerActiveHeight()697 uint32_t ScreenProperty::GetPointerActiveHeight()
698 {
699 return pointerActiveHeight_;
700 }
701 } // namespace OHOS::Rosen
702