John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef DEVICEINFO_H |
| 17 | #define DEVICEINFO_H |
| 18 | |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 19 | #include <apex/display.h> |
Peiyong Lin | 3bff135 | 2018-12-11 07:56:07 -0800 | [diff] [blame] | 20 | #include <SkImageInfo.h> |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 21 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 22 | #include "utils/Macros.h" |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
Derek Sollenberger | 1766238 | 2018-09-13 14:14:00 -0400 | [diff] [blame] | 27 | namespace renderthread { |
| 28 | class RenderThread; |
| 29 | } |
| 30 | |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 31 | class DeviceInfo { |
| 32 | PREVENT_COPY_AND_ASSIGN(DeviceInfo); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 33 | |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 34 | public: |
John Reck | cf185f5 | 2019-04-11 16:11:24 -0700 | [diff] [blame] | 35 | static DeviceInfo* get(); |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 36 | static float getMaxRefreshRate() { return get()->mMaxRefreshRate; } |
| 37 | static int32_t getWidth() { return get()->mWidth; } |
| 38 | static int32_t getHeight() { return get()->mHeight; } |
| 39 | static float getDensity() { return get()->mDensity; } |
Alec Mouri | 4a818f1 | 2019-11-19 16:17:53 -0800 | [diff] [blame] | 40 | static int64_t getVsyncPeriod() { return get()->mVsyncPeriod; } |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 41 | static int64_t getCompositorOffset() { return get()->mCompositorOffset; } |
| 42 | static int64_t getAppOffset() { return get()->mAppOffset; } |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 43 | |
Derek Sollenberger | 1766238 | 2018-09-13 14:14:00 -0400 | [diff] [blame] | 44 | // this value is only valid after the GPU has been initialized and there is a valid graphics |
| 45 | // context or if you are using the HWUI_NULL_GPU |
| 46 | int maxTextureSize() const; |
Peiyong Lin | 3bff135 | 2018-12-11 07:56:07 -0800 | [diff] [blame] | 47 | sk_sp<SkColorSpace> getWideColorSpace() const { return mWideColorSpace; } |
| 48 | SkColorType getWideColorType() const { return mWideColorType; } |
John Reck | cf185f5 | 2019-04-11 16:11:24 -0700 | [diff] [blame] | 49 | |
Alec Mouri | 4a818f1 | 2019-11-19 16:17:53 -0800 | [diff] [blame] | 50 | // This method should be called whenever the display refresh rate changes. |
| 51 | void onRefreshRateChanged(int64_t vsyncPeriod); |
John Reck | 5642847 | 2018-03-16 17:27:17 -0700 | [diff] [blame] | 52 | |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 53 | private: |
Derek Sollenberger | 1766238 | 2018-09-13 14:14:00 -0400 | [diff] [blame] | 54 | friend class renderthread::RenderThread; |
| 55 | static void setMaxTextureSize(int maxTextureSize); |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 56 | void updateDisplayInfo(); |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 57 | |
Derek Sollenberger | 1766238 | 2018-09-13 14:14:00 -0400 | [diff] [blame] | 58 | DeviceInfo(); |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 59 | ~DeviceInfo(); |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 60 | |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 61 | int mMaxTextureSize; |
Alec Mouri | 70f2a92 | 2019-11-20 11:10:29 -0800 | [diff] [blame] | 62 | sk_sp<SkColorSpace> mWideColorSpace = SkColorSpace::MakeSRGB(); |
| 63 | SkColorType mWideColorType = SkColorType::kN32_SkColorType; |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 64 | ADisplayConfig* mCurrentConfig = nullptr; |
| 65 | ADisplay** mDisplays = nullptr; |
| 66 | int mDisplaysSize = 0; |
| 67 | int mPhysicalDisplayIndex = -1; |
| 68 | float mMaxRefreshRate = 60.0; |
| 69 | int32_t mWidth = 1080; |
| 70 | int32_t mHeight = 1920; |
| 71 | float mDensity = 2.0; |
Alec Mouri | 4a818f1 | 2019-11-19 16:17:53 -0800 | [diff] [blame] | 72 | int64_t mVsyncPeriod = 16666666; |
Alec Mouri | 22d753f | 2019-09-05 17:11:45 -0700 | [diff] [blame] | 73 | int64_t mCompositorOffset = 0; |
| 74 | int64_t mAppOffset = 0; |
John Reck | 704bed0 | 2015-11-05 09:22:17 -0800 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | } /* namespace uirenderer */ |
| 78 | } /* namespace android */ |
| 79 | |
| 80 | #endif /* DEVICEINFO_H */ |