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

Side by Side Diff: ui/compositor/paint_recorder.cc

Issue 1021823002: Introduce ui::PaintRecorder and use it for CursorWindowDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: slimmingui-paintrecorder: rebase Created 5 years, 9 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 | « ui/compositor/paint_recorder.h ('k') | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/compositor/paint_recorder.h"
6
7 #include "cc/resources/display_item_list.h"
8 #include "cc/resources/drawing_display_item.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/skia_util.h"
12
13 namespace ui {
14
15 PaintRecorder::PaintRecorder(const gfx::Rect& recording_bounds,
16 float device_scale_factor)
17 : device_scale_factor_(device_scale_factor) {
18 SkRTreeFactory* no_factory = nullptr;
19 skcanvas_ = skia::SharePtr(recorder_.beginRecording(
20 gfx::RectToSkRect(recording_bounds), no_factory,
21 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
22 skcanvas_->clipRect(gfx::RectToSkRect(recording_bounds));
23 canvas_ = make_scoped_ptr(gfx::Canvas::CreateCanvasWithoutScaling(
24 skcanvas(), device_scale_factor_));
25 }
26
27 PaintRecorder::~PaintRecorder() {
28 }
29
30 scoped_ptr<cc::DrawingDisplayItem> PaintRecorder::TakeDisplayItem() {
31 DCHECK(skcanvas_);
32 scoped_ptr<cc::DrawingDisplayItem> item =
33 cc::DrawingDisplayItem::Create(skia::AdoptRef(recorder_.endRecording()));
34 skcanvas_.clear(); // Prevent this method from being called again.
35 return item;
36 }
37
38 void PaintRecorder::AppendDisplayItem(cc::DisplayItemList* list) {
39 DCHECK(skcanvas_);
40 list->AppendItem(TakeDisplayItem());
41 }
42
43 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698