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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 #include "cc/picture_pile_impl.h" | 6 #include "cc/picture_pile_impl.h" |
7 #include "cc/rendering_stats.h" | 7 #include "cc/rendering_stats.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "third_party/skia/include/core/SkSize.h" | 9 #include "third_party/skia/include/core/SkSize.h" |
| 10 #include "ui/gfx/rect_conversions.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { | 14 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { |
14 return make_scoped_refptr(new PicturePileImpl()); | 15 return make_scoped_refptr(new PicturePileImpl()); |
15 } | 16 } |
16 | 17 |
17 PicturePileImpl::PicturePileImpl() { | 18 PicturePileImpl::PicturePileImpl() { |
18 } | 19 } |
19 | 20 |
(...skipping 18 matching lines...) Expand all Loading... |
38 scoped_refptr<PicturePileImpl> clone = Create(); | 39 scoped_refptr<PicturePileImpl> clone = Create(); |
39 for (PicturePile::Pile::const_iterator i = pile_.begin(); | 40 for (PicturePile::Pile::const_iterator i = pile_.begin(); |
40 i != pile_.end(); ++i) | 41 i != pile_.end(); ++i) |
41 clone->pile_.push_back((*i)->Clone()); | 42 clone->pile_.push_back((*i)->Clone()); |
42 | 43 |
43 return clone; | 44 return clone; |
44 } | 45 } |
45 | 46 |
46 void PicturePileImpl::Raster( | 47 void PicturePileImpl::Raster( |
47 SkCanvas* canvas, | 48 SkCanvas* canvas, |
48 gfx::Rect rect, | 49 gfx::Rect content_rect, |
49 float contents_scale, | 50 float contents_scale, |
50 RenderingStats* stats) { | 51 RenderingStats* stats) { |
51 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); | 52 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); |
52 | 53 |
53 // TODO(enne): do this more efficiently, i.e. top down with Skia clips | 54 // TODO(enne): do this more efficiently, i.e. top down with Skia clips |
54 canvas->save(); | 55 canvas->save(); |
55 canvas->translate(-rect.x(), -rect.y()); | 56 canvas->translate(-content_rect.x(), -content_rect.y()); |
56 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), | 57 SkRect layer_skrect = SkRect::MakeXYWH( |
57 rect.width(), rect.height()); | 58 content_rect.x(), |
| 59 content_rect.y(), |
| 60 content_rect.width(), |
| 61 content_rect.height()); |
58 canvas->clipRect(layer_skrect); | 62 canvas->clipRect(layer_skrect); |
59 canvas->scale(contents_scale, contents_scale); | 63 canvas->scale(contents_scale, contents_scale); |
| 64 |
| 65 gfx::Rect layer_rect = gfx::ToEnclosedRect(gfx::ScaleRect(gfx::RectF(content_r
ect), 1 / contents_scale)); |
| 66 |
60 for (PicturePile::Pile::const_iterator i = pile_.begin(); | 67 for (PicturePile::Pile::const_iterator i = pile_.begin(); |
61 i != pile_.end(); ++i) { | 68 i != pile_.end(); ++i) { |
62 if (!(*i)->LayerRect().Intersects(rect)) | 69 if (!(*i)->LayerRect().Intersects(layer_rect)) |
63 continue; | 70 continue; |
64 (*i)->Raster(canvas); | 71 (*i)->Raster(canvas); |
65 | 72 |
66 SkISize deviceSize = canvas->getDeviceSize(); | 73 SkISize deviceSize = canvas->getDeviceSize(); |
67 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height(); | 74 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height(); |
68 } | 75 } |
69 canvas->restore(); | 76 canvas->restore(); |
70 | 77 |
71 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - | 78 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - |
72 rasterizeBeginTime).InSecondsF(); | 79 rasterizeBeginTime).InSecondsF(); |
73 } | 80 } |
74 | 81 |
75 } // namespace cc | 82 } // namespace cc |
OLD | NEW |