<commit_before>#include "Platform.hpp"

#include "../core/jni_string.hpp"

#include "../../../../../base/logging.hpp"

#include "../../../../../std/algorithm.hpp"
#include "../../../../../std/cmath.hpp"

class Platform::PlatformImpl
{
public:
  PlatformImpl(int densityDpi, int screenWidth, int screenHeight)
  { // Constants are taken from android.util.DisplayMetrics

    /// ceiling screen sizes to the nearest power of two, and taking half of it as a tile size

    double const log2 = log(2.0);

//    LOG(LINFO, ("width:", screenWidth, ", height:", screenHeight));

    size_t ceiledScreenWidth = static_cast<int>(pow(2.0, ceil(log(double(screenWidth)) / log2)));
    size_t ceiledScreenHeight = static_cast<int>(pow(2.0, ceil(log(double(screenHeight)) / log2)));

    size_t ceiledScreenSize = max(ceiledScreenWidth, ceiledScreenHeight);

//    LOG(LINFO, ("ceiledScreenSize=", ceiledScreenSize));

    m_tileSize = min(max(ceiledScreenSize / 2, (size_t)128), (size_t)512);

    double k = (256.0 / m_tileSize) * (256.0 / m_tileSize);

    LOG(LINFO, ("tileSize=", m_tileSize));

    /// calculating how much tiles we need for the screen of such size

    m_maxTilesCount = 0;

    m_preCachingDepth = 6;

    /// calculating for non-rotated screen

    for (unsigned i = 0; i < m_preCachingDepth; ++i)
    {
//      LOG(LINFO, ("calculating", i, "level"));
      /// minimum size of tile on the screen
      float minTileSize = floor((m_tileSize << i) / 1.05 / 2.0) - 1;
//      LOG(LINFO, ("minTileSize:", minTileSize));
      int tilesOnXSide = ceil(screenWidth / minTileSize) + 1;
//      LOG(LINFO, ("tilesOnXSide:", tilesOnXSide));
      int tilesOnYSide = ceil(screenHeight / minTileSize) + 1;
//      LOG(LINFO, ("tilesOnYSide:", tilesOnYSide));
      /// tiles in the single screen
      int singleScreenTilesCount = tilesOnXSide * tilesOnYSide;
//      LOG(LINFO, ("singleScreenTilesCount:", singleScreenTilesCount));
      int curLevelTilesCount = singleScreenTilesCount * 3;
//      LOG(LINFO, ("curLevelTilesCount:", curLevelTilesCount));
      m_maxTilesCount += curLevelTilesCount;
//      LOG(LINFO, ("on", i, "depth we need", curLevelTilesCount, "tiles"));
    }

    LOG(LINFO, ("minimum amount of tiles needed is", m_maxTilesCount));

    m_maxTilesCount = max(static_cast<int>(120 * k), m_maxTilesCount);

    switch (densityDpi)
    {
    case 120:
      m_visualScale = 0.75;
      m_skinName = "basic_ldpi.skn";
      LOG(LINFO, ("using LDPI resources"));
      break;
    case 160:
      m_visualScale = 1.0;
      m_skinName = "basic_mdpi.skn";
      LOG(LINFO, ("using MDPI resources"));
      break;
    case 240:
      m_visualScale = 1.5;
      m_skinName = "basic_hdpi.skn";
      LOG(LINFO, ("using HDPI resources"));
      break;<commit_msg>using less videoMemory for tiles.<commit_after>#include "Platform.hpp"

#include "../core/jni_string.hpp"

#include "../../../../../base/logging.hpp"

#include "../../../../../std/algorithm.hpp"
#include "../../../../../std/cmath.hpp"

class Platform::PlatformImpl
{
public:
  PlatformImpl(int densityDpi, int screenWidth, int screenHeight)
  { // Constants are taken from android.util.DisplayMetrics

    /// ceiling screen sizes to the nearest power of two, and taking half of it as a tile size

    double const log2 = log(2.0);

//    LOG(LINFO, ("width:", screenWidth, ", height:", screenHeight));

    size_t ceiledScreenWidth = static_cast<int>(pow(2.0, ceil(log(double(screenWidth)) / log2)));
    size_t ceiledScreenHeight = static_cast<int>(pow(2.0, ceil(log(double(screenHeight)) / log2)));

    size_t ceiledScreenSize = max(ceiledScreenWidth, ceiledScreenHeight);

//    LOG(LINFO, ("ceiledScreenSize=", ceiledScreenSize));

    m_tileSize = min(max(ceiledScreenSize / 2, (size_t)128), (size_t)512);

    double k = (256.0 / m_tileSize) * (256.0 / m_tileSize);

    LOG(LINFO, ("tileSize=", m_tileSize));

    /// calculating how much tiles we need for the screen of such size

    m_maxTilesCount = 0;

    m_preCachingDepth = 4;

    /// calculating for non-rotated screen

    for (unsigned i = 0; i < m_preCachingDepth; ++i)
    {
//      LOG(LINFO, ("calculating", i, "level"));
      /// minimum size of tile on the screen
      float minTileSize = floor((m_tileSize << i) / 1.05 / 2.0) - 1;
//      LOG(LINFO, ("minTileSize:", minTileSize));
      int tilesOnXSide = ceil(screenWidth / minTileSize) + 1;
//      LOG(LINFO, ("tilesOnXSide:", tilesOnXSide));
      int tilesOnYSide = ceil(screenHeight / minTileSize) + 1;
//      LOG(LINFO, ("tilesOnYSide:", tilesOnYSide));
      /// tiles in the single screen
      int singleScreenTilesCount = tilesOnXSide * tilesOnYSide;
//      LOG(LINFO, ("singleScreenTilesCount:", singleScreenTilesCount));
      int curLevelTilesCount = singleScreenTilesCount * 2;
//      LOG(LINFO, ("curLevelTilesCount:", curLevelTilesCount));
      m_maxTilesCount += curLevelTilesCount;
//      LOG(LINFO, ("on", i, "depth we need", curLevelTilesCount, "tiles"));
    }

    LOG(LINFO, ("minimum amount of tiles needed is", m_maxTilesCount));

    m_maxTilesCount = max(static_cast<int>(120 * k), m_maxTilesCount);

    switch (densityDpi)
    {
    case 120:
      m_visualScale = 0.75;
      m_skinName = "basic_ldpi.skn";
      LOG(LINFO, ("using LDPI resources"));
      break;
    case 160:
      m_visualScale = 1.0;
      m_skinName = "basic_mdpi.skn";
      LOG(LINFO, ("using MDPI resources"));
      break;
    case 240:
      m_visualScale = 1.5;
      m_skinName = "basic_hdpi.skn";
      LOG(LINFO, ("using HDPI resources"));
      break;
{'fraction_non_alphanumeric': 0.1539426523297491, 'fraction_numerical': 0.01971326164874552, 'mean_word_length': 3.1218611521418023, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '818316', 'n_tokens_mistral': 1968, 'n_tokens_neox': 1850, 'n_words': 447}