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 */ 1652eb4e01a49fe2e94555c000de38bbcbbb13401bMark Salyzyn 17704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#include <DeviceInfo.h> 18704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 19704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#include "Extensions.h" 20704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 21704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#include <thread> 22704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck#include <mutex> 23704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 2452eb4e01a49fe2e94555c000de38bbcbbb13401bMark Salyzyn#include <log/log.h> 2552eb4e01a49fe2e94555c000de38bbcbbb13401bMark Salyzyn 2652eb4e01a49fe2e94555c000de38bbcbbb13401bMark Salyzyn#include <GLES2/gl2.h> 2752eb4e01a49fe2e94555c000de38bbcbbb13401bMark Salyzyn 28704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace android { 29704bed0da7cc75d0c517d425445de70ceb58060bJohn Recknamespace uirenderer { 30704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 31704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckstatic DeviceInfo* sDeviceInfo = nullptr; 32704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckstatic std::once_flag sInitializedFlag; 33704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 34704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckconst DeviceInfo* DeviceInfo::get() { 358ecf41c61a5185207a21d64681e8ebc2502b7b2aChris Craik LOG_ALWAYS_FATAL_IF(!sDeviceInfo, "DeviceInfo not yet initialized."); 36704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck return sDeviceInfo; 37704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} 38704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 39704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckvoid DeviceInfo::initialize() { 40704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck std::call_once(sInitializedFlag, []() { 41704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck sDeviceInfo = new DeviceInfo(); 42704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck sDeviceInfo->load(); 43704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck }); 44704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} 45704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 46500a0c30d4dcd012218c3e44a62926a1c34a259fStan Ilievvoid DeviceInfo::initialize(int maxTextureSize) { 47500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev std::call_once(sInitializedFlag, [maxTextureSize]() { 48500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev sDeviceInfo = new DeviceInfo(); 49500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev sDeviceInfo->mMaxTextureSize = maxTextureSize; 50500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev }); 51500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev} 52500a0c30d4dcd012218c3e44a62926a1c34a259fStan Iliev 53704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckvoid DeviceInfo::load() { 54704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); 55704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} 56704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck 57704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace uirenderer */ 58704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck} /* namespace android */ 59