From 64d8d39667043c562e0e1b0384c1e662b1accfc1 Mon Sep 17 00:00:00 2001 From: "reveman@google.com" Date: Tue, 23 Oct 2012 18:34:51 +0000 Subject: cc: Rename LayerTextureUpdater to LayerUpdater. sed -e ' s/TextureUpdater/Updater/g s/textureUpdater/updater/g s/texture_updater\.h/updater.h/g s/texture_updater\.cc/updater.cc/g s/TEXTURE_UPDATER_H_/UPDATER_H_/g ' BUG= TEST=cc_unittests Review URL: https://codereview.chromium.org/11231082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163615 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/bitmap_canvas_layer_texture_updater.cc | 84 ------------- cc/bitmap_canvas_layer_texture_updater.h | 54 -------- cc/bitmap_canvas_layer_updater.cc | 84 +++++++++++++ cc/bitmap_canvas_layer_updater.h | 54 ++++++++ ...itmap_skpicture_canvas_layer_texture_updater.cc | 72 ----------- cc/bitmap_skpicture_canvas_layer_texture_updater.h | 42 ------- cc/bitmap_skpicture_canvas_layer_updater.cc | 72 +++++++++++ cc/bitmap_skpicture_canvas_layer_updater.h | 42 +++++++ cc/caching_bitmap_canvas_layer_texture_updater.cc | 65 ---------- cc/caching_bitmap_canvas_layer_texture_updater.h | 39 ------ cc/caching_bitmap_canvas_layer_updater.cc | 65 ++++++++++ cc/caching_bitmap_canvas_layer_updater.h | 39 ++++++ cc/canvas_layer_texture_updater.cc | 66 ---------- cc/canvas_layer_texture_updater.h | 34 ----- cc/canvas_layer_updater.cc | 66 ++++++++++ cc/canvas_layer_updater.h | 34 +++++ cc/cc.gyp | 24 ++-- cc/content_layer.cc | 26 ++-- cc/content_layer.h | 8 +- cc/content_layer_unittest.cc | 4 +- cc/image_layer.cc | 44 +++---- cc/image_layer.h | 8 +- cc/layer_texture_updater.cc | 20 --- cc/layer_texture_updater.h | 58 --------- cc/layer_updater.cc | 20 +++ cc/layer_updater.h | 58 +++++++++ cc/scrollbar_layer.cc | 14 +-- cc/scrollbar_layer.h | 18 +-- cc/skpicture_canvas_layer_texture_updater.cc | 79 ------------ cc/skpicture_canvas_layer_texture_updater.h | 61 --------- cc/skpicture_canvas_layer_updater.cc | 79 ++++++++++++ cc/skpicture_canvas_layer_updater.h | 61 +++++++++ cc/test/tiled_layer_test_common.cc | 26 ++-- cc/test/tiled_layer_test_common.h | 24 ++-- cc/tiled_layer.cc | 20 +-- cc/tiled_layer.h | 6 +- cc/tiled_layer_unittest.cc | 140 ++++++++++----------- 37 files changed, 855 insertions(+), 855 deletions(-) delete mode 100644 cc/bitmap_canvas_layer_texture_updater.cc delete mode 100644 cc/bitmap_canvas_layer_texture_updater.h create mode 100644 cc/bitmap_canvas_layer_updater.cc create mode 100644 cc/bitmap_canvas_layer_updater.h delete mode 100644 cc/bitmap_skpicture_canvas_layer_texture_updater.cc delete mode 100644 cc/bitmap_skpicture_canvas_layer_texture_updater.h create mode 100644 cc/bitmap_skpicture_canvas_layer_updater.cc create mode 100644 cc/bitmap_skpicture_canvas_layer_updater.h delete mode 100644 cc/caching_bitmap_canvas_layer_texture_updater.cc delete mode 100644 cc/caching_bitmap_canvas_layer_texture_updater.h create mode 100644 cc/caching_bitmap_canvas_layer_updater.cc create mode 100644 cc/caching_bitmap_canvas_layer_updater.h delete mode 100644 cc/canvas_layer_texture_updater.cc delete mode 100644 cc/canvas_layer_texture_updater.h create mode 100644 cc/canvas_layer_updater.cc create mode 100644 cc/canvas_layer_updater.h delete mode 100644 cc/layer_texture_updater.cc delete mode 100644 cc/layer_texture_updater.h create mode 100644 cc/layer_updater.cc create mode 100644 cc/layer_updater.h delete mode 100644 cc/skpicture_canvas_layer_texture_updater.cc delete mode 100644 cc/skpicture_canvas_layer_texture_updater.h create mode 100644 cc/skpicture_canvas_layer_updater.cc create mode 100644 cc/skpicture_canvas_layer_updater.h diff --git a/cc/bitmap_canvas_layer_texture_updater.cc b/cc/bitmap_canvas_layer_texture_updater.cc deleted file mode 100644 index e874e76..0000000 --- a/cc/bitmap_canvas_layer_texture_updater.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/bitmap_canvas_layer_texture_updater.h" - -#include "cc/layer_painter.h" -#include "cc/resource_update.h" -#include "cc/texture_update_queue.h" -#include "skia/ext/platform_canvas.h" - -namespace cc { - -BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, scoped_ptr texture) - : LayerTextureUpdater::Texture(texture.Pass()) - , m_textureUpdater(textureUpdater) -{ -} - -BitmapCanvasLayerTextureUpdater::Texture::~Texture() -{ -} - -void BitmapCanvasLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) -{ - textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); -} - -scoped_refptr BitmapCanvasLayerTextureUpdater::create(scoped_ptr painter) -{ - return make_scoped_refptr(new BitmapCanvasLayerTextureUpdater(painter.Pass())); -} - -BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(scoped_ptr painter) - : CanvasLayerTextureUpdater(painter.Pass()) - , m_opaque(false) -{ -} - -BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater() -{ -} - -scoped_ptr BitmapCanvasLayerTextureUpdater::createTexture(PrioritizedTextureManager* manager) -{ - return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); -} - -void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) -{ - if (m_canvasSize != contentRect.size()) { - m_canvasSize = contentRect.size(); - m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque)); - } - - paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); -} - -void BitmapCanvasLayerTextureUpdater::updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) -{ - ResourceUpdate upload = ResourceUpdate::Create( - texture, - &m_canvas->getDevice()->accessBitmap(false), - contentRect(), - sourceRect, - destOffset); - if (partialUpdate) - queue.appendPartialUpload(upload); - else - queue.appendFullUpload(upload); -} - -void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque) -{ - if (opaque != m_opaque) { - m_canvas.reset(); - m_canvasSize = IntSize(); - } - m_opaque = opaque; -} - -} // namespace cc diff --git a/cc/bitmap_canvas_layer_texture_updater.h b/cc/bitmap_canvas_layer_texture_updater.h deleted file mode 100644 index 1225e0e..0000000 --- a/cc/bitmap_canvas_layer_texture_updater.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -#ifndef BitmapCanvasLayerTextureUpdater_h -#define BitmapCanvasLayerTextureUpdater_h - -#include "cc/canvas_layer_texture_updater.h" - -class SkCanvas; - -namespace cc { - -class LayerPainter; - -// This class rasterizes the contentRect into a skia bitmap canvas. It then updates -// textures by copying from the canvas into the texture, using MapSubImage if -// possible. -class BitmapCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { -public: - class Texture : public LayerTextureUpdater::Texture { - public: - Texture(BitmapCanvasLayerTextureUpdater*, scoped_ptr); - virtual ~Texture(); - - virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; - - private: - BitmapCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } - - BitmapCanvasLayerTextureUpdater* m_textureUpdater; - }; - - static scoped_refptr create(scoped_ptr); - - virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; - virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) OVERRIDE; - void updateTexture(TextureUpdateQueue&, PrioritizedTexture*, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate); - - virtual void setOpaque(bool) OVERRIDE; - -protected: - explicit BitmapCanvasLayerTextureUpdater(scoped_ptr); - virtual ~BitmapCanvasLayerTextureUpdater(); - - scoped_ptr m_canvas; - IntSize m_canvasSize; - bool m_opaque; -}; - -} // namespace cc - -#endif // BitmapCanvasLayerTextureUpdater_h diff --git a/cc/bitmap_canvas_layer_updater.cc b/cc/bitmap_canvas_layer_updater.cc new file mode 100644 index 0000000..eca5e761 --- /dev/null +++ b/cc/bitmap_canvas_layer_updater.cc @@ -0,0 +1,84 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/bitmap_canvas_layer_updater.h" + +#include "cc/layer_painter.h" +#include "cc/resource_update.h" +#include "cc/texture_update_queue.h" +#include "skia/ext/platform_canvas.h" + +namespace cc { + +BitmapCanvasLayerUpdater::Texture::Texture(BitmapCanvasLayerUpdater* updater, scoped_ptr texture) + : LayerUpdater::Texture(texture.Pass()) + , m_updater(updater) +{ +} + +BitmapCanvasLayerUpdater::Texture::~Texture() +{ +} + +void BitmapCanvasLayerUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) +{ + updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); +} + +scoped_refptr BitmapCanvasLayerUpdater::create(scoped_ptr painter) +{ + return make_scoped_refptr(new BitmapCanvasLayerUpdater(painter.Pass())); +} + +BitmapCanvasLayerUpdater::BitmapCanvasLayerUpdater(scoped_ptr painter) + : CanvasLayerUpdater(painter.Pass()) + , m_opaque(false) +{ +} + +BitmapCanvasLayerUpdater::~BitmapCanvasLayerUpdater() +{ +} + +scoped_ptr BitmapCanvasLayerUpdater::createTexture(PrioritizedTextureManager* manager) +{ + return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); +} + +void BitmapCanvasLayerUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) +{ + if (m_canvasSize != contentRect.size()) { + m_canvasSize = contentRect.size(); + m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque)); + } + + paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); +} + +void BitmapCanvasLayerUpdater::updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) +{ + ResourceUpdate upload = ResourceUpdate::Create( + texture, + &m_canvas->getDevice()->accessBitmap(false), + contentRect(), + sourceRect, + destOffset); + if (partialUpdate) + queue.appendPartialUpload(upload); + else + queue.appendFullUpload(upload); +} + +void BitmapCanvasLayerUpdater::setOpaque(bool opaque) +{ + if (opaque != m_opaque) { + m_canvas.reset(); + m_canvasSize = IntSize(); + } + m_opaque = opaque; +} + +} // namespace cc diff --git a/cc/bitmap_canvas_layer_updater.h b/cc/bitmap_canvas_layer_updater.h new file mode 100644 index 0000000..bd36be2 --- /dev/null +++ b/cc/bitmap_canvas_layer_updater.h @@ -0,0 +1,54 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +#ifndef BitmapCanvasLayerUpdater_h +#define BitmapCanvasLayerUpdater_h + +#include "cc/canvas_layer_updater.h" + +class SkCanvas; + +namespace cc { + +class LayerPainter; + +// This class rasterizes the contentRect into a skia bitmap canvas. It then updates +// textures by copying from the canvas into the texture, using MapSubImage if +// possible. +class BitmapCanvasLayerUpdater : public CanvasLayerUpdater { +public: + class Texture : public LayerUpdater::Texture { + public: + Texture(BitmapCanvasLayerUpdater*, scoped_ptr); + virtual ~Texture(); + + virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + + private: + BitmapCanvasLayerUpdater* updater() { return m_updater; } + + BitmapCanvasLayerUpdater* m_updater; + }; + + static scoped_refptr create(scoped_ptr); + + virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; + virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) OVERRIDE; + void updateTexture(TextureUpdateQueue&, PrioritizedTexture*, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate); + + virtual void setOpaque(bool) OVERRIDE; + +protected: + explicit BitmapCanvasLayerUpdater(scoped_ptr); + virtual ~BitmapCanvasLayerUpdater(); + + scoped_ptr m_canvas; + IntSize m_canvasSize; + bool m_opaque; +}; + +} // namespace cc + +#endif // BitmapCanvasLayerUpdater_h diff --git a/cc/bitmap_skpicture_canvas_layer_texture_updater.cc b/cc/bitmap_skpicture_canvas_layer_texture_updater.cc deleted file mode 100644 index fc342b9..0000000 --- a/cc/bitmap_skpicture_canvas_layer_texture_updater.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/bitmap_skpicture_canvas_layer_texture_updater.h" - -#include "base/time.h" -#include "cc/layer_painter.h" -#include "cc/rendering_stats.h" -#include "cc/texture_update_queue.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkDevice.h" - -namespace cc { - -BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvasLayerTextureUpdater* textureUpdater, scoped_ptr texture) - : CanvasLayerTextureUpdater::Texture(texture.Pass()) - , m_textureUpdater(textureUpdater) -{ -} - -void BitmapSkPictureCanvasLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats& stats) -{ - m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRect.height()); - m_bitmap.allocPixels(); - m_bitmap.setIsOpaque(m_textureUpdater->layerIsOpaque()); - SkDevice device(m_bitmap); - SkCanvas canvas(&device); - base::TimeTicks paintBeginTime = base::TimeTicks::Now(); - textureUpdater()->paintContentsRect(&canvas, sourceRect, stats); - stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF(); - - ResourceUpdate upload = ResourceUpdate::Create( - texture(), &m_bitmap, sourceRect, sourceRect, destOffset); - if (partialUpdate) - queue.appendPartialUpload(upload); - else - queue.appendFullUpload(upload); -} - -scoped_refptr BitmapSkPictureCanvasLayerTextureUpdater::create(scoped_ptr painter) -{ - return make_scoped_refptr(new BitmapSkPictureCanvasLayerTextureUpdater(painter.Pass())); -} - -BitmapSkPictureCanvasLayerTextureUpdater::BitmapSkPictureCanvasLayerTextureUpdater(scoped_ptr painter) - : SkPictureCanvasLayerTextureUpdater(painter.Pass()) -{ -} - -BitmapSkPictureCanvasLayerTextureUpdater::~BitmapSkPictureCanvasLayerTextureUpdater() -{ -} - -scoped_ptr BitmapSkPictureCanvasLayerTextureUpdater::createTexture(PrioritizedTextureManager* manager) -{ - return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); -} - -void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect, RenderingStats& stats) -{ - // Translate the origin of contentRect to that of sourceRect. - canvas->translate(contentRect().x() - sourceRect.x(), - contentRect().y() - sourceRect.y()); - base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); - drawPicture(canvas); - stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBeginTime).InSecondsF(); -} - -} // namespace cc diff --git a/cc/bitmap_skpicture_canvas_layer_texture_updater.h b/cc/bitmap_skpicture_canvas_layer_texture_updater.h deleted file mode 100644 index 5935ae4..0000000 --- a/cc/bitmap_skpicture_canvas_layer_texture_updater.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BitmapSkPictureCanvasLayerTextureUpdater_h -#define BitmapSkPictureCanvasLayerTextureUpdater_h - -#include "cc/skpicture_canvas_layer_texture_updater.h" -#include "third_party/skia/include/core/SkBitmap.h" - -namespace cc { - -// This class records the contentRect into an SkPicture, then software rasterizes -// the SkPicture into bitmaps for each tile. This implements Settings::perTilePainting. -class BitmapSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater { -public: - class Texture : public CanvasLayerTextureUpdater::Texture { - public: - Texture(BitmapSkPictureCanvasLayerTextureUpdater*, scoped_ptr); - - virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; - - private: - BitmapSkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } - - SkBitmap m_bitmap; - BitmapSkPictureCanvasLayerTextureUpdater* m_textureUpdater; - }; - - static scoped_refptr create(scoped_ptr); - - virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; - void paintContentsRect(SkCanvas*, const IntRect& sourceRect, RenderingStats&); - -private: - explicit BitmapSkPictureCanvasLayerTextureUpdater(scoped_ptr); - virtual ~BitmapSkPictureCanvasLayerTextureUpdater(); -}; - -} // namespace cc - -#endif // BitmapSkPictureCanvasLayerTextureUpdater_h diff --git a/cc/bitmap_skpicture_canvas_layer_updater.cc b/cc/bitmap_skpicture_canvas_layer_updater.cc new file mode 100644 index 0000000..a8ae1ca --- /dev/null +++ b/cc/bitmap_skpicture_canvas_layer_updater.cc @@ -0,0 +1,72 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/bitmap_skpicture_canvas_layer_updater.h" + +#include "base/time.h" +#include "cc/layer_painter.h" +#include "cc/rendering_stats.h" +#include "cc/texture_update_queue.h" +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkDevice.h" + +namespace cc { + +BitmapSkPictureCanvasLayerUpdater::Texture::Texture(BitmapSkPictureCanvasLayerUpdater* updater, scoped_ptr texture) + : CanvasLayerUpdater::Texture(texture.Pass()) + , m_updater(updater) +{ +} + +void BitmapSkPictureCanvasLayerUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats& stats) +{ + m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRect.height()); + m_bitmap.allocPixels(); + m_bitmap.setIsOpaque(m_updater->layerIsOpaque()); + SkDevice device(m_bitmap); + SkCanvas canvas(&device); + base::TimeTicks paintBeginTime = base::TimeTicks::Now(); + updater()->paintContentsRect(&canvas, sourceRect, stats); + stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF(); + + ResourceUpdate upload = ResourceUpdate::Create( + texture(), &m_bitmap, sourceRect, sourceRect, destOffset); + if (partialUpdate) + queue.appendPartialUpload(upload); + else + queue.appendFullUpload(upload); +} + +scoped_refptr BitmapSkPictureCanvasLayerUpdater::create(scoped_ptr painter) +{ + return make_scoped_refptr(new BitmapSkPictureCanvasLayerUpdater(painter.Pass())); +} + +BitmapSkPictureCanvasLayerUpdater::BitmapSkPictureCanvasLayerUpdater(scoped_ptr painter) + : SkPictureCanvasLayerUpdater(painter.Pass()) +{ +} + +BitmapSkPictureCanvasLayerUpdater::~BitmapSkPictureCanvasLayerUpdater() +{ +} + +scoped_ptr BitmapSkPictureCanvasLayerUpdater::createTexture(PrioritizedTextureManager* manager) +{ + return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); +} + +void BitmapSkPictureCanvasLayerUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect, RenderingStats& stats) +{ + // Translate the origin of contentRect to that of sourceRect. + canvas->translate(contentRect().x() - sourceRect.x(), + contentRect().y() - sourceRect.y()); + base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); + drawPicture(canvas); + stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBeginTime).InSecondsF(); +} + +} // namespace cc diff --git a/cc/bitmap_skpicture_canvas_layer_updater.h b/cc/bitmap_skpicture_canvas_layer_updater.h new file mode 100644 index 0000000..b9e30a5 --- /dev/null +++ b/cc/bitmap_skpicture_canvas_layer_updater.h @@ -0,0 +1,42 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BitmapSkPictureCanvasLayerUpdater_h +#define BitmapSkPictureCanvasLayerUpdater_h + +#include "cc/skpicture_canvas_layer_updater.h" +#include "third_party/skia/include/core/SkBitmap.h" + +namespace cc { + +// This class records the contentRect into an SkPicture, then software rasterizes +// the SkPicture into bitmaps for each tile. This implements Settings::perTilePainting. +class BitmapSkPictureCanvasLayerUpdater : public SkPictureCanvasLayerUpdater { +public: + class Texture : public CanvasLayerUpdater::Texture { + public: + Texture(BitmapSkPictureCanvasLayerUpdater*, scoped_ptr); + + virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + + private: + BitmapSkPictureCanvasLayerUpdater* updater() { return m_updater; } + + SkBitmap m_bitmap; + BitmapSkPictureCanvasLayerUpdater* m_updater; + }; + + static scoped_refptr create(scoped_ptr); + + virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; + void paintContentsRect(SkCanvas*, const IntRect& sourceRect, RenderingStats&); + +private: + explicit BitmapSkPictureCanvasLayerUpdater(scoped_ptr); + virtual ~BitmapSkPictureCanvasLayerUpdater(); +}; + +} // namespace cc + +#endif // BitmapSkPictureCanvasLayerUpdater_h diff --git a/cc/caching_bitmap_canvas_layer_texture_updater.cc b/cc/caching_bitmap_canvas_layer_texture_updater.cc deleted file mode 100644 index b6d6259..0000000 --- a/cc/caching_bitmap_canvas_layer_texture_updater.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "caching_bitmap_canvas_layer_texture_updater.h" - -#include "cc/layer_painter.h" -#include "skia/ext/platform_canvas.h" - -namespace cc { - -scoped_refptr -CachingBitmapCanvasLayerTextureUpdater::Create( - scoped_ptr painter) { - return make_scoped_refptr(new CachingBitmapCanvasLayerTextureUpdater( - painter.Pass())); -} - -CachingBitmapCanvasLayerTextureUpdater::CachingBitmapCanvasLayerTextureUpdater( - scoped_ptr painter) - : BitmapCanvasLayerTextureUpdater(painter.Pass()), - pixels_did_change_(false) { -} - -CachingBitmapCanvasLayerTextureUpdater:: - ~CachingBitmapCanvasLayerTextureUpdater() -{ -} - -void CachingBitmapCanvasLayerTextureUpdater::prepareToUpdate( - const IntRect& content_rect, - const IntSize& tile_size, - float contents_width_scale, - float contents_height_scale, - IntRect& resulting_opaque_rect, - RenderingStats& stats) { - BitmapCanvasLayerTextureUpdater::prepareToUpdate(content_rect, - tile_size, - contents_width_scale, - contents_height_scale, - resulting_opaque_rect, - stats); - - const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); - SkAutoLockPixels lock(new_bitmap); - DCHECK(new_bitmap.bytesPerPixel() > 0); - pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() || - new_bitmap.height() != cached_bitmap_.height() || - new_bitmap.width() != cached_bitmap_.width() || - memcmp(new_bitmap.getPixels(), - cached_bitmap_.getPixels(), - new_bitmap.getSafeSize()); - - if (pixels_did_change_) - new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); -} - -bool CachingBitmapCanvasLayerTextureUpdater::pixelsDidChange() const -{ - return pixels_did_change_; -} - -} // namespace cc diff --git a/cc/caching_bitmap_canvas_layer_texture_updater.h b/cc/caching_bitmap_canvas_layer_texture_updater.h deleted file mode 100644 index 48be15ca..0000000 --- a/cc/caching_bitmap_canvas_layer_texture_updater.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CACHING_BITMAP_CANVAS_LAYER_TEXTURE_UPDATER_H_ -#define CACHING_BITMAP_CANVAS_LAYER_TEXTURE_UPDATER_H_ - -#include "base/compiler_specific.h" -#include "cc/bitmap_canvas_layer_texture_updater.h" - -namespace cc { - -class CachingBitmapCanvasLayerTextureUpdater - : public BitmapCanvasLayerTextureUpdater { - public: - static scoped_refptr Create( - scoped_ptr); - - virtual void prepareToUpdate(const IntRect& content_rect, - const IntSize& tile_size, - float contents_width_scale, - float contents_height_scale, - IntRect& resulting_opaque_rect, - RenderingStats&) OVERRIDE; - - bool pixelsDidChange() const; - - private: - explicit CachingBitmapCanvasLayerTextureUpdater( - scoped_ptr painter); - virtual ~CachingBitmapCanvasLayerTextureUpdater(); - - bool pixels_did_change_; - SkBitmap cached_bitmap_; -}; - -} // namespace cc - -#endif // CACHING_BITMAP_CANVAS_LAYER_TEXTURE_UPDATER_H_ diff --git a/cc/caching_bitmap_canvas_layer_updater.cc b/cc/caching_bitmap_canvas_layer_updater.cc new file mode 100644 index 0000000..c16af60 --- /dev/null +++ b/cc/caching_bitmap_canvas_layer_updater.cc @@ -0,0 +1,65 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "caching_bitmap_canvas_layer_updater.h" + +#include "cc/layer_painter.h" +#include "skia/ext/platform_canvas.h" + +namespace cc { + +scoped_refptr +CachingBitmapCanvasLayerUpdater::Create( + scoped_ptr painter) { + return make_scoped_refptr(new CachingBitmapCanvasLayerUpdater( + painter.Pass())); +} + +CachingBitmapCanvasLayerUpdater::CachingBitmapCanvasLayerUpdater( + scoped_ptr painter) + : BitmapCanvasLayerUpdater(painter.Pass()), + pixels_did_change_(false) { +} + +CachingBitmapCanvasLayerUpdater:: + ~CachingBitmapCanvasLayerUpdater() +{ +} + +void CachingBitmapCanvasLayerUpdater::prepareToUpdate( + const IntRect& content_rect, + const IntSize& tile_size, + float contents_width_scale, + float contents_height_scale, + IntRect& resulting_opaque_rect, + RenderingStats& stats) { + BitmapCanvasLayerUpdater::prepareToUpdate(content_rect, + tile_size, + contents_width_scale, + contents_height_scale, + resulting_opaque_rect, + stats); + + const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); + SkAutoLockPixels lock(new_bitmap); + DCHECK(new_bitmap.bytesPerPixel() > 0); + pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() || + new_bitmap.height() != cached_bitmap_.height() || + new_bitmap.width() != cached_bitmap_.width() || + memcmp(new_bitmap.getPixels(), + cached_bitmap_.getPixels(), + new_bitmap.getSafeSize()); + + if (pixels_did_change_) + new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); +} + +bool CachingBitmapCanvasLayerUpdater::pixelsDidChange() const +{ + return pixels_did_change_; +} + +} // namespace cc diff --git a/cc/caching_bitmap_canvas_layer_updater.h b/cc/caching_bitmap_canvas_layer_updater.h new file mode 100644 index 0000000..bd48683 --- /dev/null +++ b/cc/caching_bitmap_canvas_layer_updater.h @@ -0,0 +1,39 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CACHING_BITMAP_CANVAS_LAYER_UPDATER_H_ +#define CACHING_BITMAP_CANVAS_LAYER_UPDATER_H_ + +#include "base/compiler_specific.h" +#include "cc/bitmap_canvas_layer_updater.h" + +namespace cc { + +class CachingBitmapCanvasLayerUpdater + : public BitmapCanvasLayerUpdater { + public: + static scoped_refptr Create( + scoped_ptr); + + virtual void prepareToUpdate(const IntRect& content_rect, + const IntSize& tile_size, + float contents_width_scale, + float contents_height_scale, + IntRect& resulting_opaque_rect, + RenderingStats&) OVERRIDE; + + bool pixelsDidChange() const; + + private: + explicit CachingBitmapCanvasLayerUpdater( + scoped_ptr painter); + virtual ~CachingBitmapCanvasLayerUpdater(); + + bool pixels_did_change_; + SkBitmap cached_bitmap_; +}; + +} // namespace cc + +#endif // CACHING_BITMAP_CANVAS_LAYER_UPDATER_H_ diff --git a/cc/canvas_layer_texture_updater.cc b/cc/canvas_layer_texture_updater.cc deleted file mode 100644 index 923b897..0000000 --- a/cc/canvas_layer_texture_updater.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/canvas_layer_texture_updater.h" - -#include "FloatRect.h" -#include "SkiaUtils.h" -#include "base/debug/trace_event.h" -#include "base/time.h" -#include "cc/layer_painter.h" -#include "cc/rendering_stats.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "third_party/skia/include/core/SkRect.h" - -namespace cc { - -CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(scoped_ptr painter) - : m_painter(painter.Pass()) -{ -} - -CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater() -{ -} - -void CanvasLayerTextureUpdater::paintContents(SkCanvas* canvas, const IntRect& contentRect, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) -{ - TRACE_EVENT0("cc", "CanvasLayerTextureUpdater::paintContents"); - canvas->save(); - canvas->translate(FloatToSkScalar(-contentRect.x()), FloatToSkScalar(-contentRect.y())); - - IntRect layerRect = contentRect; - - if (contentsWidthScale != 1 || contentsHeightScale != 1) { - canvas->scale(FloatToSkScalar(contentsWidthScale), FloatToSkScalar(contentsHeightScale)); - - FloatRect rect = contentRect; - rect.scale(1 / contentsWidthScale, 1 / contentsHeightScale); - layerRect = enclosingIntRect(rect); - } - - SkPaint paint; - paint.setAntiAlias(false); - paint.setXfermodeMode(SkXfermode::kClear_Mode); - SkRect layerSkRect = SkRect::MakeXYWH(layerRect.x(), layerRect.y(), layerRect.width(), layerRect.height()); - canvas->drawRect(layerSkRect, paint); - canvas->clipRect(layerSkRect); - - FloatRect opaqueLayerRect; - base::TimeTicks paintBeginTime = base::TimeTicks::Now(); - m_painter->paint(canvas, layerRect, opaqueLayerRect); - stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF(); - canvas->restore(); - - FloatRect opaqueContentRect = opaqueLayerRect; - opaqueContentRect.scale(contentsWidthScale, contentsHeightScale); - resultingOpaqueRect = enclosedIntRect(opaqueContentRect); - - m_contentRect = contentRect; -} - -} // namespace cc diff --git a/cc/canvas_layer_texture_updater.h b/cc/canvas_layer_texture_updater.h deleted file mode 100644 index 09da606..0000000 --- a/cc/canvas_layer_texture_updater.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CanvasLayerTextureUpdater_h -#define CanvasLayerTextureUpdater_h - -#include "cc/layer_texture_updater.h" - -class SkCanvas; - -namespace cc { - -class LayerPainter; - -// Base class for BitmapCanvasLayerTextureUpdater and -// SkPictureCanvasLayerTextureUpdater that reduces code duplication between -// their respective paintContents implementations. -class CanvasLayerTextureUpdater : public LayerTextureUpdater { -protected: - explicit CanvasLayerTextureUpdater(scoped_ptr); - virtual ~CanvasLayerTextureUpdater(); - - void paintContents(SkCanvas*, const IntRect& contentRect, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&); - const IntRect& contentRect() const { return m_contentRect; } - -private: - IntRect m_contentRect; - scoped_ptr m_painter; -}; - -} // namespace cc - -#endif // CanvasLayerTextureUpdater_h diff --git a/cc/canvas_layer_updater.cc b/cc/canvas_layer_updater.cc new file mode 100644 index 0000000..96f6b7f --- /dev/null +++ b/cc/canvas_layer_updater.cc @@ -0,0 +1,66 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/canvas_layer_updater.h" + +#include "FloatRect.h" +#include "SkiaUtils.h" +#include "base/debug/trace_event.h" +#include "base/time.h" +#include "cc/layer_painter.h" +#include "cc/rendering_stats.h" +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkRect.h" + +namespace cc { + +CanvasLayerUpdater::CanvasLayerUpdater(scoped_ptr painter) + : m_painter(painter.Pass()) +{ +} + +CanvasLayerUpdater::~CanvasLayerUpdater() +{ +} + +void CanvasLayerUpdater::paintContents(SkCanvas* canvas, const IntRect& contentRect, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) +{ + TRACE_EVENT0("cc", "CanvasLayerUpdater::paintContents"); + canvas->save(); + canvas->translate(FloatToSkScalar(-contentRect.x()), FloatToSkScalar(-contentRect.y())); + + IntRect layerRect = contentRect; + + if (contentsWidthScale != 1 || contentsHeightScale != 1) { + canvas->scale(FloatToSkScalar(contentsWidthScale), FloatToSkScalar(contentsHeightScale)); + + FloatRect rect = contentRect; + rect.scale(1 / contentsWidthScale, 1 / contentsHeightScale); + layerRect = enclosingIntRect(rect); + } + + SkPaint paint; + paint.setAntiAlias(false); + paint.setXfermodeMode(SkXfermode::kClear_Mode); + SkRect layerSkRect = SkRect::MakeXYWH(layerRect.x(), layerRect.y(), layerRect.width(), layerRect.height()); + canvas->drawRect(layerSkRect, paint); + canvas->clipRect(layerSkRect); + + FloatRect opaqueLayerRect; + base::TimeTicks paintBeginTime = base::TimeTicks::Now(); + m_painter->paint(canvas, layerRect, opaqueLayerRect); + stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF(); + canvas->restore(); + + FloatRect opaqueContentRect = opaqueLayerRect; + opaqueContentRect.scale(contentsWidthScale, contentsHeightScale); + resultingOpaqueRect = enclosedIntRect(opaqueContentRect); + + m_contentRect = contentRect; +} + +} // namespace cc diff --git a/cc/canvas_layer_updater.h b/cc/canvas_layer_updater.h new file mode 100644 index 0000000..7af78ef --- /dev/null +++ b/cc/canvas_layer_updater.h @@ -0,0 +1,34 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CanvasLayerUpdater_h +#define CanvasLayerUpdater_h + +#include "cc/layer_updater.h" + +class SkCanvas; + +namespace cc { + +class LayerPainter; + +// Base class for BitmapCanvasLayerUpdater and +// SkPictureCanvasLayerUpdater that reduces code duplication between +// their respective paintContents implementations. +class CanvasLayerUpdater : public LayerUpdater { +protected: + explicit CanvasLayerUpdater(scoped_ptr); + virtual ~CanvasLayerUpdater(); + + void paintContents(SkCanvas*, const IntRect& contentRect, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&); + const IntRect& contentRect() const { return m_contentRect; } + +private: + IntRect m_contentRect; + scoped_ptr m_painter; +}; + +} // namespace cc + +#endif // CanvasLayerUpdater_h diff --git a/cc/cc.gyp b/cc/cc.gyp index 2aa37de..1a13f3c 100644 --- a/cc/cc.gyp +++ b/cc/cc.gyp @@ -9,12 +9,12 @@ 'scoped_ptr_deque.h', 'scoped_ptr_hash_map.h', 'scoped_ptr_vector.h', - 'bitmap_canvas_layer_texture_updater.cc', - 'bitmap_canvas_layer_texture_updater.h', - 'bitmap_skpicture_canvas_layer_texture_updater.cc', - 'bitmap_skpicture_canvas_layer_texture_updater.h', - 'caching_bitmap_canvas_layer_texture_updater.cc', - 'caching_bitmap_canvas_layer_texture_updater.h', + 'bitmap_canvas_layer_updater.cc', + 'bitmap_canvas_layer_updater.h', + 'bitmap_skpicture_canvas_layer_updater.cc', + 'bitmap_skpicture_canvas_layer_updater.h', + 'caching_bitmap_canvas_layer_updater.cc', + 'caching_bitmap_canvas_layer_updater.h', 'active_animation.cc', 'CCActiveAnimation.h', 'CCAppendQuadsData.h', @@ -170,8 +170,8 @@ 'video_layer_impl.h', 'yuv_video_draw_quad.cc', 'yuv_video_draw_quad.h', - 'canvas_layer_texture_updater.cc', - 'canvas_layer_texture_updater.h', + 'canvas_layer_updater.cc', + 'canvas_layer_updater.h', 'content_layer.cc', 'content_layer.h', 'content_layer_client.h', @@ -188,8 +188,8 @@ 'layer.cc', 'layer.h', 'layer_painter.h', - 'layer_texture_updater.cc', - 'layer_texture_updater.h', + 'layer_updater.cc', + 'layer_updater.h', 'platform_color.h', 'program_binding.cc', 'program_binding.h', @@ -201,8 +201,8 @@ 'scrollbar_layer.h', 'shader.cc', 'shader.h', - 'skpicture_canvas_layer_texture_updater.cc', - 'skpicture_canvas_layer_texture_updater.h', + 'skpicture_canvas_layer_updater.cc', + 'skpicture_canvas_layer_updater.h', 'solid_color_layer.cc', 'solid_color_layer.h', 'switches.cc', diff --git a/cc/content_layer.cc b/cc/content_layer.cc index f60b3ec..a75ee93 100644 --- a/cc/content_layer.cc +++ b/cc/content_layer.cc @@ -8,8 +8,8 @@ #include "base/metrics/histogram.h" #include "base/time.h" -#include "cc/bitmap_canvas_layer_texture_updater.h" -#include "cc/bitmap_skpicture_canvas_layer_texture_updater.h" +#include "cc/bitmap_canvas_layer_updater.h" +#include "cc/bitmap_skpicture_canvas_layer_updater.h" #include "cc/content_layer_client.h" #include "cc/layer_painter.h" #include "cc/layer_tree_host.h" @@ -67,7 +67,7 @@ void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) void ContentLayer::update(TextureUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) { - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); TiledLayer::update(queue, occlusion, stats); m_needsDisplay = false; } @@ -77,23 +77,23 @@ bool ContentLayer::needMoreUpdates() return needsIdlePaint(); } -LayerTextureUpdater* ContentLayer::textureUpdater() const +LayerUpdater* ContentLayer::updater() const { - return m_textureUpdater.get(); + return m_updater.get(); } -void ContentLayer::createTextureUpdaterIfNeeded() +void ContentLayer::createUpdaterIfNeeded() { - if (m_textureUpdater) + if (m_updater) return; scoped_ptr painter = ContentLayerPainter::create(m_client).PassAs(); if (layerTreeHost()->settings().acceleratePainting) - m_textureUpdater = SkPictureCanvasLayerTextureUpdater::create(painter.Pass()); + m_updater = SkPictureCanvasLayerUpdater::create(painter.Pass()); else if (Settings::perTilePaintingEnabled()) - m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(painter.Pass()); + m_updater = BitmapSkPictureCanvasLayerUpdater::create(painter.Pass()); else - m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(painter.Pass()); - m_textureUpdater->setOpaque(contentsOpaque()); + m_updater = BitmapCanvasLayerUpdater::create(painter.Pass()); + m_updater->setOpaque(contentsOpaque()); GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; setTextureFormat(textureFormat); @@ -102,8 +102,8 @@ void ContentLayer::createTextureUpdaterIfNeeded() void ContentLayer::setContentsOpaque(bool opaque) { Layer::setContentsOpaque(opaque); - if (m_textureUpdater) - m_textureUpdater->setOpaque(opaque); + if (m_updater) + m_updater->setOpaque(opaque); } } diff --git a/cc/content_layer.h b/cc/content_layer.h index 12cafa4..ff7dbc0 100644 --- a/cc/content_layer.h +++ b/cc/content_layer.h @@ -16,7 +16,7 @@ namespace cc { class ContentLayerClient; class FloatRect; class IntRect; -class LayerTextureUpdater; +class LayerUpdater; class ContentLayerPainter : public LayerPainter { public: @@ -51,11 +51,11 @@ protected: virtual ~ContentLayer(); private: - virtual LayerTextureUpdater* textureUpdater() const OVERRIDE; - virtual void createTextureUpdaterIfNeeded() OVERRIDE; + virtual LayerUpdater* updater() const OVERRIDE; + virtual void createUpdaterIfNeeded() OVERRIDE; ContentLayerClient* m_client; - scoped_refptr m_textureUpdater; + scoped_refptr m_updater; }; } diff --git a/cc/content_layer_unittest.cc b/cc/content_layer_unittest.cc index ed7823a..6582690 100644 --- a/cc/content_layer_unittest.cc +++ b/cc/content_layer_unittest.cc @@ -6,7 +6,7 @@ #include "cc/content_layer.h" -#include "cc/bitmap_canvas_layer_texture_updater.h" +#include "cc/bitmap_canvas_layer_updater.h" #include "cc/content_layer_client.h" #include "cc/rendering_stats.h" #include "cc/test/geometry_test_utils.h" @@ -44,7 +44,7 @@ TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace; opaqueRectInContentSpace.scale(contentsScale); MockContentLayerClient client(opaqueRectInLayerSpace); - scoped_refptr updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&client).PassAs()); + scoped_refptr updater = BitmapCanvasLayerUpdater::create(ContentLayerPainter::create(&client).PassAs()); IntRect resultingOpaqueRect; RenderingStats stats; diff --git a/cc/image_layer.cc b/cc/image_layer.cc index 1c6b133..1e37920 100644 --- a/cc/image_layer.cc +++ b/cc/image_layer.cc @@ -7,42 +7,42 @@ #include "cc/image_layer.h" #include "base/compiler_specific.h" -#include "cc/layer_texture_updater.h" +#include "cc/layer_updater.h" #include "cc/layer_tree_host.h" #include "cc/texture_update_queue.h" namespace cc { -class ImageLayerTextureUpdater : public LayerTextureUpdater { +class ImageLayerUpdater : public LayerUpdater { public: - class Texture : public LayerTextureUpdater::Texture { + class Texture : public LayerUpdater::Texture { public: - Texture(ImageLayerTextureUpdater* textureUpdater, scoped_ptr texture) - : LayerTextureUpdater::Texture(texture.Pass()) - , m_textureUpdater(textureUpdater) + Texture(ImageLayerUpdater* updater, scoped_ptr texture) + : LayerUpdater::Texture(texture.Pass()) + , m_updater(updater) { } virtual void update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE { - textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); + updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); } private: - ImageLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } + ImageLayerUpdater* updater() { return m_updater; } - ImageLayerTextureUpdater* m_textureUpdater; + ImageLayerUpdater* m_updater; }; - static scoped_refptr create() + static scoped_refptr create() { - return make_scoped_refptr(new ImageLayerTextureUpdater()); + return make_scoped_refptr(new ImageLayerUpdater()); } - virtual scoped_ptr createTexture( + virtual scoped_ptr createTexture( PrioritizedTextureManager* manager) OVERRIDE { - return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); + return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); } void updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) @@ -72,8 +72,8 @@ public: } private: - ImageLayerTextureUpdater() { } - virtual ~ImageLayerTextureUpdater() { } + ImageLayerUpdater() { } + virtual ~ImageLayerUpdater() { } SkBitmap m_bitmap; }; @@ -115,9 +115,9 @@ void ImageLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) void ImageLayer::update(TextureUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) { - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); if (m_needsDisplay) { - m_textureUpdater->setBitmap(m_bitmap); + m_updater->setBitmap(m_bitmap); updateTileSizeAndTilingOption(); invalidateContentRect(IntRect(IntPoint(), contentBounds())); m_needsDisplay = false; @@ -125,19 +125,19 @@ void ImageLayer::update(TextureUpdateQueue& queue, const OcclusionTracker* occlu TiledLayer::update(queue, occlusion, stats); } -void ImageLayer::createTextureUpdaterIfNeeded() +void ImageLayer::createUpdaterIfNeeded() { - if (m_textureUpdater) + if (m_updater) return; - m_textureUpdater = ImageLayerTextureUpdater::create(); + m_updater = ImageLayerUpdater::create(); GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; setTextureFormat(textureFormat); } -LayerTextureUpdater* ImageLayer::textureUpdater() const +LayerUpdater* ImageLayer::updater() const { - return m_textureUpdater.get(); + return m_updater.get(); } IntSize ImageLayer::contentBounds() const diff --git a/cc/image_layer.h b/cc/image_layer.h index 833a278..b96df58 100644 --- a/cc/image_layer.h +++ b/cc/image_layer.h @@ -10,7 +10,7 @@ namespace cc { -class ImageLayerTextureUpdater; +class ImageLayerUpdater; // A Layer that contains only an Image element. class ImageLayer : public TiledLayer { @@ -30,13 +30,13 @@ private: void setTilingOption(TilingOption); - virtual LayerTextureUpdater* textureUpdater() const OVERRIDE; - virtual void createTextureUpdaterIfNeeded() OVERRIDE; + virtual LayerUpdater* updater() const OVERRIDE; + virtual void createUpdaterIfNeeded() OVERRIDE; virtual IntSize contentBounds() const OVERRIDE; SkBitmap m_bitmap; - scoped_refptr m_textureUpdater; + scoped_refptr m_updater; }; } // namespace cc diff --git a/cc/layer_texture_updater.cc b/cc/layer_texture_updater.cc deleted file mode 100644 index 38a1307..0000000 --- a/cc/layer_texture_updater.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/layer_texture_updater.h" - -namespace cc { - -LayerTextureUpdater::Texture::Texture(scoped_ptr texture) - : m_texture(texture.Pass()) -{ -} - -LayerTextureUpdater::Texture::~Texture() -{ -} - -} diff --git a/cc/layer_texture_updater.h b/cc/layer_texture_updater.h deleted file mode 100644 index 89ef759..0000000 --- a/cc/layer_texture_updater.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LayerTextureUpdater_h -#define LayerTextureUpdater_h - -#include "base/memory/ref_counted.h" -#include "cc/prioritized_texture.h" -#include "third_party/khronos/GLES2/gl2.h" - -namespace cc { - -class IntRect; -class IntSize; -class TextureManager; -struct RenderingStats; -class TextureUpdateQueue; - -class LayerTextureUpdater : public base::RefCounted { -public: - // Allows texture uploaders to store per-tile resources. - class Texture { - public: - virtual ~Texture(); - - PrioritizedTexture* texture() { return m_texture.get(); } - void swapTextureWith(scoped_ptr& texture) { m_texture.swap(texture); } - // TODO(reveman): partialUpdate should be a property of this class - // instead of an argument passed to update(). - virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) = 0; - protected: - explicit Texture(scoped_ptr texture); - - private: - scoped_ptr m_texture; - }; - - LayerTextureUpdater() { } - - virtual scoped_ptr createTexture(PrioritizedTextureManager*) = 0; - // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater, - // then this region should be ignored in preference for the entire layer's area. - virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) { } - - // Set true by the layer when it is known that the entire output is going to be opaque. - virtual void setOpaque(bool) { } - -protected: - virtual ~LayerTextureUpdater() { } - -private: - friend class base::RefCounted; -}; - -} // namespace cc - -#endif // LayerTextureUpdater_h diff --git a/cc/layer_updater.cc b/cc/layer_updater.cc new file mode 100644 index 0000000..e0a4384 --- /dev/null +++ b/cc/layer_updater.cc @@ -0,0 +1,20 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/layer_updater.h" + +namespace cc { + +LayerUpdater::Texture::Texture(scoped_ptr texture) + : m_texture(texture.Pass()) +{ +} + +LayerUpdater::Texture::~Texture() +{ +} + +} diff --git a/cc/layer_updater.h b/cc/layer_updater.h new file mode 100644 index 0000000..10bced3 --- /dev/null +++ b/cc/layer_updater.h @@ -0,0 +1,58 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LayerUpdater_h +#define LayerUpdater_h + +#include "base/memory/ref_counted.h" +#include "cc/prioritized_texture.h" +#include "third_party/khronos/GLES2/gl2.h" + +namespace cc { + +class IntRect; +class IntSize; +class TextureManager; +struct RenderingStats; +class TextureUpdateQueue; + +class LayerUpdater : public base::RefCounted { +public: + // Allows texture uploaders to store per-tile resources. + class Texture { + public: + virtual ~Texture(); + + PrioritizedTexture* texture() { return m_texture.get(); } + void swapTextureWith(scoped_ptr& texture) { m_texture.swap(texture); } + // TODO(reveman): partialUpdate should be a property of this class + // instead of an argument passed to update(). + virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) = 0; + protected: + explicit Texture(scoped_ptr texture); + + private: + scoped_ptr m_texture; + }; + + LayerUpdater() { } + + virtual scoped_ptr createTexture(PrioritizedTextureManager*) = 0; + // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater, + // then this region should be ignored in preference for the entire layer's area. + virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) { } + + // Set true by the layer when it is known that the entire output is going to be opaque. + virtual void setOpaque(bool) { } + +protected: + virtual ~LayerUpdater() { } + +private: + friend class base::RefCounted; +}; + +} // namespace cc + +#endif // LayerUpdater_h diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc index a9625e8..829ace9 100644 --- a/cc/scrollbar_layer.cc +++ b/cc/scrollbar_layer.cc @@ -186,30 +186,30 @@ void ScrollbarLayer::setLayerTreeHost(LayerTreeHost* host) Layer::setLayerTreeHost(host); } -void ScrollbarLayer::createTextureUpdaterIfNeeded() +void ScrollbarLayer::createUpdaterIfNeeded() { m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; if (!m_backTrackUpdater) - m_backTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebKit::WebScrollbar::BackTrackPart).PassAs()); + m_backTrackUpdater = CachingBitmapCanvasLayerUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebKit::WebScrollbar::BackTrackPart).PassAs()); if (!m_backTrack) m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->contentsTextureManager()); // Only create two-part track if we think the two parts could be different in appearance. if (m_scrollbar->isCustomScrollbar()) { if (!m_foreTrackUpdater) - m_foreTrackUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebKit::WebScrollbar::ForwardTrackPart).PassAs()); + m_foreTrackUpdater = CachingBitmapCanvasLayerUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter, m_geometry.get(), WebKit::WebScrollbar::ForwardTrackPart).PassAs()); if (!m_foreTrack) m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->contentsTextureManager()); } if (!m_thumbUpdater) - m_thumbUpdater = CachingBitmapCanvasLayerTextureUpdater::Create(ScrollbarThumbPainter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs()); + m_thumbUpdater = CachingBitmapCanvasLayerUpdater::Create(ScrollbarThumbPainter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs()); if (!m_thumb) m_thumb = m_thumbUpdater->createTexture(layerTreeHost()->contentsTextureManager()); } -void ScrollbarLayer::updatePart(CachingBitmapCanvasLayerTextureUpdater* painter, LayerTextureUpdater::Texture* texture, const IntRect& rect, TextureUpdateQueue& queue, RenderingStats& stats) +void ScrollbarLayer::updatePart(CachingBitmapCanvasLayerUpdater* painter, LayerUpdater::Texture* texture, const IntRect& rect, TextureUpdateQueue& queue, RenderingStats& stats) { // Skip painting and uploading if there are no invalidations and // we already have valid texture data. @@ -243,7 +243,7 @@ void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) if (contentBounds().isEmpty()) return; - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); bool drawsToRoot = !renderTarget()->parent(); if (m_backTrack) { @@ -266,7 +266,7 @@ void ScrollbarLayer::update(TextureUpdateQueue& queue, const OcclusionTracker*, if (contentBounds().isEmpty()) return; - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().y); IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin.x(), scrollbarOrigin.y(), bounds().width(), bounds().height())); diff --git a/cc/scrollbar_layer.h b/cc/scrollbar_layer.h index 370dca1..8be2d82 100644 --- a/cc/scrollbar_layer.h +++ b/cc/scrollbar_layer.h @@ -6,7 +6,7 @@ #ifndef ScrollbarLayerChromium_h #define ScrollbarLayerChromium_h -#include "caching_bitmap_canvas_layer_texture_updater.h" +#include "caching_bitmap_canvas_layer_updater.h" #include "cc/layer.h" #include #include @@ -42,8 +42,8 @@ protected: virtual ~ScrollbarLayer(); private: - void updatePart(CachingBitmapCanvasLayerTextureUpdater*, LayerTextureUpdater::Texture*, const IntRect&, TextureUpdateQueue&, RenderingStats&); - void createTextureUpdaterIfNeeded(); + void updatePart(CachingBitmapCanvasLayerUpdater*, LayerUpdater::Texture*, const IntRect&, TextureUpdateQueue&, RenderingStats&); + void createUpdaterIfNeeded(); scoped_ptr m_scrollbar; WebKit::WebScrollbarThemePainter m_painter; @@ -52,14 +52,14 @@ private: GLenum m_textureFormat; - scoped_refptr m_backTrackUpdater; - scoped_refptr m_foreTrackUpdater; - scoped_refptr m_thumbUpdater; + scoped_refptr m_backTrackUpdater; + scoped_refptr m_foreTrackUpdater; + scoped_refptr m_thumbUpdater; // All the parts of the scrollbar except the thumb - scoped_ptr m_backTrack; - scoped_ptr m_foreTrack; - scoped_ptr m_thumb; + scoped_ptr m_backTrack; + scoped_ptr m_foreTrack; + scoped_ptr m_thumb; }; } diff --git a/cc/skpicture_canvas_layer_texture_updater.cc b/cc/skpicture_canvas_layer_texture_updater.cc deleted file mode 100644 index 1bb20df..0000000 --- a/cc/skpicture_canvas_layer_texture_updater.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/skpicture_canvas_layer_texture_updater.h" - -#include "base/debug/trace_event.h" -#include "cc/layer_painter.h" -#include "cc/texture_update_queue.h" -#include "third_party/skia/include/core/SkCanvas.h" - -namespace cc { - -SkPictureCanvasLayerTextureUpdater::Texture::Texture(SkPictureCanvasLayerTextureUpdater* textureUpdater, scoped_ptr texture) - : LayerTextureUpdater::Texture(texture.Pass()) - , m_textureUpdater(textureUpdater) -{ -} - -SkPictureCanvasLayerTextureUpdater::Texture::~Texture() -{ -} - -void SkPictureCanvasLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) -{ - textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); -} - -SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater(scoped_ptr painter) - : CanvasLayerTextureUpdater(painter.Pass()) - , m_layerIsOpaque(false) -{ -} - -SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater() -{ -} - -scoped_refptr SkPictureCanvasLayerTextureUpdater::create(scoped_ptr painter) -{ - return make_scoped_refptr(new SkPictureCanvasLayerTextureUpdater(painter.Pass())); -} - -scoped_ptr SkPictureCanvasLayerTextureUpdater::createTexture(PrioritizedTextureManager* manager) -{ - return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); -} - -void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) -{ - SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); - paintContents(canvas, contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); - m_picture.endRecording(); -} - -void SkPictureCanvasLayerTextureUpdater::drawPicture(SkCanvas* canvas) -{ - TRACE_EVENT0("cc", "SkPictureCanvasLayerTextureUpdater::drawPicture"); - canvas->drawPicture(m_picture); -} - -void SkPictureCanvasLayerTextureUpdater::updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) -{ - ResourceUpdate upload = ResourceUpdate::CreateFromPicture( - texture, &m_picture, contentRect(), sourceRect, destOffset); - if (partialUpdate) - queue.appendPartialUpload(upload); - else - queue.appendFullUpload(upload); -} - -void SkPictureCanvasLayerTextureUpdater::setOpaque(bool opaque) -{ - m_layerIsOpaque = opaque; -} - -} // namespace cc diff --git a/cc/skpicture_canvas_layer_texture_updater.h b/cc/skpicture_canvas_layer_texture_updater.h deleted file mode 100644 index 42709cb..0000000 --- a/cc/skpicture_canvas_layer_texture_updater.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -#ifndef SkPictureCanvasLayerTextureUpdater_h -#define SkPictureCanvasLayerTextureUpdater_h - -#include "cc/canvas_layer_texture_updater.h" -#include "third_party/skia/include/core/SkPicture.h" - -class SkCanvas; - -namespace cc { - -class LayerPainter; - -// This class records the contentRect into an SkPicture. Subclasses, provide -// different implementations of tile updating based on this recorded picture. -// The BitmapSkPictureCanvasLayerTextureUpdater and -// FrameBufferSkPictureCanvasLayerTextureUpdater are two examples of such -// implementations. -class SkPictureCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater { -public: - class Texture : public LayerTextureUpdater::Texture { - public: - Texture(SkPictureCanvasLayerTextureUpdater*, scoped_ptr); - virtual ~Texture(); - - virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; - - private: - SkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; } - - SkPictureCanvasLayerTextureUpdater* m_textureUpdater; - }; - - static scoped_refptr create(scoped_ptr); - - virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; - virtual void setOpaque(bool) OVERRIDE; - -protected: - explicit SkPictureCanvasLayerTextureUpdater(scoped_ptr); - virtual ~SkPictureCanvasLayerTextureUpdater(); - - virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) OVERRIDE; - void drawPicture(SkCanvas*); - void updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate); - - bool layerIsOpaque() const { return m_layerIsOpaque; } - -private: - // Recording canvas. - SkPicture m_picture; - // True when it is known that all output pixels will be opaque. - bool m_layerIsOpaque; -}; - -} // namespace cc -#endif // SkPictureCanvasLayerTextureUpdater_h diff --git a/cc/skpicture_canvas_layer_updater.cc b/cc/skpicture_canvas_layer_updater.cc new file mode 100644 index 0000000..fe42362 --- /dev/null +++ b/cc/skpicture_canvas_layer_updater.cc @@ -0,0 +1,79 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/skpicture_canvas_layer_updater.h" + +#include "base/debug/trace_event.h" +#include "cc/layer_painter.h" +#include "cc/texture_update_queue.h" +#include "third_party/skia/include/core/SkCanvas.h" + +namespace cc { + +SkPictureCanvasLayerUpdater::Texture::Texture(SkPictureCanvasLayerUpdater* updater, scoped_ptr texture) + : LayerUpdater::Texture(texture.Pass()) + , m_updater(updater) +{ +} + +SkPictureCanvasLayerUpdater::Texture::~Texture() +{ +} + +void SkPictureCanvasLayerUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) +{ + updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); +} + +SkPictureCanvasLayerUpdater::SkPictureCanvasLayerUpdater(scoped_ptr painter) + : CanvasLayerUpdater(painter.Pass()) + , m_layerIsOpaque(false) +{ +} + +SkPictureCanvasLayerUpdater::~SkPictureCanvasLayerUpdater() +{ +} + +scoped_refptr SkPictureCanvasLayerUpdater::create(scoped_ptr painter) +{ + return make_scoped_refptr(new SkPictureCanvasLayerUpdater(painter.Pass())); +} + +scoped_ptr SkPictureCanvasLayerUpdater::createTexture(PrioritizedTextureManager* manager) +{ + return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); +} + +void SkPictureCanvasLayerUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats& stats) +{ + SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); + paintContents(canvas, contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); + m_picture.endRecording(); +} + +void SkPictureCanvasLayerUpdater::drawPicture(SkCanvas* canvas) +{ + TRACE_EVENT0("cc", "SkPictureCanvasLayerUpdater::drawPicture"); + canvas->drawPicture(m_picture); +} + +void SkPictureCanvasLayerUpdater::updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) +{ + ResourceUpdate upload = ResourceUpdate::CreateFromPicture( + texture, &m_picture, contentRect(), sourceRect, destOffset); + if (partialUpdate) + queue.appendPartialUpload(upload); + else + queue.appendFullUpload(upload); +} + +void SkPictureCanvasLayerUpdater::setOpaque(bool opaque) +{ + m_layerIsOpaque = opaque; +} + +} // namespace cc diff --git a/cc/skpicture_canvas_layer_updater.h b/cc/skpicture_canvas_layer_updater.h new file mode 100644 index 0000000..5fe8e1a --- /dev/null +++ b/cc/skpicture_canvas_layer_updater.h @@ -0,0 +1,61 @@ +// Copyright 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +#ifndef SkPictureCanvasLayerUpdater_h +#define SkPictureCanvasLayerUpdater_h + +#include "cc/canvas_layer_updater.h" +#include "third_party/skia/include/core/SkPicture.h" + +class SkCanvas; + +namespace cc { + +class LayerPainter; + +// This class records the contentRect into an SkPicture. Subclasses, provide +// different implementations of tile updating based on this recorded picture. +// The BitmapSkPictureCanvasLayerUpdater and +// FrameBufferSkPictureCanvasLayerUpdater are two examples of such +// implementations. +class SkPictureCanvasLayerUpdater : public CanvasLayerUpdater { +public: + class Texture : public LayerUpdater::Texture { + public: + Texture(SkPictureCanvasLayerUpdater*, scoped_ptr); + virtual ~Texture(); + + virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + + private: + SkPictureCanvasLayerUpdater* updater() { return m_updater; } + + SkPictureCanvasLayerUpdater* m_updater; + }; + + static scoped_refptr create(scoped_ptr); + + virtual scoped_ptr createTexture(PrioritizedTextureManager*) OVERRIDE; + virtual void setOpaque(bool) OVERRIDE; + +protected: + explicit SkPictureCanvasLayerUpdater(scoped_ptr); + virtual ~SkPictureCanvasLayerUpdater(); + + virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) OVERRIDE; + void drawPicture(SkCanvas*); + void updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate); + + bool layerIsOpaque() const { return m_layerIsOpaque; } + +private: + // Recording canvas. + SkPicture m_picture; + // True when it is known that all output pixels will be opaque. + bool m_layerIsOpaque; +}; + +} // namespace cc +#endif // SkPictureCanvasLayerUpdater_h diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index ad9ef2e..3467e22 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -10,19 +10,19 @@ using namespace cc; namespace WebKitTests { -FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, scoped_ptr texture) - : LayerTextureUpdater::Texture(texture.Pass()) +FakeLayerUpdater::Texture::Texture(FakeLayerUpdater* layer, scoped_ptr texture) + : LayerUpdater::Texture(texture.Pass()) , m_layer(layer) { m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); m_bitmap.allocPixels(); } -FakeLayerTextureUpdater::Texture::~Texture() +FakeLayerUpdater::Texture::~Texture() { } -void FakeLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect&, const IntSize&, bool partialUpdate, RenderingStats&) +void FakeLayerUpdater::Texture::update(TextureUpdateQueue& queue, const IntRect&, const IntSize&, bool partialUpdate, RenderingStats&) { const IntRect rect(0, 0, 10, 10); ResourceUpdate upload = ResourceUpdate::Create( @@ -35,17 +35,17 @@ void FakeLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const I m_layer->update(); } -FakeLayerTextureUpdater::FakeLayerTextureUpdater() +FakeLayerUpdater::FakeLayerUpdater() : m_prepareCount(0) , m_updateCount(0) { } -FakeLayerTextureUpdater::~FakeLayerTextureUpdater() +FakeLayerUpdater::~FakeLayerUpdater() { } -void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, float, float, IntRect& resultingOpaqueRect, RenderingStats&) +void FakeLayerUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, float, float, IntRect& resultingOpaqueRect, RenderingStats&) { m_prepareCount++; m_lastUpdateRect = contentRect; @@ -57,15 +57,15 @@ void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const resultingOpaqueRect = m_opaquePaintRect; } -void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiledLayer* layer) +void FakeLayerUpdater::setRectToInvalidate(const IntRect& rect, FakeTiledLayer* layer) { m_rectToInvalidate = rect; m_layer = layer; } -scoped_ptr FakeLayerTextureUpdater::createTexture(PrioritizedTextureManager* manager) +scoped_ptr FakeLayerUpdater::createTexture(PrioritizedTextureManager* manager) { - return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); + return scoped_ptr(new Texture(this, PrioritizedTexture::create(manager))); } FakeTiledLayerImpl::FakeTiledLayerImpl(int id) @@ -79,7 +79,7 @@ FakeTiledLayerImpl::~FakeTiledLayerImpl() FakeTiledLayer::FakeTiledLayer(PrioritizedTextureManager* textureManager) : TiledLayer() - , m_fakeTextureUpdater(make_scoped_refptr(new FakeLayerTextureUpdater)) + , m_fakeUpdater(make_scoped_refptr(new FakeLayerUpdater)) , m_textureManager(textureManager) { setTileSize(tileSize()); @@ -129,9 +129,9 @@ cc::PrioritizedTextureManager* FakeTiledLayer::textureManager() const return m_textureManager; } -cc::LayerTextureUpdater* FakeTiledLayer::textureUpdater() const +cc::LayerUpdater* FakeTiledLayer::updater() const { - return m_fakeTextureUpdater.get(); + return m_fakeUpdater.get(); } cc::IntSize FakeTiledLayerWithScaledBounds::contentBounds() const diff --git a/cc/test/tiled_layer_test_common.h b/cc/test/tiled_layer_test_common.h index be52ca1..ee6d31d 100644 --- a/cc/test/tiled_layer_test_common.h +++ b/cc/test/tiled_layer_test_common.h @@ -9,7 +9,7 @@ #include "IntRect.h" #include "IntSize.h" #include "Region.h" -#include "cc/layer_texture_updater.h" +#include "cc/layer_updater.h" #include "cc/prioritized_texture.h" #include "cc/resource_provider.h" #include "cc/texture_copier.h" @@ -22,23 +22,23 @@ namespace WebKitTests { class FakeTiledLayer; -class FakeLayerTextureUpdater : public cc::LayerTextureUpdater { +class FakeLayerUpdater : public cc::LayerUpdater { public: - class Texture : public cc::LayerTextureUpdater::Texture { + class Texture : public cc::LayerUpdater::Texture { public: - Texture(FakeLayerTextureUpdater*, scoped_ptr); + Texture(FakeLayerUpdater*, scoped_ptr); virtual ~Texture(); virtual void update(cc::TextureUpdateQueue&, const cc::IntRect&, const cc::IntSize&, bool, cc::RenderingStats&) OVERRIDE; private: - FakeLayerTextureUpdater* m_layer; + FakeLayerUpdater* m_layer; SkBitmap m_bitmap; }; - FakeLayerTextureUpdater(); + FakeLayerUpdater(); - virtual scoped_ptr createTexture(cc::PrioritizedTextureManager*) OVERRIDE; + virtual scoped_ptr createTexture(cc::PrioritizedTextureManager*) OVERRIDE; virtual void prepareToUpdate(const cc::IntRect& contentRect, const cc::IntSize&, float, float, cc::IntRect& resultingOpaqueRect, cc::RenderingStats&) OVERRIDE; // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next @@ -59,7 +59,7 @@ public: void setOpaquePaintRect(const cc::IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } protected: - virtual ~FakeLayerTextureUpdater(); + virtual ~FakeLayerUpdater(); private: int m_prepareCount; @@ -97,16 +97,16 @@ public: virtual void setTexturePriorities(const cc::PriorityCalculator&) OVERRIDE; virtual cc::PrioritizedTextureManager* textureManager() const OVERRIDE; - FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); } + FakeLayerUpdater* fakeLayerUpdater() { return m_fakeUpdater.get(); } cc::FloatRect updateRect() { return m_updateRect; } protected: - virtual cc::LayerTextureUpdater* textureUpdater() const OVERRIDE; - virtual void createTextureUpdaterIfNeeded() OVERRIDE { } + virtual cc::LayerUpdater* updater() const OVERRIDE; + virtual void createUpdaterIfNeeded() OVERRIDE { } virtual ~FakeTiledLayer(); private: - scoped_refptr m_fakeTextureUpdater; + scoped_refptr m_fakeUpdater; cc::PrioritizedTextureManager* m_textureManager; cc::FloatRect m_lastNeedsDisplayRect; }; diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc index fe3e3dd..367ca04 100644 --- a/cc/tiled_layer.cc +++ b/cc/tiled_layer.cc @@ -21,12 +21,12 @@ namespace cc { class UpdatableTile : public LayerTilingData::Tile { public: - static scoped_ptr create(scoped_ptr texture) + static scoped_ptr create(scoped_ptr texture) { return make_scoped_ptr(new UpdatableTile(texture.Pass())); } - LayerTextureUpdater::Texture* texture() { return m_texture.get(); } + LayerUpdater::Texture* texture() { return m_texture.get(); } PrioritizedTexture* managedTexture() { return m_texture->texture(); } bool isDirty() const { return !dirtyRect.isEmpty(); } @@ -61,7 +61,7 @@ public: bool isInUseOnImpl; private: - explicit UpdatableTile(scoped_ptr texture) + explicit UpdatableTile(scoped_ptr texture) : partialUpdate(false) , validForFrame(false) , occluded(false) @@ -70,7 +70,7 @@ private: { } - scoped_ptr m_texture; + scoped_ptr m_texture; DISALLOW_COPY_AND_ASSIGN(UpdatableTile); }; @@ -255,9 +255,9 @@ UpdatableTile* TiledLayer::tileAt(int i, int j) const UpdatableTile* TiledLayer::createTile(int i, int j) { - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); - scoped_ptr tile(UpdatableTile::create(textureUpdater()->createTexture(textureManager()))); + scoped_ptr tile(UpdatableTile::create(updater()->createTexture(textureManager()))); tile->managedTexture()->setDimensions(m_tiler->tileSize(), m_textureFormat); UpdatableTile* addedTile = tile.get(); @@ -343,7 +343,7 @@ bool TiledLayer::tileNeedsBufferedUpdate(UpdatableTile* tile) bool TiledLayer::updateTiles(int left, int top, int right, int bottom, TextureUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, bool& didPaint) { didPaint = false; - createTextureUpdaterIfNeeded(); + createUpdaterIfNeeded(); bool ignoreOcclusions = !occlusion; if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { @@ -457,9 +457,9 @@ void TiledLayer::updateTileTextures(const IntRect& paintRect, int left, int top, // effect of disabling compositing, which causes our reference to the texture updater to be deleted. // However, we can't free the memory backing the SkCanvas until the paint finishes, // so we grab a local reference here to hold the updater alive until the paint completes. - scoped_refptr protector(textureUpdater()); + scoped_refptr protector(updater()); IntRect paintedOpaqueRect; - textureUpdater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1 / heightScale, paintedOpaqueRect, stats); + updater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1 / heightScale, paintedOpaqueRect, stats); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { @@ -616,7 +616,7 @@ void TiledLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) IntRect tileRect = m_tiler->tileRect(tile); tile->dirtyRect = tileRect; - LayerTextureUpdater::Texture* backBuffer = tile->texture(); + LayerUpdater::Texture* backBuffer = tile->texture(); setPriorityForTexture(visibleContentRect(), tile->dirtyRect, drawsToRoot, smallAnimatedLayer, backBuffer->texture()); scoped_ptr frontBuffer = PrioritizedTexture::create(backBuffer->texture()->textureManager(), backBuffer->texture()->size(), diff --git a/cc/tiled_layer.h b/cc/tiled_layer.h index b060ef6..0712c5f 100644 --- a/cc/tiled_layer.h +++ b/cc/tiled_layer.h @@ -6,7 +6,7 @@ #define TiledLayerChromium_h #include "cc/layer.h" -#include "cc/layer_texture_updater.h" +#include "cc/layer_updater.h" #include "cc/layer_tiling_data.h" namespace cc { @@ -50,8 +50,8 @@ protected: void setBorderTexelOption(LayerTilingData::BorderTexelOption); size_t numPaintedTiles() { return m_tiler->tiles().size(); } - virtual LayerTextureUpdater* textureUpdater() const = 0; - virtual void createTextureUpdaterIfNeeded() = 0; + virtual LayerUpdater* updater() const = 0; + virtual void createUpdaterIfNeeded() = 0; // Set invalidations to be potentially repainted during update(). void invalidateContentRect(const IntRect& contentRect); diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc index 3e79fab..8f46bb0 100644 --- a/cc/tiled_layer_unittest.cc +++ b/cc/tiled_layer_unittest.cc @@ -6,7 +6,7 @@ #include "cc/tiled_layer.h" -#include "cc/bitmap_canvas_layer_texture_updater.h" +#include "cc/bitmap_canvas_layer_updater.h" #include "cc/layer_painter.h" #include "cc/overdraw_metrics.h" #include "cc/rendering_stats.h" @@ -381,7 +381,7 @@ TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) // The tile size is 100x100, so this invalidates and then paints two tiles. // However, during the paint, we invalidate one of the tiles. This should // not prevent the tile from being pushed. - layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer.get()); + layer->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer.get()); layer->setBounds(IntSize(100, 200)); layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); updateAndPush(layer.get(), layerImpl.get()); @@ -399,7 +399,7 @@ TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) ScopedFakeTiledLayerImpl layer2Impl(2); // Invalidate a tile on layer1, during update of layer 2. - layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get()); + layer2->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get()); layer1->setBounds(IntSize(100, 200)); layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer2->setBounds(IntSize(100, 200)); @@ -421,7 +421,7 @@ TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) ScopedFakeTiledLayerImpl layer1Impl(1); ScopedFakeTiledLayerImpl layer2Impl(2); - layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get()); + layer1->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get()); layer1->setBounds(IntSize(100, 200)); layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); layer2->setBounds(IntSize(100, 200)); @@ -592,23 +592,23 @@ TEST_F(TiledLayerTest, invalidateFromPrepare) EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); - layer->fakeLayerTextureUpdater()->clearPrepareCount(); + layer->fakeLayerUpdater()->clearPrepareCount(); // Invoke update again. As the layer is valid update shouldn't be invoked on - // the LayerTextureUpdater. + // the LayerUpdater. updateAndPush(layer.get(), layerImpl.get()); - EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); + EXPECT_EQ(0, layer->fakeLayerUpdater()->prepareCount()); // setRectToInvalidate triggers invalidateContentRect() being invoked from update. - layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get()); - layer->fakeLayerTextureUpdater()->clearPrepareCount(); + layer->fakeLayerUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get()); + layer->fakeLayerUpdater()->clearPrepareCount(); layer->invalidateContentRect(IntRect(0, 0, 50, 50)); updateAndPush(layer.get(), layerImpl.get()); - EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); - layer->fakeLayerTextureUpdater()->clearPrepareCount(); + EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); + layer->fakeLayerUpdater()->clearPrepareCount(); // The layer should still be invalid as update invoked invalidate. updateAndPush(layer.get(), layerImpl.get()); // visible - EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); + EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); } TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) @@ -813,9 +813,9 @@ TEST_F(TiledLayerTest, partialUpdates) EXPECT_EQ(6, m_queue->fullUploadSize()); EXPECT_EQ(0, m_queue->partialUploadSize()); updateTextures(); - EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layerPushPropertiesTo(layer.get(), layerImpl.get()); } layerTreeHost->commitComplete(); @@ -828,9 +828,9 @@ TEST_F(TiledLayerTest, partialUpdates) EXPECT_EQ(3, m_queue->fullUploadSize()); EXPECT_EQ(3, m_queue->partialUploadSize()); updateTextures(); - EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layerPushPropertiesTo(layer.get(), layerImpl.get()); } layerTreeHost->commitComplete(); @@ -843,9 +843,9 @@ TEST_F(TiledLayerTest, partialUpdates) EXPECT_EQ(2, m_queue->fullUploadSize()); EXPECT_EQ(4, m_queue->partialUploadSize()); updateTextures(); - EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layerPushPropertiesTo(layer.get(), layerImpl.get()); } layerTreeHost->commitComplete(); @@ -866,9 +866,9 @@ TEST_F(TiledLayerTest, partialUpdates) EXPECT_EQ(6, m_queue->fullUploadSize()); EXPECT_EQ(0, m_queue->partialUploadSize()); updateTextures(); - EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layerPushPropertiesTo(layer.get(), layerImpl.get()); } layerTreeHost->commitComplete(); @@ -881,9 +881,9 @@ TEST_F(TiledLayerTest, partialUpdates) EXPECT_EQ(0, m_queue->fullUploadSize()); EXPECT_EQ(4, m_queue->partialUploadSize()); updateTextures(); - EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layerPushPropertiesTo(layer.get(), layerImpl.get()); } layerTreeHost->commitComplete(); @@ -905,7 +905,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), 0, m_stats); - EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); } TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) @@ -925,33 +925,33 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); occluded.setOcclusion(IntRect(250, 200, 300, 100)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000, 1); EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); occluded.setOcclusion(IntRect(250, 250, 300, 100)); layer->invalidateContentRect(IntRect(0, 0, 600, 600)); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000 + 360000, 1); @@ -976,13 +976,13 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000, 1); EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); // Now the visible region stops at the edge of the occlusion so the partly visible tiles become fully occluded. occluded.setOcclusion(IntRect(200, 200, 300, 150)); @@ -992,13 +992,13 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000, 1); EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); // Now the visible region is even smaller than the occlusion, it should have the same result. occluded.setOcclusion(IntRect(200, 200, 300, 150)); @@ -1008,7 +1008,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000 + 180000, 1); @@ -1032,7 +1032,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); { updateTextures(); } @@ -1041,13 +1041,13 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); @@ -1076,7 +1076,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); @@ -1110,13 +1110,13 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) // The content is half the size of the layer (so the number of tiles is fewer). // In this case, the content is 300x300, and since the tile size is 100, the // number of tiles 3x3. - EXPECT_EQ(9, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1); EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); // This makes sure the painting works when the content space is scaled to // a different layer space. In this case the occluded region catches the @@ -1128,13 +1128,13 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 + 80000, 1); EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); - layer->fakeLayerTextureUpdater()->clearUpdateCount(); + layer->fakeLayerUpdater()->clearUpdateCount(); // This makes sure content scaling and transforms work together. WebTransformationMatrix screenTransform; @@ -1149,7 +1149,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); layer->update(*m_queue.get(), &occluded, m_stats); - EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 + 80000 + 80000, 1); @@ -1178,7 +1178,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) m_textureManager->prioritizeTextures(); // If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(contentBounds); layer->update(*m_queue.get(), &occluded, m_stats); opaqueContents = layer->visibleContentOpaqueRegion(); @@ -1191,7 +1191,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // visibleContentOpaqueRegion should match the visible part of what is painted opaque. opaquePaintRect = IntRect(10, 10, 90, 190); - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); + layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect); layer->invalidateContentRect(contentBounds); layer->update(*m_queue.get(), &occluded, m_stats); updateTextures(); @@ -1205,7 +1205,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); // If we paint again without invalidating, the same stuff should be opaque. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->update(*m_queue.get(), &occluded, m_stats); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); @@ -1219,7 +1219,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // If we repaint a non-opaque part of the tile, then it shouldn't lose its opaque-ness. And other tiles should // not be affected. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(0, 0, 1, 1)); layer->update(*m_queue.get(), &occluded, m_stats); updateTextures(); @@ -1234,7 +1234,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // If we repaint an opaque part of the tile, then it should lose its opaque-ness. But other tiles should still // not be affected. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(10, 10, 1, 1)); layer->update(*m_queue.get(), &occluded, m_stats); updateTextures(); @@ -1270,7 +1270,7 @@ TEST_F(TiledLayerTest, pixelsPaintedMetrics) m_textureManager->prioritizeTextures(); // Invalidates and paints the whole layer. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(contentBounds); layer->update(*m_queue.get(), &occluded, m_stats); updateTextures(); @@ -1284,7 +1284,7 @@ TEST_F(TiledLayerTest, pixelsPaintedMetrics) // Invalidates an area on the top and bottom tile, which will cause us to paint the tile in the middle, // even though it is not dirty and will not be uploaded. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); layer->invalidateContentRect(IntRect(0, 0, 1, 1)); layer->invalidateContentRect(IntRect(50, 200, 10, 10)); layer->update(*m_queue.get(), &occluded, m_stats); @@ -1352,14 +1352,14 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) *m_queue.get(), std::numeric_limits::max()); { updateTextures(); - EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - root->fakeLayerTextureUpdater()->clearUpdateCount(); - child->fakeLayerTextureUpdater()->clearUpdateCount(); - child2->fakeLayerTextureUpdater()->clearUpdateCount(); + root->fakeLayerUpdater()->clearUpdateCount(); + child->fakeLayerUpdater()->clearUpdateCount(); + child2->fakeLayerUpdater()->clearUpdateCount(); ScopedFakeTiledLayerImpl rootImpl(root->id()); ScopedFakeTiledLayerImpl childImpl(child->id()); @@ -1387,14 +1387,14 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); { updateTextures(); - EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - root->fakeLayerTextureUpdater()->clearUpdateCount(); - child->fakeLayerTextureUpdater()->clearUpdateCount(); - child2->fakeLayerTextureUpdater()->clearUpdateCount(); + root->fakeLayerUpdater()->clearUpdateCount(); + child->fakeLayerUpdater()->clearUpdateCount(); + child2->fakeLayerUpdater()->clearUpdateCount(); ScopedFakeTiledLayerImpl rootImpl(root->id()); ScopedFakeTiledLayerImpl childImpl(child->id()); @@ -1423,14 +1423,14 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) *m_queue.get(), (3 * 1) * (100 * 100) * 4); { updateTextures(); - EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); - EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); + EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); + EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); EXPECT_FALSE(m_queue->hasMoreUpdates()); - root->fakeLayerTextureUpdater()->clearUpdateCount(); - child->fakeLayerTextureUpdater()->clearUpdateCount(); - child2->fakeLayerTextureUpdater()->clearUpdateCount(); + root->fakeLayerUpdater()->clearUpdateCount(); + child->fakeLayerUpdater()->clearUpdateCount(); + child2->fakeLayerUpdater()->clearUpdateCount(); ScopedFakeTiledLayerImpl rootImpl(root->id()); ScopedFakeTiledLayerImpl childImpl(child->id()); @@ -1477,7 +1477,7 @@ public: { scoped_ptr trackingLayerPainter(TrackingLayerPainter::create()); m_trackingLayerPainter = trackingLayerPainter.get(); - m_layerTextureUpdater = BitmapCanvasLayerTextureUpdater::create(trackingLayerPainter.PassAs()); + m_layerUpdater = BitmapCanvasLayerUpdater::create(trackingLayerPainter.PassAs()); } TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerPainter; } @@ -1485,11 +1485,11 @@ public: protected: virtual ~UpdateTrackingTiledLayer() { } - virtual LayerTextureUpdater* textureUpdater() const OVERRIDE { return m_layerTextureUpdater.get(); } + virtual LayerUpdater* updater() const OVERRIDE { return m_layerUpdater.get(); } private: TrackingLayerPainter* m_trackingLayerPainter; - scoped_refptr m_layerTextureUpdater; + scoped_refptr m_layerUpdater; }; TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) -- cgit v1.1