diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 01:15:54 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 01:15:54 +0000 |
commit | ac1d20a0ba81deccca895406f85fa4af71657647 (patch) | |
tree | 33e0e6c35864200c051d5113431fe97aa9865f33 /cc | |
parent | 4c7a383b1649e488e024ea02cd31f8b3b0a24bd2 (diff) | |
download | chromium_src-ac1d20a0ba81deccca895406f85fa4af71657647.zip chromium_src-ac1d20a0ba81deccca895406f85fa4af71657647.tar.gz chromium_src-ac1d20a0ba81deccca895406f85fa4af71657647.tar.bz2 |
cc: Apply contents scales to impl-side painting rasterization
Tiles now have a contents scale that they are rastered with, so that non-1.0
contents scales work. Additionally, PictureLayer derives from
ContentsScalingLayer so that it picks up the right content bounds and default
contents scale.
BUG=155209
Review URL: https://chromiumcodereview.appspot.com/11421210
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/picture_layer.h | 3 | ||||
-rw-r--r-- | cc/picture_layer_impl.cc | 5 | ||||
-rw-r--r-- | cc/picture_pile_impl.cc | 8 | ||||
-rw-r--r-- | cc/picture_pile_impl.h | 6 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_tiling_client.cc | 3 | ||||
-rw-r--r-- | cc/tile.cc | 6 | ||||
-rw-r--r-- | cc/tile.h | 5 | ||||
-rw-r--r-- | cc/tile_manager.cc | 8 |
8 files changed, 33 insertions, 11 deletions
diff --git a/cc/picture_layer.h b/cc/picture_layer.h index 1517687..3aab8fd 100644 --- a/cc/picture_layer.h +++ b/cc/picture_layer.h @@ -5,6 +5,7 @@ #ifndef CC_PICTURE_LAYER_H_ #define CC_PICTURE_LAYER_H_ +#include "cc/contents_scaling_layer.h" #include "cc/layer.h" #include "cc/picture_pile.h" #include "cc/occlusion_tracker.h" @@ -15,7 +16,7 @@ class ContentLayerClient; class ResourceUpdateQueue; struct RenderingStats; -class CC_EXPORT PictureLayer : public Layer { +class CC_EXPORT PictureLayer : public ContentsScalingLayer { public: static scoped_refptr<PictureLayer> create(ContentLayerClient*); diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc index 093e7d4..9a9c043 100644 --- a/cc/picture_layer_impl.cc +++ b/cc/picture_layer_impl.cc @@ -160,7 +160,7 @@ void PictureLayerImpl::didUpdateTransforms() { last_content_scale_y_ = contentsScaleY(); } -scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, +scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, gfx::Rect rect) { TileManager* tile_manager = layerTreeHostImpl()->tileManager(); @@ -169,7 +169,8 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, pile_.get(), rect.size(), GL_RGBA, - rect)); + rect, + tiling->contents_scale())); } void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { diff --git a/cc/picture_pile_impl.cc b/cc/picture_pile_impl.cc index 216643b..530a97e 100644 --- a/cc/picture_pile_impl.cc +++ b/cc/picture_pile_impl.cc @@ -30,8 +30,11 @@ scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { return clone; } -void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, - RenderingStats* stats) { +void PicturePileImpl::Raster( + SkCanvas* canvas, + gfx::Rect rect, + float contents_scale, + RenderingStats* stats) { base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); // TODO(enne): do this more efficiently, i.e. top down with Skia clips @@ -40,6 +43,7 @@ void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); canvas->clipRect(layer_skrect); + canvas->scale(contents_scale, contents_scale); for (PicturePile::Pile::const_iterator i = pile_.begin(); i != pile_.end(); ++i) { if (!(*i)->LayerRect().Intersects(rect)) diff --git a/cc/picture_pile_impl.h b/cc/picture_pile_impl.h index 807bcbf..93ac072 100644 --- a/cc/picture_pile_impl.h +++ b/cc/picture_pile_impl.h @@ -26,7 +26,11 @@ public: // Raster a subrect of this PicturePileImpl into the given canvas. // It's only safe to call paint on a cloned version. // It is assumed that contentsScale has already been applied to this canvas. - void Raster(SkCanvas* canvas, gfx::Rect rect, RenderingStats* stats); + void Raster( + SkCanvas* canvas, + gfx::Rect rect, + float contents_scale, + RenderingStats* stats); private: friend class PicturePile; diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index ca6e4b2..c86abb0 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -21,7 +21,8 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( pile_.get(), tile_size_, GL_RGBA, - rect)); + rect, + 1)); } void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { @@ -13,12 +13,14 @@ Tile::Tile(TileManager* tile_manager, PicturePileImpl* picture_pile, gfx::Size tile_size, GLenum format, - gfx::Rect rect_inside_picture) + gfx::Rect rect_inside_picture, + float contents_scale) : tile_manager_(tile_manager), picture_pile_(picture_pile), tile_size_(tile_size), format_(format), - rect_inside_picture_(rect_inside_picture) { + rect_inside_picture_(rect_inside_picture), + contents_scale_(contents_scale) { tile_manager_->RegisterTile(this); } @@ -26,7 +26,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { PicturePileImpl* picture_pile, gfx::Size tile_size, GLenum format, - gfx::Rect rect_inside_picture); + gfx::Rect rect_inside_picture, + float contents_scale); const PicturePileImpl* picture_pile() const { return picture_pile_.get(); @@ -59,6 +60,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { ManagedTileState& managed_state() { return managed_state_; } const ManagedTileState& managed_state() const { return managed_state_; } size_t bytes_consumed_if_allocated() const; + float contents_scale() const { return contents_scale_; } // Normal private methods. friend class base::RefCounted<Tile>; @@ -69,6 +71,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { gfx::Rect tile_size_; GLenum format_; gfx::Rect rect_inside_picture_; + float contents_scale_; gfx::Rect opaque_rect_; TilePriority priority_[2]; diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc index a80f1dd..a257fc3 100644 --- a/cc/tile_manager.cc +++ b/cc/tile_manager.cc @@ -23,6 +23,7 @@ namespace { void RasterizeTile(cc::PicturePileImpl* picture_pile, uint8_t* mapped_buffer, const gfx::Rect& rect, + float contents_scale, cc::RenderingStats* stats) { TRACE_EVENT0("cc", "RasterizeTile"); DCHECK(mapped_buffer); @@ -32,7 +33,11 @@ void RasterizeTile(cc::PicturePileImpl* picture_pile, bitmap.setPixels(mapped_buffer); SkDevice device(bitmap); SkCanvas canvas(&device); - picture_pile->Raster(&canvas, rect, stats); + picture_pile->Raster( + &canvas, + rect, + contents_scale, + stats); } const char* kRasterThreadNamePrefix = "CompositorRaster"; @@ -322,6 +327,7 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) { resource_pool_->resource_provider()->mapPixelBuffer( resource_id), tile->rect_inside_picture_, + tile->contents_scale(), stats), base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |