| Index: cc/resources/tile_bundle.cc
 | 
| diff --git a/cc/resources/tile_bundle.cc b/cc/resources/tile_bundle.cc
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..e0d7f003dd362b89697d8281b53e42af5b679c81
 | 
| --- /dev/null
 | 
| +++ b/cc/resources/tile_bundle.cc
 | 
| @@ -0,0 +1,104 @@
 | 
| +// Copyright 2013 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/resources/tile_bundle.h"
 | 
| +
 | 
| +#include "cc/resources/picture_layer_tiling.h"
 | 
| +#include "cc/resources/tile.h"
 | 
| +#include "cc/resources/tile_manager.h"
 | 
| +
 | 
| +namespace cc {
 | 
| +
 | 
| +TileBundle::Id TileBundle::s_next_id_ = 0;
 | 
| +
 | 
| +TileBundle::TileBundle(TileManager* tile_manager,
 | 
| +                       int width,
 | 
| +                       int height,
 | 
| +                       int offset_x,
 | 
| +                       int offset_y)
 | 
| +    : RefCountedManaged<TileBundle>(tile_manager),
 | 
| +      tiling_(NULL),
 | 
| +      width_(width),
 | 
| +      height_(height),
 | 
| +      offset_x_(offset_x),
 | 
| +      offset_y_(offset_y),
 | 
| +      id_(s_next_id_++) {}
 | 
| +
 | 
| +TileBundle::~TileBundle() {}
 | 
| +
 | 
| +Tile* TileBundle::TileAt(int index_x, int index_y) {
 | 
| +  TileMapKey key = ComputeLocalIndex(index_x, index_y);
 | 
| +  TileMap::iterator it = tiles_.find(key);
 | 
| +  if (it == tiles_.end())
 | 
| +    return NULL;
 | 
| +  return it->second.get();
 | 
| +}
 | 
| +
 | 
| +TileBundle* TileBundle::GetTwinBundle() {
 | 
| +  DCHECK(client_);
 | 
| +  const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(tiling_);
 | 
| +  if (!twin_tiling)
 | 
| +    return NULL;
 | 
| +  return twin_tiling->TileBundleContainingTileAt(offset_x_, offset_y_);
 | 
| +}
 | 
| +
 | 
| +bool TileBundle::IsRecycled() const {
 | 
| +  return client_->IsRecycled();
 | 
| +}
 | 
| +
 | 
| +bool TileBundle::IsActive() const {
 | 
| +  return client_->IsActive();
 | 
| +}
 | 
| +
 | 
| +bool TileBundle::IsPending() const {
 | 
| +  return client_->IsPending();
 | 
| +}
 | 
| +
 | 
| +bool TileBundle::RemoveTileAt(int index_x, int index_y) {
 | 
| +  TileMapKey key = ComputeLocalIndex(index_x, index_y);
 | 
| +  TileMap::iterator it = tiles_.find(key);
 | 
| +  if (it == tiles_.end())
 | 
| +    return false;
 | 
| +
 | 
| +  tiles_.erase(it);
 | 
| +  return true;
 | 
| +}
 | 
| +
 | 
| +void TileBundle::AddTileAt(int index_x,
 | 
| +                           int index_y,
 | 
| +                           scoped_refptr<Tile> tile) {
 | 
| +  TileMapKey key = ComputeLocalIndex(index_x, index_y);
 | 
| +  DCHECK(tiles_.find(key) == tiles_.end());
 | 
| +  tiles_[key] = tile;
 | 
| +}
 | 
| +
 | 
| +void TileBundle::DidBecomeRecycled() {
 | 
| +  priority_ = TilePriority();
 | 
| +}
 | 
| +
 | 
| +void TileBundle::DidBecomeActive() {
 | 
| +}
 | 
| +
 | 
| +size_t TileBundle::TileCount() const {
 | 
| +  return tiles_.size();
 | 
| +}
 | 
| +
 | 
| +TileBundle::TileMapKey TileBundle::ComputeLocalIndex(int index_x, int index_y) {
 | 
| +  index_x -= offset_x_;
 | 
| +  index_y -= offset_y_;
 | 
| +
 | 
| +  DCHECK_GE(index_x, 0);
 | 
| +  DCHECK_GE(index_y, 0);
 | 
| +  DCHECK_LT(index_x, width_);
 | 
| +  DCHECK_LT(index_x, height_);
 | 
| +
 | 
| +  return TileMapKey(index_x, index_y);
 | 
| +}
 | 
| +
 | 
| +TileBundle::Iterator::Iterator(TileBundle* bundle)
 | 
| +    : bundle_(bundle), iterator_(bundle_->tiles_.begin()) {}
 | 
| +
 | 
| +TileBundle::Iterator::~Iterator() {}
 | 
| +
 | 
| +}  // namespace cc
 | 
| 
 |