DeviceInfo.h revision 8dc02f99d09130ace2ee738c2e689db1b3f33181
1704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck/* 2704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * Copyright (C) 2015 The Android Open Source Project 3704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * 4704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * Licensed under the Apache License, Version 2.0 (the "License"); 5704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * you may not use this file except in compliance with the License. 6704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * You may obtain a copy of the License at 7704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * 8704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * http://www.apache.org/licenses/LICENSE-2.0 9704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * 10704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * Unless required by applicable law or agreed to in writing, software 11704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * distributed under the License is distributed on an "AS IS" BASIS, 12704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * See the License for the specific language governing permissions and 14704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck * limitations under the License. 15704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck */ 16704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#ifndef DEVICEINFO_H 17704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#define DEVICEINFO_H 18704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 198dc02f99d09130ace2ee738c2e689db1b3f33181John Reck#include <ui/DisplayInfo.h> 208dc02f99d09130ace2ee738c2e689db1b3f33181John Reck 21704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#include "utils/Macros.h" 228dc02f99d09130ace2ee738c2e689db1b3f33181John Reck#include "Extensions.h" 23704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 24704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace android { 25704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace uirenderer { 26704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 27704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckclass DeviceInfo { 28704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck PREVENT_COPY_AND_ASSIGN(DeviceInfo); 29704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckpublic: 30704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // returns nullptr if DeviceInfo is not initialized yet 31704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // Note this does not have a memory fence so it's up to the caller 32704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // to use one if required. Normally this should not be necessary 33704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck static const DeviceInfo* get(); 34704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 35704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // only call this after GL has been initialized, or at any point if compiled 36704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // with HWUI_NULL_GPU 37704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck static void initialize(); 38500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev static void initialize(int maxTextureSize); 39704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 40704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck int maxTextureSize() const { return mMaxTextureSize; } 418dc02f99d09130ace2ee738c2e689db1b3f33181John Reck const DisplayInfo& displayInfo() const { return mDisplayInfo; } 428dc02f99d09130ace2ee738c2e689db1b3f33181John Reck const Extensions& extensions() const { return mExtensions; } 438dc02f99d09130ace2ee738c2e689db1b3f33181John Reck 448dc02f99d09130ace2ee738c2e689db1b3f33181John Reck static uint32_t multiplyByResolution(uint32_t in) { 458dc02f99d09130ace2ee738c2e689db1b3f33181John Reck auto di = DeviceInfo::get()->displayInfo(); 468dc02f99d09130ace2ee738c2e689db1b3f33181John Reck return di.w * di.h * in; 478dc02f99d09130ace2ee738c2e689db1b3f33181John Reck } 48704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 49704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckprivate: 50704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck DeviceInfo() {} 51704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck ~DeviceInfo() {} 52704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 53704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck void load(); 548dc02f99d09130ace2ee738c2e689db1b3f33181John Reck void loadDisplayInfo(); 55704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 56704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck int mMaxTextureSize; 578dc02f99d09130ace2ee738c2e689db1b3f33181John Reck DisplayInfo mDisplayInfo; 588dc02f99d09130ace2ee738c2e689db1b3f33181John Reck Extensions mExtensions; 59704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck}; 60704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 61704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace uirenderer */ 62704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace android */ 63704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 64704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#endif /* DEVICEINFO_H */ 65