Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: cc/resources/drawing_display_item.cc

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | cc/resources/eviction_tile_priority_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/drawing_display_item.h" 5 #include "cc/resources/drawing_display_item.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkMatrix.h" 9 #include "third_party/skia/include/core/SkMatrix.h"
10 #include "third_party/skia/include/core/SkPicture.h" 10 #include "third_party/skia/include/core/SkPicture.h"
11 #include "third_party/skia/include/utils/SkPictureUtils.h" 11 #include "third_party/skia/include/utils/SkPictureUtils.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture, 15 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture,
16 gfx::PointF location) 16 gfx::PointF location)
17 : picture_(picture), location_(location) { 17 : picture_(picture), location_(location) {
18 } 18 }
19 19
20 DrawingDisplayItem::~DrawingDisplayItem() { 20 DrawingDisplayItem::~DrawingDisplayItem() {
21 } 21 }
22 22
23 void DrawingDisplayItem::Raster(SkCanvas* canvas, 23 void DrawingDisplayItem::Raster(SkCanvas* canvas,
24 SkDrawPictureCallback* callback) const { 24 SkDrawPictureCallback* callback) const {
25 canvas->save(); 25 canvas->save();
26 canvas->translate(location_.x(), location_.y()); 26 canvas->translate(location_.x(), location_.y());
27 if (callback) 27 if (callback)
28 picture_->draw(canvas, callback); 28 picture_->playback(canvas, callback);
29 else 29 else
30 canvas->drawPicture(picture_.get()); 30 canvas->drawPicture(picture_.get());
31 canvas->restore(); 31 canvas->restore();
32 } 32 }
33 33
34 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const { 34 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const {
35 return picture_->suitableForGpuRasterization(NULL); 35 return picture_->suitableForGpuRasterization(NULL);
36 } 36 }
37 37
38 int DrawingDisplayItem::ApproximateOpCount() const { 38 int DrawingDisplayItem::ApproximateOpCount() const {
39 return picture_->approximateOpCount() + sizeof(gfx::PointF); 39 return picture_->approximateOpCount() + sizeof(gfx::PointF);
40 } 40 }
41 41
42 size_t DrawingDisplayItem::PictureMemoryUsage() const { 42 size_t DrawingDisplayItem::PictureMemoryUsage() const {
43 DCHECK(picture_); 43 DCHECK(picture_);
44 return SkPictureUtils::ApproximateBytesUsed(picture_.get()); 44 return SkPictureUtils::ApproximateBytesUsed(picture_.get());
45 } 45 }
46 46
47 } // namespace cc 47 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/draw_quad_unittest.cc ('k') | cc/resources/eviction_tile_priority_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698