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

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

Issue 1116523002: cc: Remove save/restore from DrawingDisplayItem::Raster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 5 years, 7 months 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 | « no previous file | no next file » | 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 <string> 7 #include <string>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 #include "cc/debug/picture_debug_util.h" 11 #include "cc/debug/picture_debug_util.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkDrawPictureCallback.h" 13 #include "third_party/skia/include/core/SkDrawPictureCallback.h"
14 #include "third_party/skia/include/core/SkMatrix.h" 14 #include "third_party/skia/include/core/SkMatrix.h"
15 #include "third_party/skia/include/core/SkPicture.h" 15 #include "third_party/skia/include/core/SkPicture.h"
16 #include "third_party/skia/include/utils/SkPictureUtils.h" 16 #include "third_party/skia/include/utils/SkPictureUtils.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture) 20 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture)
21 : picture_(picture) { 21 : picture_(picture) {
22 } 22 }
23 23
24 DrawingDisplayItem::~DrawingDisplayItem() { 24 DrawingDisplayItem::~DrawingDisplayItem() {
25 } 25 }
26 26
27 void DrawingDisplayItem::Raster(SkCanvas* canvas, 27 void DrawingDisplayItem::Raster(SkCanvas* canvas,
28 SkDrawPictureCallback* callback) const { 28 SkDrawPictureCallback* callback) const {
29 canvas->save(); 29 // SkPicture always does a wrapping save/restore on the canvas, so it is not
30 // necessary here.
30 if (callback) 31 if (callback)
31 picture_->playback(canvas, callback); 32 picture_->playback(canvas, callback);
32 else 33 else
33 canvas->drawPicture(picture_.get()); 34 canvas->drawPicture(picture_.get());
34 canvas->restore();
35 } 35 }
36 36
37 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const { 37 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const {
38 return picture_->suitableForGpuRasterization(NULL); 38 return picture_->suitableForGpuRasterization(NULL);
39 } 39 }
40 40
41 int DrawingDisplayItem::ApproximateOpCount() const { 41 int DrawingDisplayItem::ApproximateOpCount() const {
42 return picture_->approximateOpCount(); 42 return picture_->approximateOpCount();
43 } 43 }
44 44
(...skipping 11 matching lines...) Expand all
56 base::StringPrintf("[%f,%f,%f,%f]", picture_->cullRect().x(), 56 base::StringPrintf("[%f,%f,%f,%f]", picture_->cullRect().x(),
57 picture_->cullRect().y(), picture_->cullRect().width(), 57 picture_->cullRect().y(), picture_->cullRect().width(),
58 picture_->cullRect().height())); 58 picture_->cullRect().height()));
59 std::string b64_picture; 59 std::string b64_picture;
60 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture); 60 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture);
61 array->SetString("skp64", b64_picture); 61 array->SetString("skp64", b64_picture);
62 array->EndDictionary(); 62 array->EndDictionary();
63 } 63 }
64 64
65 } // namespace cc 65 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698