Commit ac1d20a0 authored by enne@chromium.org's avatar enne@chromium.org

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
parent 4c7a383b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CC_PICTURE_LAYER_H_ #ifndef CC_PICTURE_LAYER_H_
#define CC_PICTURE_LAYER_H_ #define CC_PICTURE_LAYER_H_
#include "cc/contents_scaling_layer.h"
#include "cc/layer.h" #include "cc/layer.h"
#include "cc/picture_pile.h" #include "cc/picture_pile.h"
#include "cc/occlusion_tracker.h" #include "cc/occlusion_tracker.h"
...@@ -15,7 +16,7 @@ class ContentLayerClient; ...@@ -15,7 +16,7 @@ class ContentLayerClient;
class ResourceUpdateQueue; class ResourceUpdateQueue;
struct RenderingStats; struct RenderingStats;
class CC_EXPORT PictureLayer : public Layer { class CC_EXPORT PictureLayer : public ContentsScalingLayer {
public: public:
static scoped_refptr<PictureLayer> create(ContentLayerClient*); static scoped_refptr<PictureLayer> create(ContentLayerClient*);
......
...@@ -160,7 +160,7 @@ void PictureLayerImpl::didUpdateTransforms() { ...@@ -160,7 +160,7 @@ void PictureLayerImpl::didUpdateTransforms() {
last_content_scale_y_ = contentsScaleY(); last_content_scale_y_ = contentsScaleY();
} }
scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
gfx::Rect rect) { gfx::Rect rect) {
TileManager* tile_manager = layerTreeHostImpl()->tileManager(); TileManager* tile_manager = layerTreeHostImpl()->tileManager();
...@@ -169,7 +169,8 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, ...@@ -169,7 +169,8 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*,
pile_.get(), pile_.get(),
rect.size(), rect.size(),
GL_RGBA, GL_RGBA,
rect)); rect,
tiling->contents_scale()));
} }
void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
......
...@@ -30,7 +30,10 @@ scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { ...@@ -30,7 +30,10 @@ scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const {
return clone; return clone;
} }
void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, void PicturePileImpl::Raster(
SkCanvas* canvas,
gfx::Rect rect,
float contents_scale,
RenderingStats* stats) { RenderingStats* stats) {
base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now();
...@@ -40,6 +43,7 @@ void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, ...@@ -40,6 +43,7 @@ void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect,
SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(),
rect.width(), rect.height()); rect.width(), rect.height());
canvas->clipRect(layer_skrect); canvas->clipRect(layer_skrect);
canvas->scale(contents_scale, contents_scale);
for (PicturePile::Pile::const_iterator i = pile_.begin(); for (PicturePile::Pile::const_iterator i = pile_.begin();
i != pile_.end(); ++i) { i != pile_.end(); ++i) {
if (!(*i)->LayerRect().Intersects(rect)) if (!(*i)->LayerRect().Intersects(rect))
......
...@@ -26,7 +26,11 @@ public: ...@@ -26,7 +26,11 @@ public:
// Raster a subrect of this PicturePileImpl into the given canvas. // Raster a subrect of this PicturePileImpl into the given canvas.
// It's only safe to call paint on a cloned version. // It's only safe to call paint on a cloned version.
// It is assumed that contentsScale has already been applied to this canvas. // 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: private:
friend class PicturePile; friend class PicturePile;
......
...@@ -21,7 +21,8 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( ...@@ -21,7 +21,8 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile(
pile_.get(), pile_.get(),
tile_size_, tile_size_,
GL_RGBA, GL_RGBA,
rect)); rect,
1));
} }
void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) {
......
...@@ -13,12 +13,14 @@ Tile::Tile(TileManager* tile_manager, ...@@ -13,12 +13,14 @@ Tile::Tile(TileManager* tile_manager,
PicturePileImpl* picture_pile, PicturePileImpl* picture_pile,
gfx::Size tile_size, gfx::Size tile_size,
GLenum format, GLenum format,
gfx::Rect rect_inside_picture) gfx::Rect rect_inside_picture,
float contents_scale)
: tile_manager_(tile_manager), : tile_manager_(tile_manager),
picture_pile_(picture_pile), picture_pile_(picture_pile),
tile_size_(tile_size), tile_size_(tile_size),
format_(format), format_(format),
rect_inside_picture_(rect_inside_picture) { rect_inside_picture_(rect_inside_picture),
contents_scale_(contents_scale) {
tile_manager_->RegisterTile(this); tile_manager_->RegisterTile(this);
} }
......
...@@ -26,7 +26,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { ...@@ -26,7 +26,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
PicturePileImpl* picture_pile, PicturePileImpl* picture_pile,
gfx::Size tile_size, gfx::Size tile_size,
GLenum format, GLenum format,
gfx::Rect rect_inside_picture); gfx::Rect rect_inside_picture,
float contents_scale);
const PicturePileImpl* picture_pile() const { const PicturePileImpl* picture_pile() const {
return picture_pile_.get(); return picture_pile_.get();
...@@ -59,6 +60,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { ...@@ -59,6 +60,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
ManagedTileState& managed_state() { return managed_state_; } ManagedTileState& managed_state() { return managed_state_; }
const ManagedTileState& managed_state() const { return managed_state_; } const ManagedTileState& managed_state() const { return managed_state_; }
size_t bytes_consumed_if_allocated() const; size_t bytes_consumed_if_allocated() const;
float contents_scale() const { return contents_scale_; }
// Normal private methods. // Normal private methods.
friend class base::RefCounted<Tile>; friend class base::RefCounted<Tile>;
...@@ -69,6 +71,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { ...@@ -69,6 +71,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
gfx::Rect tile_size_; gfx::Rect tile_size_;
GLenum format_; GLenum format_;
gfx::Rect rect_inside_picture_; gfx::Rect rect_inside_picture_;
float contents_scale_;
gfx::Rect opaque_rect_; gfx::Rect opaque_rect_;
TilePriority priority_[2]; TilePriority priority_[2];
......
...@@ -23,6 +23,7 @@ namespace { ...@@ -23,6 +23,7 @@ namespace {
void RasterizeTile(cc::PicturePileImpl* picture_pile, void RasterizeTile(cc::PicturePileImpl* picture_pile,
uint8_t* mapped_buffer, uint8_t* mapped_buffer,
const gfx::Rect& rect, const gfx::Rect& rect,
float contents_scale,
cc::RenderingStats* stats) { cc::RenderingStats* stats) {
TRACE_EVENT0("cc", "RasterizeTile"); TRACE_EVENT0("cc", "RasterizeTile");
DCHECK(mapped_buffer); DCHECK(mapped_buffer);
...@@ -32,7 +33,11 @@ void RasterizeTile(cc::PicturePileImpl* picture_pile, ...@@ -32,7 +33,11 @@ void RasterizeTile(cc::PicturePileImpl* picture_pile,
bitmap.setPixels(mapped_buffer); bitmap.setPixels(mapped_buffer);
SkDevice device(bitmap); SkDevice device(bitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
picture_pile->Raster(&canvas, rect, stats); picture_pile->Raster(
&canvas,
rect,
contents_scale,
stats);
} }
const char* kRasterThreadNamePrefix = "CompositorRaster"; const char* kRasterThreadNamePrefix = "CompositorRaster";
...@@ -322,6 +327,7 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) { ...@@ -322,6 +327,7 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
resource_pool_->resource_provider()->mapPixelBuffer( resource_pool_->resource_provider()->mapPixelBuffer(
resource_id), resource_id),
tile->rect_inside_picture_, tile->rect_inside_picture_,
tile->contents_scale(),
stats), stats),
base::Bind(&TileManager::OnRasterTaskCompleted, base::Bind(&TileManager::OnRasterTaskCompleted,
base::Unretained(this), base::Unretained(this),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment