OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/tiled_layer_impl.h" | 5 #include "cc/layers/tiled_layer_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 TiledLayerImpl::TiledLayerImpl(LayerTreeImpl* tree_impl, int id) | 48 TiledLayerImpl::TiledLayerImpl(LayerTreeImpl* tree_impl, int id) |
49 : LayerImpl(tree_impl, id), skips_draw_(true) {} | 49 : LayerImpl(tree_impl, id), skips_draw_(true) {} |
50 | 50 |
51 TiledLayerImpl::~TiledLayerImpl() { | 51 TiledLayerImpl::~TiledLayerImpl() { |
52 } | 52 } |
53 | 53 |
54 ResourceProvider::ResourceId TiledLayerImpl::ContentsResourceId() const { | 54 ResourceProvider::ResourceId TiledLayerImpl::ContentsResourceId() const { |
55 // This function is only valid for single texture layers, e.g. masks. | 55 // This function is only valid for single texture layers, e.g. masks. |
56 DCHECK(tiler_); | 56 DCHECK(tiler_); |
| 57 // It's possible the mask layer is created but has no size or otherwise |
| 58 // can't draw. |
| 59 if (tiler_->num_tiles_x() == 0 || tiler_->num_tiles_y() == 0) |
| 60 return 0; |
| 61 |
| 62 // Any other number of tiles other than 0 or 1 is incorrect for masks. |
57 DCHECK_EQ(tiler_->num_tiles_x(), 1); | 63 DCHECK_EQ(tiler_->num_tiles_x(), 1); |
58 DCHECK_EQ(tiler_->num_tiles_y(), 1); | 64 DCHECK_EQ(tiler_->num_tiles_y(), 1); |
59 | 65 |
60 DrawableTile* tile = TileAt(0, 0); | 66 DrawableTile* tile = TileAt(0, 0); |
61 ResourceProvider::ResourceId resource_id = tile ? tile->resource_id() : 0; | 67 ResourceProvider::ResourceId resource_id = tile ? tile->resource_id() : 0; |
62 return resource_id; | 68 return resource_id; |
63 } | 69 } |
64 | 70 |
65 bool TiledLayerImpl::HasTileAt(int i, int j) const { | 71 bool TiledLayerImpl::HasTileAt(int i, int j) const { |
66 return !!tiler_->TileAt(i, j); | 72 return !!tiler_->TileAt(i, j); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 298 |
293 void TiledLayerImpl::ReleaseResources() { | 299 void TiledLayerImpl::ReleaseResources() { |
294 tiler_->reset(); | 300 tiler_->reset(); |
295 } | 301 } |
296 | 302 |
297 const char* TiledLayerImpl::LayerTypeAsString() const { | 303 const char* TiledLayerImpl::LayerTypeAsString() const { |
298 return "cc::TiledLayerImpl"; | 304 return "cc::TiledLayerImpl"; |
299 } | 305 } |
300 | 306 |
301 } // namespace cc | 307 } // namespace cc |
OLD | NEW |