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

Side by Side Diff: cc/content_layer.cc

Issue 12603013: Part 10 of cc/ directory shuffles: layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/content_layer.h ('k') | cc/content_layer_client.h » ('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 2010 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 "cc/content_layer.h"
6
7 #include "base/auto_reset.h"
8 #include "base/metrics/histogram.h"
9 #include "base/time.h"
10 #include "cc/content_layer_client.h"
11 #include "cc/resources/bitmap_content_layer_updater.h"
12 #include "cc/resources/bitmap_skpicture_content_layer_updater.h"
13 #include "cc/resources/layer_painter.h"
14 #include "cc/trees/layer_tree_host.h"
15
16 namespace cc {
17
18 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client)
19 : client_(client) {}
20
21 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create(
22 ContentLayerClient* client) {
23 return make_scoped_ptr(new ContentLayerPainter(client));
24 }
25
26 void ContentLayerPainter::Paint(SkCanvas* canvas,
27 gfx::Rect content_rect,
28 gfx::RectF* opaque) {
29 base::TimeTicks paint_start = base::TimeTicks::HighResNow();
30 client_->PaintContents(canvas, content_rect, opaque);
31 base::TimeTicks paint_end = base::TimeTicks::HighResNow();
32 double pixels_per_sec = (content_rect.width() * content_rect.height()) /
33 (paint_end - paint_start).InSecondsF();
34 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS",
35 (paint_end - paint_start).InMilliseconds(),
36 0,
37 120,
38 30);
39 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond",
40 pixels_per_sec / 1000000,
41 10,
42 210,
43 30);
44 }
45
46 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) {
47 return make_scoped_refptr(new ContentLayer(client));
48 }
49
50 ContentLayer::ContentLayer(ContentLayerClient* client)
51 : TiledLayer(),
52 client_(client) {}
53
54 ContentLayer::~ContentLayer() {}
55
56 bool ContentLayer::DrawsContent() const {
57 return TiledLayer::DrawsContent() && client_;
58 }
59
60 void ContentLayer::SetTexturePriorities(
61 const PriorityCalculator& priority_calc) {
62 // Update the tile data before creating all the layer's tiles.
63 UpdateTileSizeAndTilingOption();
64
65 TiledLayer::SetTexturePriorities(priority_calc);
66 }
67
68 void ContentLayer::Update(ResourceUpdateQueue* queue,
69 const OcclusionTracker* occlusion,
70 RenderingStats* stats) {
71 {
72 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
73 true);
74
75 CreateUpdaterIfNeeded();
76 }
77
78 TiledLayer::Update(queue, occlusion, stats);
79 needs_display_ = false;
80 }
81
82 bool ContentLayer::NeedMoreUpdates() {
83 return NeedsIdlePaint();
84 }
85
86 LayerUpdater* ContentLayer::Updater() const {
87 return updater_.get();
88 }
89
90 void ContentLayer::CreateUpdaterIfNeeded() {
91 if (updater_)
92 return;
93 scoped_ptr<LayerPainter> painter =
94 ContentLayerPainter::Create(client_).PassAs<LayerPainter>();
95 if (layer_tree_host()->settings().acceleratePainting)
96 updater_ = SkPictureContentLayerUpdater::Create(painter.Pass());
97 else if (layer_tree_host()->settings().perTilePaintingEnabled)
98 updater_ = BitmapSkPictureContentLayerUpdater::Create(painter.Pass());
99 else
100 updater_ = BitmapContentLayerUpdater::Create(painter.Pass());
101 updater_->SetOpaque(contents_opaque());
102
103 unsigned texture_format =
104 layer_tree_host()->GetRendererCapabilities().best_texture_format;
105 SetTextureFormat(texture_format);
106 }
107
108 void ContentLayer::SetContentsOpaque(bool opaque) {
109 Layer::SetContentsOpaque(opaque);
110 if (updater_)
111 updater_->SetOpaque(opaque);
112 }
113
114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/content_layer.h ('k') | cc/content_layer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698