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

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

Issue 132163009: [#6]Pass gfx structs by const ref (gfx::Vector2d) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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
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"
11 #include "cc/resources/resource_update.h" 11 #include "cc/resources/resource_update.h"
12 #include "cc/resources/resource_update_queue.h" 12 #include "cc/resources/resource_update_queue.h"
13 #include "skia/ext/platform_canvas.h" 13 #include "skia/ext/platform_canvas.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 BitmapContentLayerUpdater::Resource::Resource( 17 BitmapContentLayerUpdater::Resource::Resource(
18 BitmapContentLayerUpdater* updater, 18 BitmapContentLayerUpdater* updater,
19 scoped_ptr<PrioritizedResource> texture) 19 scoped_ptr<PrioritizedResource> texture)
20 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {} 20 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
21 21
22 BitmapContentLayerUpdater::Resource::~Resource() {} 22 BitmapContentLayerUpdater::Resource::~Resource() {}
23 23
24 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, 24 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue,
25 const gfx::Rect& source_rect, 25 const gfx::Rect& source_rect,
26 gfx::Vector2d dest_offset, 26 const gfx::Vector2d& dest_offset,
27 bool partial_update) { 27 bool partial_update) {
r.kasibhatla 2014/01/24 05:32:16 The alignment is wrong. Correct it.
28 updater_->UpdateTexture( 28 updater_->UpdateTexture(
29 queue, texture(), source_rect, dest_offset, partial_update); 29 queue, texture(), source_rect, dest_offset, partial_update);
30 } 30 }
31 31
32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( 32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create(
33 scoped_ptr<LayerPainter> painter, 33 scoped_ptr<LayerPainter> painter,
34 RenderingStatsInstrumentation* stats_instrumentation, 34 RenderingStatsInstrumentation* stats_instrumentation,
35 int layer_id) { 35 int layer_id) {
36 return make_scoped_refptr( 36 return make_scoped_refptr(
37 new BitmapContentLayerUpdater(painter.Pass(), 37 new BitmapContentLayerUpdater(painter.Pass(),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 base::TimeDelta duration = 81 base::TimeDelta duration =
82 rendering_stats_instrumentation_->EndRecording(start_time); 82 rendering_stats_instrumentation_->EndRecording(start_time);
83 rendering_stats_instrumentation_->AddPaint( 83 rendering_stats_instrumentation_->AddPaint(
84 duration, 84 duration,
85 content_rect.width() * content_rect.height()); 85 content_rect.width() * content_rect.height());
86 } 86 }
87 87
88 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, 88 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
89 PrioritizedResource* texture, 89 PrioritizedResource* texture,
90 const gfx::Rect& source_rect, 90 const gfx::Rect& source_rect,
91 gfx::Vector2d dest_offset, 91 const gfx::Vector2d& dest_offset,
92 bool partial_update) { 92 bool partial_update) {
93 CHECK(canvas_); 93 CHECK(canvas_);
94 ResourceUpdate upload = ResourceUpdate::Create(texture, 94 ResourceUpdate upload = ResourceUpdate::Create(texture,
95 &bitmap_backing_, 95 &bitmap_backing_,
96 content_rect(), 96 content_rect(),
97 source_rect, 97 source_rect,
98 dest_offset); 98 dest_offset);
99 if (partial_update) 99 if (partial_update)
100 queue->AppendPartialUpload(upload); 100 queue->AppendPartialUpload(upload);
101 else 101 else
102 queue->AppendFullUpload(upload); 102 queue->AppendFullUpload(upload);
103 } 103 }
104 104
105 void BitmapContentLayerUpdater::ReduceMemoryUsage() { 105 void BitmapContentLayerUpdater::ReduceMemoryUsage() {
106 canvas_.clear(); 106 canvas_.clear();
107 canvas_size_ = gfx::Size(); 107 canvas_size_ = gfx::Size();
108 } 108 }
109 109
110 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { 110 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
111 if (opaque != layer_is_opaque_) { 111 if (opaque != layer_is_opaque_) {
112 canvas_.clear(); 112 canvas_.clear();
113 canvas_size_ = gfx::Size(); 113 canvas_size_ = gfx::Size();
114 } 114 }
115 115
116 ContentLayerUpdater::SetOpaque(opaque); 116 ContentLayerUpdater::SetOpaque(opaque);
117 } 117 }
118 118
119 } // namespace cc 119 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698