1 // Copyright 2011 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 "cc/resources/skpicture_content_layer_updater.h"
7 #include "base/debug/trace_event.h"
8 #include "cc/debug/rendering_stats_instrumentation.h"
9 #include "cc/resources/layer_painter.h"
10 #include "cc/resources/prioritized_resource.h"
11 #include "cc/resources/resource_update_queue.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
16 SkPictureContentLayerUpdater::SkPictureContentLayerUpdater(
17 scoped_ptr
<LayerPainter
> painter
,
18 RenderingStatsInstrumentation
* stats_instrumentation
,
20 : ContentLayerUpdater(painter
.Pass(), stats_instrumentation
, layer_id
) {}
22 SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() {}
24 void SkPictureContentLayerUpdater::PrepareToUpdate(
25 gfx::Rect content_rect
,
27 float contents_width_scale
,
28 float contents_height_scale
,
29 gfx::Rect
* resulting_opaque_rect
) {
31 picture_
.beginRecording(content_rect
.width(), content_rect
.height());
32 base::TimeTicks start_time
=
33 rendering_stats_instrumentation_
->StartRecording();
37 contents_height_scale
,
38 resulting_opaque_rect
);
39 base::TimeDelta duration
=
40 rendering_stats_instrumentation_
->EndRecording(start_time
);
41 rendering_stats_instrumentation_
->AddRecord(
42 duration
, content_rect
.width() * content_rect
.height());
43 picture_
.endRecording();
46 void SkPictureContentLayerUpdater::DrawPicture(SkCanvas
* canvas
) {
47 TRACE_EVENT0("cc", "SkPictureContentLayerUpdater::DrawPicture");
48 canvas
->drawPicture(picture_
);