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

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

Issue 23484005: Skip clearing the canvas before painting the contents of opaque layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unecessary newline Created 7 years, 3 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 | « no previous file | cc/resources/content_layer_updater.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 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 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/bitmap_content_layer_updater.h" 5 #include "cc/resources/bitmap_content_layer_updater.h"
6 6
7 #include "cc/debug/devtools_instrumentation.h" 7 #include "cc/debug/devtools_instrumentation.h"
8 #include "cc/debug/rendering_stats_instrumentation.h" 8 #include "cc/debug/rendering_stats_instrumentation.h"
9 #include "cc/resources/layer_painter.h" 9 #include "cc/resources/layer_painter.h"
10 #include "cc/resources/prioritized_resource.h" 10 #include "cc/resources/prioritized_resource.h"
(...skipping 25 matching lines...) Expand all
36 return make_scoped_refptr( 36 return make_scoped_refptr(
37 new BitmapContentLayerUpdater(painter.Pass(), 37 new BitmapContentLayerUpdater(painter.Pass(),
38 stats_instrumentation, 38 stats_instrumentation,
39 layer_id)); 39 layer_id));
40 } 40 }
41 41
42 BitmapContentLayerUpdater::BitmapContentLayerUpdater( 42 BitmapContentLayerUpdater::BitmapContentLayerUpdater(
43 scoped_ptr<LayerPainter> painter, 43 scoped_ptr<LayerPainter> painter,
44 RenderingStatsInstrumentation* stats_instrumentation, 44 RenderingStatsInstrumentation* stats_instrumentation,
45 int layer_id) 45 int layer_id)
46 : ContentLayerUpdater(painter.Pass(), stats_instrumentation, layer_id), 46 : ContentLayerUpdater(painter.Pass(), stats_instrumentation, layer_id) {}
47 opaque_(false) {}
48 47
49 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} 48 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {}
50 49
51 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( 50 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource(
52 PrioritizedResourceManager* manager) { 51 PrioritizedResourceManager* manager) {
53 return scoped_ptr<LayerUpdater::Resource>( 52 return scoped_ptr<LayerUpdater::Resource>(
54 new Resource(this, PrioritizedResource::Create(manager))); 53 new Resource(this, PrioritizedResource::Create(manager)));
55 } 54 }
56 55
57 void BitmapContentLayerUpdater::PrepareToUpdate( 56 void BitmapContentLayerUpdater::PrepareToUpdate(
58 gfx::Rect content_rect, 57 gfx::Rect content_rect,
59 gfx::Size tile_size, 58 gfx::Size tile_size,
60 float contents_width_scale, 59 float contents_width_scale,
61 float contents_height_scale, 60 float contents_height_scale,
62 gfx::Rect* resulting_opaque_rect) { 61 gfx::Rect* resulting_opaque_rect) {
63 devtools_instrumentation::ScopedLayerTask paint_layer( 62 devtools_instrumentation::ScopedLayerTask paint_layer(
64 devtools_instrumentation::kPaintLayer, layer_id_); 63 devtools_instrumentation::kPaintLayer, layer_id_);
65 if (canvas_size_ != content_rect.size()) { 64 if (canvas_size_ != content_rect.size()) {
66 devtools_instrumentation::ScopedLayerTask paint_setup( 65 devtools_instrumentation::ScopedLayerTask paint_setup(
67 devtools_instrumentation::kPaintSetup, layer_id_); 66 devtools_instrumentation::kPaintSetup, layer_id_);
68 canvas_size_ = content_rect.size(); 67 canvas_size_ = content_rect.size();
69 canvas_ = skia::AdoptRef(skia::CreateBitmapCanvas( 68 canvas_ = skia::AdoptRef(skia::CreateBitmapCanvas(
70 canvas_size_.width(), canvas_size_.height(), opaque_)); 69 canvas_size_.width(), canvas_size_.height(), layer_is_opaque_));
71 } 70 }
72 71
73 base::TimeTicks start_time = 72 base::TimeTicks start_time =
74 rendering_stats_instrumentation_->StartRecording(); 73 rendering_stats_instrumentation_->StartRecording();
75 PaintContents(canvas_.get(), 74 PaintContents(canvas_.get(),
76 content_rect, 75 content_rect.origin(),
77 contents_width_scale, 76 contents_width_scale,
78 contents_height_scale, 77 contents_height_scale,
79 resulting_opaque_rect); 78 resulting_opaque_rect);
80 base::TimeDelta duration = 79 base::TimeDelta duration =
81 rendering_stats_instrumentation_->EndRecording(start_time); 80 rendering_stats_instrumentation_->EndRecording(start_time);
82 rendering_stats_instrumentation_->AddPaint( 81 rendering_stats_instrumentation_->AddPaint(
83 duration, 82 duration,
84 content_rect.width() * content_rect.height()); 83 content_rect.width() * content_rect.height());
85 } 84 }
86 85
(...skipping 14 matching lines...) Expand all
101 else 100 else
102 queue->AppendFullUpload(upload); 101 queue->AppendFullUpload(upload);
103 } 102 }
104 103
105 void BitmapContentLayerUpdater::ReduceMemoryUsage() { 104 void BitmapContentLayerUpdater::ReduceMemoryUsage() {
106 canvas_.clear(); 105 canvas_.clear();
107 canvas_size_ = gfx::Size(); 106 canvas_size_ = gfx::Size();
108 } 107 }
109 108
110 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { 109 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
111 if (opaque != opaque_) { 110 if (opaque != layer_is_opaque_) {
112 canvas_.clear(); 111 canvas_.clear();
113 canvas_size_ = gfx::Size(); 112 canvas_size_ = gfx::Size();
114 } 113 }
115 opaque_ = opaque; 114
115 ContentLayerUpdater::SetOpaque(opaque);
116 } 116 }
117 117
118 } // namespace cc 118 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698