0

cc: Fix impl-side painting rasterization at >1 contents scales

Previously there was a content space vs. layer space mixup.  cc::Tile had a
member variable that was labeled rect_in_layer_space, but the tilings were
making a content space rect.  It's actually impossible to have an int rect in
layer space for most content spaces, so this got renamed to just be
content_space rect.

The actual bug was that this rect was being used to check if a given picture's
layer rect intersected it, so as soon as you got over bounds() / content_scale
away from the origin, the tile was getting nothing rastered to it and whatever
memory was in the canvas was being used, which happened to be old tiles.

R=aelias@chromium.org
BUG=164750


Review URL: https://chromiumcodereview.appspot.com/11466032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171964 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
enne@chromium.org
2012-12-08 08:48:21 +00:00
parent 4a23c374cf
commit be03793baa
6 changed files with 19 additions and 12 deletions

@ -62,8 +62,8 @@ void Picture::Record(ContentLayerClient* painter,
layer_rect_.y(),
layer_rect_.width(),
layer_rect_.height());
canvas->drawRect(layer_skrect, paint);
canvas->clipRect(layer_skrect);
canvas->drawRect(layer_skrect, paint);
gfx::RectF opaque_layer_rect;
base::TimeTicks beginPaintTime = base::TimeTicks::Now();

@ -7,6 +7,7 @@
#include "cc/rendering_stats.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSize.h"
#include "ui/gfx/rect_conversions.h"
namespace cc {
@ -45,21 +46,27 @@ scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const {
void PicturePileImpl::Raster(
SkCanvas* canvas,
gfx::Rect rect,
gfx::Rect content_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
canvas->save();
canvas->translate(-rect.x(), -rect.y());
SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(),
rect.width(), rect.height());
canvas->translate(-content_rect.x(), -content_rect.y());
SkRect layer_skrect = SkRect::MakeXYWH(
content_rect.x(),
content_rect.y(),
content_rect.width(),
content_rect.height());
canvas->clipRect(layer_skrect);
canvas->scale(contents_scale, contents_scale);
gfx::Rect layer_rect = gfx::ToEnclosedRect(gfx::ScaleRect(gfx::RectF(content_rect), 1 / contents_scale));
for (PicturePile::Pile::const_iterator i = pile_.begin();
i != pile_.end(); ++i) {
if (!(*i)->LayerRect().Intersects(rect))
if (!(*i)->LayerRect().Intersects(layer_rect))
continue;
(*i)->Raster(canvas);

@ -34,7 +34,7 @@ public:
// It is assumed that contentsScale has already been applied to this canvas.
void Raster(
SkCanvas* canvas,
gfx::Rect rect,
gfx::Rect content_rect,
float contents_scale,
RenderingStats* stats);

@ -13,13 +13,13 @@ Tile::Tile(TileManager* tile_manager,
PicturePileImpl* picture_pile,
gfx::Size tile_size,
GLenum format,
gfx::Rect rect_inside_picture,
gfx::Rect content_rect,
float contents_scale)
: tile_manager_(tile_manager),
picture_pile_(picture_pile),
tile_size_(tile_size),
format_(format),
rect_inside_picture_(rect_inside_picture),
content_rect_(content_rect),
contents_scale_(contents_scale) {
tile_manager_->RegisterTile(this);
}

@ -26,7 +26,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
PicturePileImpl* picture_pile,
gfx::Size tile_size,
GLenum format,
gfx::Rect rect_inside_picture,
gfx::Rect content_rect,
float contents_scale);
PicturePileImpl* picture_pile() {
@ -68,7 +68,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
scoped_refptr<PicturePileImpl> picture_pile_;
gfx::Rect tile_size_;
GLenum format_;
gfx::Rect rect_inside_picture_;
gfx::Rect content_rect_;
float contents_scale_;
gfx::Rect opaque_rect_;

@ -413,7 +413,7 @@ void TileManager::DispatchOneRasterTask(
FROM_HERE,
picture_pile_clone.get(),
resource_pool_->resource_provider()->mapPixelBuffer(resource_id),
tile->rect_inside_picture_,
tile->content_rect_,
tile->contents_scale(),
stats,
base::Bind(&TileManager::OnRasterTaskCompleted,