fake_picture_layer_impl.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_ 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "cc/layers/picture_layer_impl.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace cc { 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class FakePictureLayerImpl : public PictureLayerImpl { 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) public: 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static scoped_ptr<FakePictureLayerImpl> Create( 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) LayerTreeImpl* tree_impl, int id) { 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id)); 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 200529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Create layer from a pile that covers the entire layer. 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static scoped_ptr<FakePictureLayerImpl> CreateWithPile( 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) LayerTreeImpl* tree_impl, int id, scoped_refptr<PicturePileImpl> pile) { 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id, pile)); 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Create layer from a pile that only covers part of the layer. 270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch static scoped_ptr<FakePictureLayerImpl> CreateWithPartialPile( 280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch LayerTreeImpl* tree_impl, 290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch int id, 300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch scoped_refptr<PicturePileImpl> pile, 310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch const gfx::Size& layer_bounds) { 320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return make_scoped_ptr( 330529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch new FakePictureLayerImpl(tree_impl, id, pile, layer_bounds)); 340529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 350529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) OVERRIDE; 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void AppendQuads(RenderPass* render_pass, 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const OcclusionTracker<LayerImpl>& occlusion_tracker, 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) AppendQuadsData* append_quads_data) OVERRIDE; 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual gfx::Size CalculateTileSize( 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Size& content_bounds) const OVERRIDE; 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) virtual void DidBecomeActive() OVERRIDE; 455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) size_t did_become_active_call_count() { 465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) return did_become_active_call_count_; 475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) } 485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) using PictureLayerImpl::AddTiling; 5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) using PictureLayerImpl::CleanUpTilingsOnActiveLayer; 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) using PictureLayerImpl::CanHaveTilings; 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) using PictureLayerImpl::MarkVisibleResourcesAsRequired; 533551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) using PictureLayerImpl::DoPostCommitInitializationIfNeeded; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) using PictureLayerImpl::MinimumContentsScale; 550529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch using PictureLayerImpl::SanityCheckTilingState; 563551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 57f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) using PictureLayerImpl::UpdateIdealScales; 58f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) using PictureLayerImpl::MaximumTilingContentsScale; 59f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 60cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void SetNeedsPostCommitInitialization() { 61cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) needs_post_commit_initialization_ = true; 62cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) bool needs_post_commit_initialization() const { 653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) return needs_post_commit_initialization_; 663551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) } 673551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 68f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) float raster_page_scale() const { return raster_page_scale_; } 69f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void set_raster_page_scale(float scale) { raster_page_scale_ = scale; } 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PictureLayerTiling* HighResTiling() const; 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PictureLayerTiling* LowResTiling() const; 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) size_t num_tilings() const { return tilings_->num_tilings(); } 7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PictureLayerImpl* twin_layer() { return twin_layer_; } 7623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) void set_twin_layer(PictureLayerImpl* twin) { twin_layer_ = twin; } 7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PictureLayerTilingSet* tilings() { return tilings_.get(); } 781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) PicturePileImpl* pile() { return pile_.get(); } 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) size_t append_quads_count() { return append_quads_count_; } 8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const Region& invalidation() const { return invalidation_; } 8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void set_invalidation(const Region& region) { invalidation_ = region; } 8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 840529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gfx::Rect visible_rect_for_tile_priority() { 850529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return visible_rect_for_tile_priority_; 860529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) gfx::Rect viewport_rect_for_tile_priority() { 885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) return viewport_rect_for_tile_priority_; 890529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 900529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gfx::Transform screen_space_transform_for_tile_priority() { 910529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return screen_space_transform_for_tile_priority_; 920529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 930529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void set_fixed_tile_size(const gfx::Size& size) { fixed_tile_size_ = size; } 9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CreateDefaultTilingsAndTiles(); 97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SetAllTilesVisible(); 98a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SetAllTilesReady(); 99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SetAllTilesReadyInTiling(PictureLayerTiling* tiling); 100e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void ResetAllTilesPriorities(); 1015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) PictureLayerTilingSet* GetTilings() { return tilings_.get(); } 102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 10390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) protected: 10490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) FakePictureLayerImpl( 10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) LayerTreeImpl* tree_impl, 10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int id, 10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) scoped_refptr<PicturePileImpl> pile); 1080529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch FakePictureLayerImpl(LayerTreeImpl* tree_impl, 1090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch int id, 1100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch scoped_refptr<PicturePileImpl> pile, 1110529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch const gfx::Size& layer_bounds); 11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id); 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private: 11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::Size fixed_tile_size_; 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) size_t append_quads_count_; 1185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) size_t did_become_active_call_count_; 11990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 12090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 12190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace cc 12290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 12390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_ 124