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

Side by Side Diff: cc/test/tiled_layer_test_common.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
« no previous file with comments | « cc/test/tiled_layer_test_common.h ('k') | cc/trees/damage_tracker.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/tiled_layer_test_common.h" 5 #include "cc/test/tiled_layer_test_common.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer, 9 FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer,
10 scoped_ptr<PrioritizedResource> texture) 10 scoped_ptr<PrioritizedResource> texture)
11 : LayerUpdater::Resource(texture.Pass()), layer_(layer) { 11 : LayerUpdater::Resource(texture.Pass()), layer_(layer) {
12 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 12 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
13 bitmap_.allocPixels(); 13 bitmap_.allocPixels();
14 } 14 }
15 15
16 FakeLayerUpdater::Resource::~Resource() {} 16 FakeLayerUpdater::Resource::~Resource() {}
17 17
18 void FakeLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, 18 void FakeLayerUpdater::Resource::Update(ResourceUpdateQueue* queue,
19 gfx::Rect source_rect, 19 const gfx::Rect& source_rect,
20 gfx::Vector2d dest_offset, 20 gfx::Vector2d dest_offset,
21 bool partial_update) { 21 bool partial_update) {
22 const gfx::Rect kRect(0, 0, 10, 10); 22 const gfx::Rect kRect(0, 0, 10, 10);
23 ResourceUpdate upload = ResourceUpdate::Create( 23 ResourceUpdate upload = ResourceUpdate::Create(
24 texture(), &bitmap_, kRect, kRect, gfx::Vector2d()); 24 texture(), &bitmap_, kRect, kRect, gfx::Vector2d());
25 if (partial_update) 25 if (partial_update)
26 queue->AppendPartialUpload(upload); 26 queue->AppendPartialUpload(upload);
27 else 27 else
28 queue->AppendFullUpload(upload); 28 queue->AppendFullUpload(upload);
29 29
30 layer_->Update(); 30 layer_->Update();
31 } 31 }
32 32
33 FakeLayerUpdater::FakeLayerUpdater() : prepare_count_(0), update_count_(0) {} 33 FakeLayerUpdater::FakeLayerUpdater() : prepare_count_(0), update_count_(0) {}
34 34
35 FakeLayerUpdater::~FakeLayerUpdater() {} 35 FakeLayerUpdater::~FakeLayerUpdater() {}
36 36
37 void FakeLayerUpdater::PrepareToUpdate(gfx::Rect content_rect, 37 void FakeLayerUpdater::PrepareToUpdate(const gfx::Rect& content_rect,
38 gfx::Size tile_size, 38 gfx::Size tile_size,
39 float contents_width_scale, 39 float contents_width_scale,
40 float contents_height_scale, 40 float contents_height_scale,
41 gfx::Rect* resulting_opaque_rect) { 41 gfx::Rect* resulting_opaque_rect) {
42 prepare_count_++; 42 prepare_count_++;
43 last_update_rect_ = content_rect; 43 last_update_rect_ = content_rect;
44 if (!rect_to_invalidate_.IsEmpty()) { 44 if (!rect_to_invalidate_.IsEmpty()) {
45 layer_->InvalidateContentRect(rect_to_invalidate_); 45 layer_->InvalidateContentRect(rect_to_invalidate_);
46 rect_to_invalidate_ = gfx::Rect(); 46 rect_to_invalidate_ = gfx::Rect();
47 layer_ = NULL; 47 layer_ = NULL;
48 } 48 }
49 *resulting_opaque_rect = opaque_paint_rect_; 49 *resulting_opaque_rect = opaque_paint_rect_;
50 } 50 }
51 51
52 void FakeLayerUpdater::SetRectToInvalidate(gfx::Rect rect, 52 void FakeLayerUpdater::SetRectToInvalidate(const gfx::Rect& rect,
53 FakeTiledLayer* layer) { 53 FakeTiledLayer* layer) {
54 rect_to_invalidate_ = rect; 54 rect_to_invalidate_ = rect;
55 layer_ = layer; 55 layer_ = layer;
56 } 56 }
57 57
58 scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::CreateResource( 58 scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::CreateResource(
59 PrioritizedResourceManager* manager) { 59 PrioritizedResourceManager* manager) {
60 return scoped_ptr<LayerUpdater::Resource>( 60 return scoped_ptr<LayerUpdater::Resource>(
61 new Resource(this, PrioritizedResource::Create(manager))); 61 new Resource(this, PrioritizedResource::Create(manager)));
62 } 62 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 float* contents_scale_y, 162 float* contents_scale_y,
163 gfx::Size* content_bounds) { 163 gfx::Size* content_bounds) {
164 *contents_scale_x = 164 *contents_scale_x =
165 static_cast<float>(forced_content_bounds_.width()) / bounds().width(); 165 static_cast<float>(forced_content_bounds_.width()) / bounds().width();
166 *contents_scale_y = 166 *contents_scale_y =
167 static_cast<float>(forced_content_bounds_.height()) / bounds().height(); 167 static_cast<float>(forced_content_bounds_.height()) / bounds().height();
168 *content_bounds = forced_content_bounds_; 168 *content_bounds = forced_content_bounds_;
169 } 169 }
170 170
171 } // namespace cc 171 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/tiled_layer_test_common.h ('k') | cc/trees/damage_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698