1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/viz/common/display/de_jelly.h" 6 7 #include "base/command_line.h" 8 #include "build/build_config.h" 9 #include "components/viz/common/features.h" 10 #include "components/viz/common/switches.h" 11 12 #if defined(OS_ANDROID) 13 #include "base/android/jni_android.h" 14 #include "base/android/jni_string.h" 15 #include "base/time/time.h" 16 #include "components/viz/common/common_jni_headers/DeJellyUtils_jni.h" 17 #endif 18 19 namespace viz { 20 DeJellyEnabled()21bool DeJellyEnabled() { 22 if (base::FeatureList::IsEnabled(features::kDisableDeJelly)) 23 return false; 24 25 return base::CommandLine::ForCurrentProcess()->HasSwitch( 26 switches::kEnableDeJelly); 27 } 28 DeJellyActive()29bool DeJellyActive() { 30 if (!DeJellyEnabled()) 31 return false; 32 33 #if defined(OS_ANDROID) 34 return Java_DeJellyUtils_useDeJelly(base::android::AttachCurrentThread()); 35 #endif 36 37 return true; 38 } 39 DeJellyScreenWidth()40float DeJellyScreenWidth() { 41 std::string value = 42 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 43 switches::kDeJellyScreenWidth); 44 if (!value.empty()) 45 return std::atoi(value.c_str()); 46 47 #if defined(OS_ANDROID) 48 return Java_DeJellyUtils_screenWidth(base::android::AttachCurrentThread()); 49 #endif 50 51 return 1440.0f; 52 } 53 MaxDeJellyHeight()54float MaxDeJellyHeight() { 55 // Not currently configurable. 56 return 30.0f; 57 } 58 59 } // namespace viz 60