<commit_before>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/picture_layer_tiling.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size_conversions.h"

namespace cc {

scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create(
    float contents_scale,
    gfx::Size tile_size) {
  return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size));
}

scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const {
  return make_scoped_ptr(new PictureLayerTiling(*this));
}

PictureLayerTiling::PictureLayerTiling(float contents_scale,
                                       gfx::Size tile_size)
    : client_(NULL),
      contents_scale_(contents_scale),
      tiling_data_(tile_size, gfx::Size(), true) {
}

PictureLayerTiling::~PictureLayerTiling() {
}

const PictureLayerTiling& PictureLayerTiling::operator=(
    const PictureLayerTiling& tiler) {
  tiling_data_ = tiler.tiling_data_;
  tiles_ = tiler.tiles_;
  return *this;
}

void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
  client_ = client;
}

gfx::Rect PictureLayerTiling::ContentRect() const {
  gfx::Size content_bounds =
      gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_));
  return gfx::Rect(gfx::Point(), content_bounds);
}

Tile* PictureLayerTiling::TileAt(int i, int j) const {
  TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
  if (iter == tiles_.end())
    return NULL;
  return iter->second.get();
}

void PictureLayerTiling::CreateTile(int i, int j) {
  gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j);
  tile_rect.set_size(tiling_data_.max_texture_size());
  TileMapKey key(i, j);
  DCHECK(!tiles_[key]);
  tiles_[key] = client_->CreateTile(this, tile_rect);
}<commit_msg>[cc] Give newly created tiles default priority<commit_after>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/picture_layer_tiling.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size_conversions.h"

namespace cc {

scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create(
    float contents_scale,
    gfx::Size tile_size) {
  return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size));
}

scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const {
  return make_scoped_ptr(new PictureLayerTiling(*this));
}

PictureLayerTiling::PictureLayerTiling(float contents_scale,
                                       gfx::Size tile_size)
    : client_(NULL),
      contents_scale_(contents_scale),
      tiling_data_(tile_size, gfx::Size(), true) {
}

PictureLayerTiling::~PictureLayerTiling() {
}

const PictureLayerTiling& PictureLayerTiling::operator=(
    const PictureLayerTiling& tiler) {
  tiling_data_ = tiler.tiling_data_;
  tiles_ = tiler.tiles_;
  return *this;
}

void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
  client_ = client;
}

gfx::Rect PictureLayerTiling::ContentRect() const {
  gfx::Size content_bounds =
      gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_));
  return gfx::Rect(gfx::Point(), content_bounds);
}

Tile* PictureLayerTiling::TileAt(int i, int j) const {
  TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
  if (iter == tiles_.end())
    return NULL;
  return iter->second.get();
}

void PictureLayerTiling::CreateTile(int i, int j) {
  gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j);
  tile_rect.set_size(tiling_data_.max_texture_size());
  TileMapKey key(i, j);
  DCHECK(!tiles_[key]);
  tiles_[key] = client_->CreateTile(this, tile_rect);

  // TODO(enne): Remove this when we start setting priorities correctly.
  TilePriority priority;
  priority.resolution = HIGH_RESOLUTION;
  priority.time_to_visible_in_seconds = 1000;
  tiles_[key]->set_priority(ACTIVE_TREE, priority);
}
{'fraction_non_alphanumeric': 0.11687017194119113, 'fraction_numerical': 0.00299028158484924, 'mean_word_length': 5.232919254658385, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3484783', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1318, 'n_words': 269}