Send a crash report when a hung process is detected.
[chromium-blink-merge.git] / ui / compositor / paint_recorder.cc
blob15aa0fb8edff443e07c3d98a19276fed1b66ca86
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.
5 #include "ui/compositor/paint_recorder.h"
7 #include "cc/resources/display_item_list.h"
8 #include "cc/resources/drawing_display_item.h"
9 #include "third_party/skia/include/core/SkPictureRecorder.h"
10 #include "ui/compositor/paint_context.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/skia_util.h"
14 namespace ui {
16 PaintRecorder::PaintRecorder(const PaintContext& context)
17 : context_(context), canvas_(context.canvas_) {
18 #if DCHECK_IS_ON()
19 DCHECK(!context.inside_paint_recorder_);
20 context.inside_paint_recorder_ = true;
21 #endif
23 if (context.list_) {
24 SkRTreeFactory* no_factory = nullptr;
25 // This SkCancas is shared with the recorder_ so no need to store a RefPtr
26 // to it on this class.
27 skia::RefPtr<SkCanvas> skcanvas =
28 skia::SharePtr(context.recorder_->beginRecording(
29 gfx::RectToSkRect(context.bounds_), no_factory,
30 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
31 owned_canvas_ = make_scoped_ptr(gfx::Canvas::CreateCanvasWithoutScaling(
32 skcanvas.get(), context.device_scale_factor_));
33 canvas_ = owned_canvas_.get();
37 PaintRecorder::~PaintRecorder() {
38 #if DCHECK_IS_ON()
39 context_.inside_paint_recorder_ = false;
40 #endif
42 if (context_.list_) {
43 context_.list_->AppendItem(cc::DrawingDisplayItem::Create(
44 skia::AdoptRef(context_.recorder_->endRecordingAsPicture())));
48 } // namespace ui