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 
19 #include <SkImageInfo.h>
20 #include <ui/DisplayInfo.h>
21 
22 #include "utils/Macros.h"
23 
24 namespace android {
25 namespace uirenderer {
26 
27 namespace renderthread {
28     class RenderThread;
29 }
30 
31 class DeviceInfo {
32     PREVENT_COPY_AND_ASSIGN(DeviceInfo);
33 
34 public:
35     static DeviceInfo* get();
36 
37     // this value is only valid after the GPU has been initialized and there is a valid graphics
38     // context or if you are using the HWUI_NULL_GPU
39     int maxTextureSize() const;
displayInfo()40     const DisplayInfo& displayInfo() const { return mDisplayInfo; }
getWideColorSpace()41     sk_sp<SkColorSpace> getWideColorSpace() const { return mWideColorSpace; }
getWideColorType()42     SkColorType getWideColorType() const { return mWideColorType; }
getMaxRefreshRate()43     float getMaxRefreshRate() const { return mMaxRefreshRate; }
44 
45     void onDisplayConfigChanged();
46 
47 private:
48     friend class renderthread::RenderThread;
49     static void setMaxTextureSize(int maxTextureSize);
50 
51     DeviceInfo();
52 
53     int mMaxTextureSize;
54     DisplayInfo mDisplayInfo;
55     sk_sp<SkColorSpace> mWideColorSpace;
56     SkColorType mWideColorType;
57     const float mMaxRefreshRate;
58 };
59 
60 } /* namespace uirenderer */
61 } /* namespace android */
62 
63 #endif /* DEVICEINFO_H */
64