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 218dc02f99d09130ace2ee738c2e689db1b3f33181John Reck#include "Extensions.h" 221bcacfdcab0eaa0cee92bd7f5a1b5e271dd68e52John Reck#include "utils/Macros.h" 23704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 24704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace android { 25704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace uirenderer { 26704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 27704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckclass DeviceInfo { 28704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck PREVENT_COPY_AND_ASSIGN(DeviceInfo); 291bcacfdcab0eaa0cee92bd7f5a1b5e271dd68e52John Reck 30704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckpublic: 31704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // returns nullptr if DeviceInfo is not initialized yet 32704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // Note this does not have a memory fence so it's up to the caller 33704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // to use one if required. Normally this should not be necessary 34704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck static const DeviceInfo* get(); 35704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 36704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // only call this after GL has been initialized, or at any point if compiled 37704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck // with HWUI_NULL_GPU 38704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck static void initialize(); 39500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev static void initialize(int maxTextureSize); 40704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 41704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck int maxTextureSize() const { return mMaxTextureSize; } 428dc02f99d09130ace2ee738c2e689db1b3f33181John Reck const DisplayInfo& displayInfo() const { return mDisplayInfo; } 438dc02f99d09130ace2ee738c2e689db1b3f33181John Reck const Extensions& extensions() const { return mExtensions; } 448dc02f99d09130ace2ee738c2e689db1b3f33181John Reck 458dc02f99d09130ace2ee738c2e689db1b3f33181John Reck static uint32_t multiplyByResolution(uint32_t in) { 468dc02f99d09130ace2ee738c2e689db1b3f33181John Reck auto di = DeviceInfo::get()->displayInfo(); 478dc02f99d09130ace2ee738c2e689db1b3f33181John Reck return di.w * di.h * in; 488dc02f99d09130ace2ee738c2e689db1b3f33181John Reck } 49704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 50564284759f014c141cb8b8403b036833f50f49efJohn Reck static DisplayInfo queryDisplayInfo(); 51564284759f014c141cb8b8403b036833f50f49efJohn Reck 52704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckprivate: 53704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck DeviceInfo() {} 54704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck ~DeviceInfo() {} 55704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 56704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck void load(); 57704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 58704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck int mMaxTextureSize; 598dc02f99d09130ace2ee738c2e689db1b3f33181John Reck DisplayInfo mDisplayInfo; 608dc02f99d09130ace2ee738c2e689db1b3f33181John Reck Extensions mExtensions; 61704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck}; 62704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 63704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace uirenderer */ 64704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace android */ 65704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 66704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#endif /* DEVICEINFO_H */ 67