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

Side by Side Diff: cc/picture_image_layer.cc

Issue 12095053: cc: Avoid expensive RenderingStats collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « cc/picture_image_layer.h ('k') | cc/picture_layer.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/picture_image_layer.h" 5 #include "cc/picture_image_layer.h"
6 6
7 #include "third_party/skia/include/core/SkCanvas.h" 7 #include "third_party/skia/include/core/SkCanvas.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
(...skipping 21 matching lines...) Expand all
32 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) 32 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef())
33 return; 33 return;
34 34
35 bitmap_ = bitmap; 35 bitmap_ = bitmap;
36 setNeedsDisplay(); 36 setNeedsDisplay();
37 } 37 }
38 38
39 void PictureImageLayer::update( 39 void PictureImageLayer::update(
40 ResourceUpdateQueue& queue, 40 ResourceUpdateQueue& queue,
41 const OcclusionTracker* tracker, 41 const OcclusionTracker* tracker,
42 RenderingStats& stats) { 42 RenderingStats* stats) {
43 if (bounds() != bounds_) { 43 if (bounds() != bounds_) {
44 // Pictures are recorded in layer space, so if the layer size changes, 44 // Pictures are recorded in layer space, so if the layer size changes,
45 // then the picture needs to be re-scaled, as a directly composited image 45 // then the picture needs to be re-scaled, as a directly composited image
46 // always fills its entire layer bounds. This could be improved by 46 // always fills its entire layer bounds. This could be improved by
47 // recording pictures of images at their actual resolution somehow. 47 // recording pictures of images at their actual resolution somehow.
48 bounds_ = bounds(); 48 bounds_ = bounds();
49 setNeedsDisplay(); 49 setNeedsDisplay();
50 } 50 }
51 PictureLayer::update(queue, tracker, stats); 51 PictureLayer::update(queue, tracker, stats);
52 } 52 }
53 53
54 void PictureImageLayer::paintContents( 54 void PictureImageLayer::paintContents(
55 SkCanvas* canvas, 55 SkCanvas* canvas,
56 const gfx::Rect& clip, 56 const gfx::Rect& clip,
57 gfx::RectF& opaque) { 57 gfx::RectF& opaque) {
58 if (!bitmap_.width() || !bitmap_.height()) 58 if (!bitmap_.width() || !bitmap_.height())
59 return; 59 return;
60 60
61 SkScalar content_to_layer_scale_x = SkFloatToScalar( 61 SkScalar content_to_layer_scale_x = SkFloatToScalar(
62 static_cast<float>(bounds().width()) / bitmap_.width()); 62 static_cast<float>(bounds().width()) / bitmap_.width());
63 SkScalar content_to_layer_scale_y = SkFloatToScalar( 63 SkScalar content_to_layer_scale_y = SkFloatToScalar(
64 static_cast<float>(bounds().height()) / bitmap_.height()); 64 static_cast<float>(bounds().height()) / bitmap_.height());
65 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); 65 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
66 66
67 canvas->drawBitmap(bitmap_, 0, 0); 67 canvas->drawBitmap(bitmap_, 0, 0);
68 } 68 }
69 69
70 } // namespace cc 70 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_image_layer.h ('k') | cc/picture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698