diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 09:51:20 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 09:51:20 +0000 |
commit | c97dfc681180e48f4408c8121293cd4ea64bc41c (patch) | |
tree | 8d4bf609decb3f6d015cc535ae6dc69117a6ea47 /cc/picture.cc | |
parent | c17ca9d20bd6d8ba21e7b13fa0e2634c9951f268 (diff) | |
download | chromium_src-c97dfc681180e48f4408c8121293cd4ea64bc41c.zip chromium_src-c97dfc681180e48f4408c8121293cd4ea64bc41c.tar.gz chromium_src-c97dfc681180e48f4408c8121293cd4ea64bc41c.tar.bz2 |
Make PicturePile pile.
This follows a similar policy as Android browser:
- If an invalidate only intersects the base plus at most one non-base SkPicture, then it creates a new SkPicture of that size.
- If an invalidate intersects two or more non-base SkPictures, then a new SkPicture is created at the top of the pile, sized to the union of the invalidate plus the bounds of all the intersecting pictures.
- Whenever new picture's area fully contains an existing picture, that old picture is destroyed.
- If an SkPicture's area would be >70% of the base, the pile is
destroyed and the base SkPicture is recreated.
During the invalidate pass, invalidated pictures are represented as
Pictures with a size but no recording. Then all the blank pictures
are filled in at the end of the Update().
BUG=163429
Review URL: https://chromiumcodereview.appspot.com/11299324
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/picture.cc')
-rw-r--r-- | cc/picture.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/cc/picture.cc b/cc/picture.cc index b7445e6..47d1b23 100644 --- a/cc/picture.cc +++ b/cc/picture.cc @@ -11,11 +11,12 @@ namespace cc { -scoped_refptr<Picture> Picture::Create() { - return make_scoped_refptr(new Picture()); +scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { + return make_scoped_refptr(new Picture(layer_rect)); } -Picture::Picture() { +Picture::Picture(gfx::Rect layer_rect) + : layer_rect_(layer_rect) { } Picture::Picture(const skia::RefPtr<SkPicture>& picture, @@ -29,7 +30,7 @@ Picture::Picture(const skia::RefPtr<SkPicture>& picture, Picture::~Picture() { } -scoped_refptr<Picture> Picture::Clone() { +scoped_refptr<Picture> Picture::Clone() const { // SkPicture is not thread-safe to rasterize with, so return a thread-safe // clone of it. DCHECK(picture_); @@ -37,7 +38,7 @@ scoped_refptr<Picture> Picture::Clone() { return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); } -void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect, +void Picture::Record(ContentLayerClient* painter, RenderingStats& stats) { TRACE_EVENT0("cc", "Picture::Record"); @@ -46,37 +47,36 @@ void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect, picture_ = skia::AdoptRef(new SkPicture); SkCanvas* canvas = picture_->beginRecording( - layer_rect.width(), - layer_rect.height(), + layer_rect_.width(), + layer_rect_.height(), SkPicture::kOptimizeForClippedPlayback_RecordingFlag); canvas->save(); - canvas->translate(SkFloatToScalar(-layer_rect.x()), - SkFloatToScalar(-layer_rect.y())); + canvas->translate(SkFloatToScalar(-layer_rect_.x()), + SkFloatToScalar(-layer_rect_.y())); SkPaint paint; paint.setAntiAlias(false); paint.setXfermodeMode(SkXfermode::kClear_Mode); - SkRect layer_skrect = SkRect::MakeXYWH(layer_rect.x(), - layer_rect.y(), - layer_rect.width(), - layer_rect.height()); + SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), + layer_rect_.y(), + layer_rect_.width(), + layer_rect_.height()); canvas->drawRect(layer_skrect, paint); canvas->clipRect(layer_skrect); gfx::RectF opaque_layer_rect; base::TimeTicks beginPaintTime = base::TimeTicks::Now(); - painter->paintContents(canvas, layer_rect, opaque_layer_rect); + painter->paintContents(canvas, layer_rect_, opaque_layer_rect); double delta = (base::TimeTicks::Now() - beginPaintTime).InSecondsF(); stats.totalPaintTimeInSeconds += delta; - stats.totalPixelsPainted += layer_rect.width() * - layer_rect.height(); + stats.totalPixelsPainted += layer_rect_.width() * + layer_rect_.height(); canvas->restore(); picture_->endRecording(); opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); - layer_rect_ = layer_rect; } void Picture::Raster(SkCanvas* canvas) { |