Skip to content

support screen.devicePixelRatio #9926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2022
Merged

support screen.devicePixelRatio #9926

merged 1 commit into from
Jan 6, 2022

Conversation

PPpro
Copy link
Contributor

@PPpro PPpro commented Jan 6, 2022

Re: cocos-creator/3d-tasks#

Changelog:

  • 支持 screen.devicePixelRatio 只读属性,该属性返回的是引擎当前使用的 DPR

@PPpro PPpro requested a review from SantyWang January 6, 2022 05:39
@github-actions
Copy link

github-actions bot commented Jan 6, 2022

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -16581,9 +16581,9 @@
         /**
          * @en Returns device pixel ratio for retina display.
          * @zh 返回设备或浏览器像素比例。
          *
-         * @deprecated since v3.4.0, devicePixelRatio is a concept on web standard.
+         * @deprecated since v3.4.0, please use screen.devicePixelRatio instead.
          */
         getDevicePixelRatio(): number;
         /**
          * @en Returns the real location in view for a translation based on a related position
@@ -47669,8 +47669,16 @@
          * @zh screen 单例对象提供简单的方法来做屏幕管理相关的工作。
          */
         export class cocos_core_platform_screen_Screen {
             /**
+             * @en the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device
+             * NOTE: For performance reasons, the engine will limit the maximum value of DPR on some platforms.
+             * This property returns the DPR after the engine limit.
+             * @zh 当前显示设备的物理像素分辨率与 CSS 像素分辨率之比
+             * 注意:出于性能考虑,引擎在一些平台会限制 DPR 的最高值,这个属性返回的是引擎限制后的 DPR。
+             */
+            get devicePixelRatio(): number;
+            /**
              * @en Get and set the size of current window in physical pixels.
              * NOTE:
              * - Setting window size is only supported on Web platform for now.
              * - On Web platform, if the ContainerStrategy is PROPORTIONAL_TO_FRAME, we set windowSize on game frame,

@SantyWang SantyWang requested a review from pandamicro January 6, 2022 05:45
@PPpro PPpro requested a review from minggo January 6, 2022 06:16
@SantyWang SantyWang merged commit b6d54e3 into cocos:v3.4.1 Jan 6, 2022
@PPpro PPpro deleted the 341-dpr branch January 6, 2022 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants