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