OLD | NEW |
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 gfx::Rect source_rect, |
20 gfx::Vector2d dest_offset, | 20 gfx::Vector2d dest_offset, |
21 bool partial_update, | 21 bool partial_update) { |
22 RenderingStats* stats) { | |
23 const gfx::Rect kRect(0, 0, 10, 10); | 22 const gfx::Rect kRect(0, 0, 10, 10); |
24 ResourceUpdate upload = ResourceUpdate::Create( | 23 ResourceUpdate upload = ResourceUpdate::Create( |
25 texture(), &bitmap_, kRect, kRect, gfx::Vector2d()); | 24 texture(), &bitmap_, kRect, kRect, gfx::Vector2d()); |
26 if (partial_update) | 25 if (partial_update) |
27 queue->AppendPartialUpload(upload); | 26 queue->AppendPartialUpload(upload); |
28 else | 27 else |
29 queue->AppendFullUpload(upload); | 28 queue->AppendFullUpload(upload); |
30 | 29 |
31 layer_->Update(); | 30 layer_->Update(); |
32 } | 31 } |
33 | 32 |
34 FakeLayerUpdater::FakeLayerUpdater() : prepare_count_(0), update_count_(0) {} | 33 FakeLayerUpdater::FakeLayerUpdater() : prepare_count_(0), update_count_(0) {} |
35 | 34 |
36 FakeLayerUpdater::~FakeLayerUpdater() {} | 35 FakeLayerUpdater::~FakeLayerUpdater() {} |
37 | 36 |
38 void FakeLayerUpdater::PrepareToUpdate(gfx::Rect content_rect, | 37 void FakeLayerUpdater::PrepareToUpdate(gfx::Rect content_rect, |
39 gfx::Size tile_size, | 38 gfx::Size tile_size, |
40 float contents_width_scale, | 39 float contents_width_scale, |
41 float contents_height_scale, | 40 float contents_height_scale, |
42 gfx::Rect* resulting_opaque_rect, | 41 gfx::Rect* resulting_opaque_rect) { |
43 RenderingStats* stats) { | |
44 prepare_count_++; | 42 prepare_count_++; |
45 last_update_rect_ = content_rect; | 43 last_update_rect_ = content_rect; |
46 if (!rect_to_invalidate_.IsEmpty()) { | 44 if (!rect_to_invalidate_.IsEmpty()) { |
47 layer_->InvalidateContentRect(rect_to_invalidate_); | 45 layer_->InvalidateContentRect(rect_to_invalidate_); |
48 rect_to_invalidate_ = gfx::Rect(); | 46 rect_to_invalidate_ = gfx::Rect(); |
49 layer_ = NULL; | 47 layer_ = NULL; |
50 } | 48 } |
51 *resulting_opaque_rect = opaque_paint_rect_; | 49 *resulting_opaque_rect = opaque_paint_rect_; |
52 } | 50 } |
53 | 51 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 float* contents_scale_y, | 138 float* contents_scale_y, |
141 gfx::Size* content_bounds) { | 139 gfx::Size* content_bounds) { |
142 *contents_scale_x = | 140 *contents_scale_x = |
143 static_cast<float>(forced_content_bounds_.width()) / bounds().width(); | 141 static_cast<float>(forced_content_bounds_.width()) / bounds().width(); |
144 *contents_scale_y = | 142 *contents_scale_y = |
145 static_cast<float>(forced_content_bounds_.height()) / bounds().height(); | 143 static_cast<float>(forced_content_bounds_.height()) / bounds().height(); |
146 *content_bounds = forced_content_bounds_; | 144 *content_bounds = forced_content_bounds_; |
147 } | 145 } |
148 | 146 |
149 } // namespace cc | 147 } // namespace cc |
OLD | NEW |