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

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

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! 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 gfx::Rect source_rect, 25 const gfx::Rect& source_rect,
26 gfx::Vector2d dest_offset, 26 gfx::Vector2d dest_offset,
27 bool partial_update) { 27 bool partial_update) {
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) {
(...skipping 11 matching lines...) Expand all
47 47
48 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} 48 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {}
49 49
50 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( 50 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource(
51 PrioritizedResourceManager* manager) { 51 PrioritizedResourceManager* manager) {
52 return scoped_ptr<LayerUpdater::Resource>( 52 return scoped_ptr<LayerUpdater::Resource>(
53 new Resource(this, PrioritizedResource::Create(manager))); 53 new Resource(this, PrioritizedResource::Create(manager)));
54 } 54 }
55 55
56 void BitmapContentLayerUpdater::PrepareToUpdate( 56 void BitmapContentLayerUpdater::PrepareToUpdate(
57 gfx::Rect content_rect, 57 const gfx::Rect& content_rect,
58 gfx::Size tile_size, 58 gfx::Size tile_size,
59 float contents_width_scale, 59 float contents_width_scale,
60 float contents_height_scale, 60 float contents_height_scale,
61 gfx::Rect* resulting_opaque_rect) { 61 gfx::Rect* resulting_opaque_rect) {
62 if (canvas_size_ != content_rect.size()) { 62 if (canvas_size_ != content_rect.size()) {
63 devtools_instrumentation::ScopedLayerTask paint_setup( 63 devtools_instrumentation::ScopedLayerTask paint_setup(
64 devtools_instrumentation::kPaintSetup, layer_id_); 64 devtools_instrumentation::kPaintSetup, layer_id_);
65 canvas_size_ = content_rect.size(); 65 canvas_size_ = content_rect.size();
66 bitmap_backing_.setConfig( 66 bitmap_backing_.setConfig(
67 SkBitmap::kARGB_8888_Config, 67 SkBitmap::kARGB_8888_Config,
(...skipping 12 matching lines...) Expand all
80 resulting_opaque_rect); 80 resulting_opaque_rect);
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 gfx::Rect source_rect, 90 const gfx::Rect& source_rect,
91 gfx::Vector2d dest_offset, 91 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
« no previous file with comments | « cc/resources/bitmap_content_layer_updater.h ('k') | cc/resources/bitmap_skpicture_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698