OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/skpicture_content_layer_updater.h" | 7 #include "cc/skpicture_content_layer_updater.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/layer_painter.h" | 10 #include "cc/layer_painter.h" |
11 #include "cc/resource_update_queue.h" | 11 #include "cc/resource_update_queue.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 SkPictureContentLayerUpdater::Resource::Resource(SkPictureContentLayerUpdater* u
pdater, scoped_ptr<PrioritizedTexture> texture) | 16 SkPictureContentLayerUpdater::Resource::Resource(SkPictureContentLayerUpdater* u
pdater, scoped_ptr<PrioritizedTexture> texture) |
17 : LayerUpdater::Resource(texture.Pass()) | 17 : LayerUpdater::Resource(texture.Pass()) |
18 , m_updater(updater) | 18 , m_updater(updater) |
19 { | 19 { |
20 } | 20 } |
21 | 21 |
22 SkPictureContentLayerUpdater::Resource::~Resource() | 22 SkPictureContentLayerUpdater::Resource::~Resource() |
23 { | 23 { |
24 } | 24 } |
25 | 25 |
26 void SkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue,
const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, Render
ingStats&) | 26 void SkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue,
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate
, RenderingStats&) |
27 { | 27 { |
28 updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUp
date); | 28 updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUp
date); |
29 } | 29 } |
30 | 30 |
31 SkPictureContentLayerUpdater::SkPictureContentLayerUpdater(scoped_ptr<LayerPaint
er> painter) | 31 SkPictureContentLayerUpdater::SkPictureContentLayerUpdater(scoped_ptr<LayerPaint
er> painter) |
32 : ContentLayerUpdater(painter.Pass()) | 32 : ContentLayerUpdater(painter.Pass()) |
33 , m_layerIsOpaque(false) | 33 , m_layerIsOpaque(false) |
34 { | 34 { |
35 } | 35 } |
36 | 36 |
37 SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() | 37 SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() |
38 { | 38 { |
39 } | 39 } |
40 | 40 |
41 scoped_refptr<SkPictureContentLayerUpdater> SkPictureContentLayerUpdater::create
(scoped_ptr<LayerPainter> painter) | 41 scoped_refptr<SkPictureContentLayerUpdater> SkPictureContentLayerUpdater::create
(scoped_ptr<LayerPainter> painter) |
42 { | 42 { |
43 return make_scoped_refptr(new SkPictureContentLayerUpdater(painter.Pass())); | 43 return make_scoped_refptr(new SkPictureContentLayerUpdater(painter.Pass())); |
44 } | 44 } |
45 | 45 |
46 scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::createResource(
PrioritizedTextureManager* manager) | 46 scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::createResource(
PrioritizedTextureManager* manager) |
47 { | 47 { |
48 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText
ure::create(manager))); | 48 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText
ure::create(manager))); |
49 } | 49 } |
50 | 50 |
51 void SkPictureContentLayerUpdater::prepareToUpdate(const IntRect& contentRect, c
onst IntSize&, float contentsWidthScale, float contentsHeightScale, IntRect& res
ultingOpaqueRect, RenderingStats& stats) | 51 void SkPictureContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect,
const gfx::Size&, float contentsWidthScale, float contentsHeightScale, gfx::Rec
t& resultingOpaqueRect, RenderingStats& stats) |
52 { | 52 { |
53 SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect
.height()); | 53 SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect
.height()); |
54 paintContents(canvas, contentRect, contentsWidthScale, contentsHeightScale,
resultingOpaqueRect, stats); | 54 paintContents(canvas, contentRect, contentsWidthScale, contentsHeightScale,
resultingOpaqueRect, stats); |
55 m_picture.endRecording(); | 55 m_picture.endRecording(); |
56 } | 56 } |
57 | 57 |
58 void SkPictureContentLayerUpdater::drawPicture(SkCanvas* canvas) | 58 void SkPictureContentLayerUpdater::drawPicture(SkCanvas* canvas) |
59 { | 59 { |
60 TRACE_EVENT0("cc", "SkPictureContentLayerUpdater::drawPicture"); | 60 TRACE_EVENT0("cc", "SkPictureContentLayerUpdater::drawPicture"); |
61 canvas->drawPicture(m_picture); | 61 canvas->drawPicture(m_picture); |
62 } | 62 } |
63 | 63 |
64 void SkPictureContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, Pri
oritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset,
bool partialUpdate) | 64 void SkPictureContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, Pri
oritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& dest
Offset, bool partialUpdate) |
65 { | 65 { |
66 ResourceUpdate upload = ResourceUpdate::CreateFromPicture( | 66 ResourceUpdate upload = ResourceUpdate::CreateFromPicture( |
67 texture, &m_picture, contentRect(), sourceRect, destOffset); | 67 texture, &m_picture, contentRect(), sourceRect, destOffset); |
68 if (partialUpdate) | 68 if (partialUpdate) |
69 queue.appendPartialUpload(upload); | 69 queue.appendPartialUpload(upload); |
70 else | 70 else |
71 queue.appendFullUpload(upload); | 71 queue.appendFullUpload(upload); |
72 } | 72 } |
73 | 73 |
74 void SkPictureContentLayerUpdater::setOpaque(bool opaque) | 74 void SkPictureContentLayerUpdater::setOpaque(bool opaque) |
75 { | 75 { |
76 m_layerIsOpaque = opaque; | 76 m_layerIsOpaque = opaque; |
77 } | 77 } |
78 | 78 |
79 } // namespace cc | 79 } // namespace cc |
OLD | NEW |