blob: 65c646e49cc69dbb5d25c4bf39904ac53fdaaf3e [file] [log] [blame]
/*
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cobalt/browser/memory_settings/build_settings.h"
namespace cobalt {
namespace browser {
namespace memory_settings {
namespace {
bool HasBlitter() {
#if SB_HAS(BLITTER)
const bool has_blitter = true;
#else
const bool has_blitter = false;
#endif
return has_blitter;
}
base::optional<int64_t> MakeValidIfGreaterThanOrEqualToZero(int64_t value) {
base::optional<int64_t> output;
if (value >= 0) {
output = value;
}
return output;
}
base::optional<math::Size> MakeDimensionsIfPositive(int width, int height) {
base::optional<math::Size> output;
if ((width > 0) && (height > 0)) {
output = math::Size(width, height);
}
return output;
}
} // namespace
BuildSettings GetDefaultBuildSettings() {
BuildSettings settings;
settings.has_blitter = HasBlitter();
settings.cobalt_image_cache_size_in_bytes =
MakeValidIfGreaterThanOrEqualToZero(COBALT_IMAGE_CACHE_SIZE_IN_BYTES);
settings.javascript_garbage_collection_threshold_in_bytes =
MakeValidIfGreaterThanOrEqualToZero(
COBALT_JS_GARBAGE_COLLECTION_THRESHOLD_IN_BYTES);
settings.skia_cache_size_in_bytes =
MakeValidIfGreaterThanOrEqualToZero(COBALT_SKIA_CACHE_SIZE_IN_BYTES);
settings.skia_texture_atlas_dimensions = MakeDimensionsIfPositive(
COBALT_SKIA_GLYPH_ATLAS_WIDTH, COBALT_SKIA_GLYPH_ATLAS_HEIGHT);
settings.software_surface_cache_size_in_bytes =
MakeValidIfGreaterThanOrEqualToZero(
COBALT_SOFTWARE_SURFACE_CACHE_SIZE_IN_BYTES);
return settings;
}
} // namespace memory_settings
} // namespace browser
} // namespace cobalt