summaryrefslogtreecommitdiffstats
path: root/cc/resources/bitmap_skpicture_content_layer_updater.cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 08:24:40 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 08:24:40 +0000
commite12dd0e802b2a80112cb40e01fabcc5c0475f05b (patch)
treefbfd355be68b05d64c98e4c0618e1d4ad8122f6a /cc/resources/bitmap_skpicture_content_layer_updater.cc
parent0d4f1f4b15d63e5976f0a2c0205d414da861c8a5 (diff)
downloadchromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.zip
chromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.tar.gz
chromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.tar.bz2
Part 8 of cc/ directory shuffles: resources
Continuation of https://src.chromium.org/viewvc/chrome?view=rev&revision=188681 BUG=190824 TBR=enne@chromium.org, piman@chromium.org, jschuh@chromium.org Review URL: https://codereview.chromium.org/12471007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/bitmap_skpicture_content_layer_updater.cc')
-rw-r--r--cc/resources/bitmap_skpicture_content_layer_updater.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/cc/resources/bitmap_skpicture_content_layer_updater.cc b/cc/resources/bitmap_skpicture_content_layer_updater.cc
new file mode 100644
index 0000000..9931e11
--- /dev/null
+++ b/cc/resources/bitmap_skpicture_content_layer_updater.cc
@@ -0,0 +1,85 @@
+// 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 "cc/resources/bitmap_skpicture_content_layer_updater.h"
+
+#include "base/time.h"
+#include "cc/debug/rendering_stats.h"
+#include "cc/resources/layer_painter.h"
+#include "cc/resources/prioritized_resource.h"
+#include "cc/resources/resource_update_queue.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkDevice.h"
+
+namespace cc {
+
+BitmapSkPictureContentLayerUpdater::Resource::Resource(
+ BitmapSkPictureContentLayerUpdater* updater,
+ scoped_ptr<PrioritizedResource> texture)
+ : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {}
+
+void BitmapSkPictureContentLayerUpdater::Resource::Update(
+ ResourceUpdateQueue* queue,
+ gfx::Rect source_rect,
+ gfx::Vector2d dest_offset,
+ bool partial_update,
+ RenderingStats* stats) {
+ bitmap_.setConfig(
+ SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height());
+ bitmap_.allocPixels();
+ bitmap_.setIsOpaque(updater_->layer_is_opaque());
+ SkDevice device(bitmap_);
+ SkCanvas canvas(&device);
+ base::TimeTicks paint_begin_time;
+ if (stats)
+ paint_begin_time = base::TimeTicks::Now();
+ updater_->PaintContentsRect(&canvas, source_rect, stats);
+ if (stats)
+ stats->totalPaintTime += base::TimeTicks::Now() - paint_begin_time;
+
+ ResourceUpdate upload = ResourceUpdate::Create(
+ texture(), &bitmap_, source_rect, source_rect, dest_offset);
+ if (partial_update)
+ queue->appendPartialUpload(upload);
+ else
+ queue->appendFullUpload(upload);
+}
+
+scoped_refptr<BitmapSkPictureContentLayerUpdater>
+BitmapSkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) {
+ return make_scoped_refptr(
+ new BitmapSkPictureContentLayerUpdater(painter.Pass()));
+}
+
+BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater(
+ scoped_ptr<LayerPainter> painter)
+ : SkPictureContentLayerUpdater(painter.Pass()) {}
+
+BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {}
+
+scoped_ptr<LayerUpdater::Resource>
+BitmapSkPictureContentLayerUpdater::CreateResource(
+ PrioritizedResourceManager* manager) {
+ return scoped_ptr<LayerUpdater::Resource>(
+ new Resource(this, PrioritizedResource::create(manager)));
+}
+
+void BitmapSkPictureContentLayerUpdater::PaintContentsRect(
+ SkCanvas* canvas,
+ gfx::Rect source_rect,
+ RenderingStats* stats) {
+ // Translate the origin of content_rect to that of source_rect.
+ canvas->translate(content_rect().x() - source_rect.x(),
+ content_rect().y() - source_rect.y());
+ base::TimeTicks rasterize_begin_time;
+ if (stats)
+ rasterize_begin_time = base::TimeTicks::Now();
+ DrawPicture(canvas);
+ if (stats) {
+ stats->totalRasterizeTime += base::TimeTicks::Now() - rasterize_begin_time;
+ stats->totalPixelsRasterized += source_rect.width() * source_rect.height();
+ }
+}
+
+} // namespace cc