diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-22 03:28:05 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-22 03:28:05 +0000 |
commit | f8936a7662f5ccc53df6789ef7fce57ac2d52670 (patch) | |
tree | 28c57b9f2ee07921acff26e28a10576b31758117 /cc/test/tiled_layer_test_common.cc | |
parent | e57d3e9e9f705ad2c9004156ac60f6e9b205e577 (diff) | |
download | chromium_src-f8936a7662f5ccc53df6789ef7fce57ac2d52670.zip chromium_src-f8936a7662f5ccc53df6789ef7fce57ac2d52670.tar.gz chromium_src-f8936a7662f5ccc53df6789ef7fce57ac2d52670.tar.bz2 |
cc chromification: tiled_layer_test_common.h/cc
BUG=144577
Review URL: https://codereview.chromium.org/12458014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/tiled_layer_test_common.cc')
-rw-r--r-- | cc/test/tiled_layer_test_common.cc | 217 |
1 files changed, 98 insertions, 119 deletions
diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index 01c8f83..ce3d365 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -4,155 +4,133 @@ #include "cc/test/tiled_layer_test_common.h" -using cc::LayerTilingData; -using cc::LayerUpdater; -using cc::PriorityCalculator; -using cc::PrioritizedResource; -using cc::PrioritizedResourceManager; -using cc::RenderingStats; -using cc::ResourceUpdate; -using cc::ResourceUpdateQueue; - namespace cc { -FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer, scoped_ptr<PrioritizedResource> texture) - : LayerUpdater::Resource(texture.Pass()) - , m_layer(layer) -{ - m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); - m_bitmap.allocPixels(); +FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer, + scoped_ptr<PrioritizedResource> texture) + : LayerUpdater::Resource(texture.Pass()), layer_(layer) { + bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); + bitmap_.allocPixels(); } -FakeLayerUpdater::Resource::~Resource() -{ -} +FakeLayerUpdater::Resource::~Resource() {} -void FakeLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, gfx::Rect sourceRect, gfx::Vector2d destOffset, bool partialUpdate, RenderingStats* stats) -{ - const gfx::Rect rect(0, 0, 10, 10); - ResourceUpdate upload = ResourceUpdate::Create( - texture(), &m_bitmap, rect, rect, gfx::Vector2d()); - if (partialUpdate) - queue->AppendPartialUpload(upload); - else - queue->AppendFullUpload(upload); - - m_layer->update(); -} +void FakeLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, + gfx::Rect source_rect, + gfx::Vector2d dest_offset, + bool partial_update, + RenderingStats* stats) { + const gfx::Rect kRect(0, 0, 10, 10); + ResourceUpdate upload = ResourceUpdate::Create( + texture(), &bitmap_, kRect, kRect, gfx::Vector2d()); + if (partial_update) + queue->AppendPartialUpload(upload); + else + queue->AppendFullUpload(upload); -FakeLayerUpdater::FakeLayerUpdater() - : m_prepareCount(0) - , m_updateCount(0) -{ + layer_->Update(); } -FakeLayerUpdater::~FakeLayerUpdater() -{ -} +FakeLayerUpdater::FakeLayerUpdater() : prepare_count_(0), update_count_(0) {} -void FakeLayerUpdater::PrepareToUpdate(gfx::Rect contentRect, gfx::Size, float, float, gfx::Rect* resultingOpaqueRect, RenderingStats*) -{ - m_prepareCount++; - m_lastUpdateRect = contentRect; - if (!m_rectToInvalidate.IsEmpty()) { - m_layer->InvalidateContentRect(m_rectToInvalidate); - m_rectToInvalidate = gfx::Rect(); - m_layer = NULL; - } - *resultingOpaqueRect = m_opaquePaintRect; -} +FakeLayerUpdater::~FakeLayerUpdater() {} -void FakeLayerUpdater::setRectToInvalidate(const gfx::Rect& rect, FakeTiledLayer* layer) -{ - m_rectToInvalidate = rect; - m_layer = layer; +void FakeLayerUpdater::PrepareToUpdate(gfx::Rect content_rect, + gfx::Size tile_size, + float contents_width_scale, + float contents_height_scale, + gfx::Rect* resulting_opaque_rect, + RenderingStats* stats) { + prepare_count_++; + last_update_rect_ = content_rect; + if (!rect_to_invalidate_.IsEmpty()) { + layer_->InvalidateContentRect(rect_to_invalidate_); + rect_to_invalidate_ = gfx::Rect(); + layer_ = NULL; + } + *resulting_opaque_rect = opaque_paint_rect_; } -scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::CreateResource(PrioritizedResourceManager* manager) -{ - return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::Create(manager))); +void FakeLayerUpdater::SetRectToInvalidate(gfx::Rect rect, + FakeTiledLayer* layer) { + rect_to_invalidate_ = rect; + layer_ = layer; } -FakeTiledLayerImpl::FakeTiledLayerImpl(LayerTreeImpl* treeImpl, int id) - : TiledLayerImpl(treeImpl, id) -{ +scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::CreateResource( + PrioritizedResourceManager* manager) { + return scoped_ptr<LayerUpdater::Resource>( + new Resource(this, PrioritizedResource::Create(manager))); } -FakeTiledLayerImpl::~FakeTiledLayerImpl() -{ -} +FakeTiledLayerImpl::FakeTiledLayerImpl(LayerTreeImpl* tree_impl, int id) + : TiledLayerImpl(tree_impl, id) {} -FakeTiledLayer::FakeTiledLayer(PrioritizedResourceManager* resourceManager) - : TiledLayer() - , m_fakeUpdater(make_scoped_refptr(new FakeLayerUpdater)) - , m_resourceManager(resourceManager) -{ - SetTileSize(tileSize()); - SetTextureFormat(GL_RGBA); - SetBorderTexelOption(LayerTilingData::NO_BORDER_TEXELS); - SetIsDrawable(true); // So that we don't get false positives if any of these tests expect to return false from DrawsContent() for other reasons. -} +FakeTiledLayerImpl::~FakeTiledLayerImpl() {} -FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(PrioritizedResourceManager* resourceManager) - : FakeTiledLayer(resourceManager) -{ +FakeTiledLayer::FakeTiledLayer(PrioritizedResourceManager* resource_manager) + : TiledLayer(), + fake_updater_(make_scoped_refptr(new FakeLayerUpdater)), + resource_manager_(resource_manager) { + SetTileSize(tile_size()); + SetTextureFormat(GL_RGBA); + SetBorderTexelOption(LayerTilingData::NO_BORDER_TEXELS); + // So that we don't get false positives if any of these + // tests expect to return false from DrawsContent() for other reasons. + SetIsDrawable(true); } -FakeTiledLayerWithScaledBounds::~FakeTiledLayerWithScaledBounds() -{ -} +FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds( + PrioritizedResourceManager* resource_manager) + : FakeTiledLayer(resource_manager) {} -FakeTiledLayer::~FakeTiledLayer() -{ -} +FakeTiledLayerWithScaledBounds::~FakeTiledLayerWithScaledBounds() {} + +FakeTiledLayer::~FakeTiledLayer() {} -void FakeTiledLayer::SetNeedsDisplayRect(const gfx::RectF& rect) -{ - m_lastNeedsDisplayRect = rect; - TiledLayer::SetNeedsDisplayRect(rect); +void FakeTiledLayer::SetNeedsDisplayRect(const gfx::RectF& rect) { + last_needs_display_rect_ = rect; + TiledLayer::SetNeedsDisplayRect(rect); } -void FakeTiledLayer::SetTexturePriorities(const PriorityCalculator& calculator) -{ - // Ensure there is always a target render surface available. If none has been - // set (the layer is an orphan for the test), then just set a surface on itself. - bool missingTargetRenderSurface = !render_target(); +void FakeTiledLayer::SetTexturePriorities( + const PriorityCalculator& calculator) { + // Ensure there is always a target render surface available. If none has been + // set (the layer is an orphan for the test), then just set a surface on + // itself. + bool missing_target_render_surface = !render_target(); - if (missingTargetRenderSurface) - CreateRenderSurface(); + if (missing_target_render_surface) + CreateRenderSurface(); - TiledLayer::SetTexturePriorities(calculator); + TiledLayer::SetTexturePriorities(calculator); - if (missingTargetRenderSurface) { - ClearRenderSurface(); - draw_properties().render_target = 0; - } + if (missing_target_render_surface) { + ClearRenderSurface(); + draw_properties().render_target = 0; + } } -cc::PrioritizedResourceManager* FakeTiledLayer::ResourceManager() const -{ - return m_resourceManager; +PrioritizedResourceManager* FakeTiledLayer::ResourceManager() const { + return resource_manager_; } -void FakeTiledLayer::updateContentsScale(float ideal_contents_scale) -{ - CalculateContentsScale( - ideal_contents_scale, - false, // animating_transform_to_screen - &draw_properties().contents_scale_x, - &draw_properties().contents_scale_y, - &draw_properties().content_bounds); +void FakeTiledLayer::UpdateContentsScale(float ideal_contents_scale) { + CalculateContentsScale(ideal_contents_scale, + false, // animating_transform_to_screen + &draw_properties().contents_scale_x, + &draw_properties().contents_scale_y, + &draw_properties().content_bounds); } -cc::LayerUpdater* FakeTiledLayer::Updater() const -{ - return m_fakeUpdater.get(); +LayerUpdater* FakeTiledLayer::Updater() const { + return fake_updater_.get(); } -void FakeTiledLayerWithScaledBounds::setContentBounds(const gfx::Size& contentBounds) -{ - m_forcedContentBounds = contentBounds; - draw_properties().content_bounds = m_forcedContentBounds; +void FakeTiledLayerWithScaledBounds::SetContentBounds( + gfx::Size content_bounds) { + forced_content_bounds_ = content_bounds; + draw_properties().content_bounds = forced_content_bounds_; } void FakeTiledLayerWithScaledBounds::CalculateContentsScale( @@ -160,11 +138,12 @@ void FakeTiledLayerWithScaledBounds::CalculateContentsScale( bool animating_transform_to_screen, float* contents_scale_x, float* contents_scale_y, - gfx::Size* contentBounds) -{ - *contents_scale_x = static_cast<float>(m_forcedContentBounds.width()) / bounds().width(); - *contents_scale_y = static_cast<float>(m_forcedContentBounds.height()) / bounds().height(); - *contentBounds = m_forcedContentBounds; + gfx::Size* content_bounds) { + *contents_scale_x = + static_cast<float>(forced_content_bounds_.width()) / bounds().width(); + *contents_scale_y = + static_cast<float>(forced_content_bounds_.height()) / bounds().height(); + *content_bounds = forced_content_bounds_; } } // namespace cc |