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

Side by Side Diff: ui/compositor/layer_unittest.cc

Issue 637933004: Fix memory issues in compositor_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 224 }
225 225
226 float device_scale_factor() const { 226 float device_scale_factor() const {
227 return device_scale_factor_; 227 return device_scale_factor_;
228 } 228 }
229 229
230 // Overridden from LayerDelegate: 230 // Overridden from LayerDelegate:
231 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 231 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
232 SkISize size = canvas->sk_canvas()->getBaseLayerSize(); 232 SkISize size = canvas->sk_canvas()->getBaseLayerSize();
233 paint_size_ = gfx::Size(size.width(), size.height()); 233 paint_size_ = gfx::Size(size.width(), size.height());
234 canvas->FillRect(gfx::Rect(paint_size_), colors_[color_index_]); 234 canvas->DrawColor(colors_[color_index_]);
235 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); 235 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size());
236 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); 236 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix();
237 scale_x_ = matrix.getScaleX(); 237 scale_x_ = matrix.getScaleX();
238 scale_y_ = matrix.getScaleY(); 238 scale_y_ = matrix.getScaleY();
239 } 239 }
240 240
241 virtual void OnDelegatedFrameDamage( 241 virtual void OnDelegatedFrameDamage(
242 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} 242 const gfx::Rect& damage_rect_in_dip) OVERRIDE {}
243 243
244 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { 244 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void Reset() { 276 void Reset() {
277 painted_ = false; 277 painted_ = false;
278 } 278 }
279 279
280 bool painted() const { return painted_; } 280 bool painted() const { return painted_; }
281 281
282 private: 282 private:
283 // Overridden from LayerDelegate: 283 // Overridden from LayerDelegate:
284 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 284 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
285 painted_ = true; 285 painted_ = true;
286 canvas->DrawColor(SK_ColorTRANSPARENT);
286 } 287 }
287 virtual void OnDelegatedFrameDamage( 288 virtual void OnDelegatedFrameDamage(
288 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} 289 const gfx::Rect& damage_rect_in_dip) OVERRIDE {}
289 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { 290 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {
290 } 291 }
291 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE { 292 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
292 return base::Closure(); 293 return base::Closure();
293 } 294 }
294 295
295 bool painted_; 296 bool painted_;
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 MakeFrameData(gfx::Size(10, 10)))); 1745 MakeFrameData(gfx::Size(10, 10))));
1745 layer->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10)); 1746 layer->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10));
1746 1747
1747 EXPECT_FALSE(delegate.delegated_frame_damage_called()); 1748 EXPECT_FALSE(delegate.delegated_frame_damage_called());
1748 layer->OnDelegatedFrameDamage(damage_rect); 1749 layer->OnDelegatedFrameDamage(damage_rect);
1749 EXPECT_TRUE(delegate.delegated_frame_damage_called()); 1750 EXPECT_TRUE(delegate.delegated_frame_damage_called());
1750 EXPECT_EQ(damage_rect, delegate.delegated_frame_damage_rect()); 1751 EXPECT_EQ(damage_rect, delegate.delegated_frame_damage_rect());
1751 } 1752 }
1752 1753
1753 } // namespace ui 1754 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698