summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 03:58:38 +0000
committervmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 03:58:38 +0000
commitc0c292a5a3100765fb4be8c365a19ea9de02d762 (patch)
treef41f71cca6769c68ba440caf86e0f0d7e2fd4808
parentb2598c1a5c8d130025d62aaba7bf286340ac845b (diff)
downloadchromium_src-c0c292a5a3100765fb4be8c365a19ea9de02d762.zip
chromium_src-c0c292a5a3100765fb4be8c365a19ea9de02d762.tar.gz
chromium_src-c0c292a5a3100765fb4be8c365a19ea9de02d762.tar.bz2
cc: Use gather pixel refs with positions util.
This is part 2 of patch: actually using the pixel refs with positions. I'm still storing the pixel refs in a grid, but this reduces the number of walks. This still keeps the impl thread quick, and improves the record time. BUG=242703 Review URL: https://chromiumcodereview.appspot.com/16154008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203836 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/resources/picture.cc77
1 files changed, 25 insertions, 52 deletions
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 71c72ea..6d3ae60 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -17,7 +17,7 @@
#include "cc/debug/traced_picture.h"
#include "cc/debug/traced_value.h"
#include "cc/layers/content_layer_client.h"
-#include "skia/ext/analysis_canvas.h"
+#include "skia/ext/lazy_pixel_ref_utils.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkDrawFilter.h"
@@ -92,37 +92,6 @@ class DisableLCDTextFilter : public SkDrawFilter {
}
};
-// URI label for a lazily decoded SkPixelRef.
-const char kLabelLazyDecoded[] = "lazy";
-
-void GatherPixelRefsForRect(
- SkPicture* picture,
- gfx::Rect rect,
- Picture::PixelRefs* pixel_refs) {
- DCHECK(picture);
- SkData* pixel_ref_data = SkPictureUtils::GatherPixelRefs(
- picture,
- gfx::RectToSkRect(rect));
- if (!pixel_ref_data)
- return;
-
- void* data = const_cast<void*>(pixel_ref_data->data());
- if (!data) {
- pixel_ref_data->unref();
- return;
- }
-
- SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data);
- for (size_t i = 0; i < pixel_ref_data->size() / sizeof(*refs); ++i) {
- if (*refs && (*refs)->getURI() &&
- !strncmp((*refs)->getURI(), kLabelLazyDecoded, 4)) {
- pixel_refs->push_back(static_cast<skia::LazyPixelRef*>(*refs));
- }
- refs++;
- }
- pixel_ref_data->unref();
-}
-
} // namespace
scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) {
@@ -300,29 +269,33 @@ void Picture::GatherPixelRefs(
if (stats)
begin_image_gathering_time = base::TimeTicks::Now();
- gfx::Size layer_size(layer_rect_.size());
-
- // Capture pixel refs for this picture in a grid
- // with cell_size_ sized cells.
- pixel_refs_.clear();
- for (int y = 0; y < layer_rect_.height(); y += cell_size_.height()) {
- for (int x = 0; x < layer_rect_.width(); x += cell_size_.width()) {
- gfx::Rect rect(gfx::Point(x, y), cell_size_);
- rect.Intersect(gfx::Rect(gfx::Point(), layer_rect_.size()));
-
- PixelRefs pixel_refs;
- GatherPixelRefsForRect(picture_.get(), rect, &pixel_refs);
-
- // Only capture non-empty cells.
- if (!pixel_refs.empty()) {
+ skia::LazyPixelRefList pixel_refs;
+ skia::LazyPixelRefUtils::GatherPixelRefs(picture_.get(), &pixel_refs);
+ for (skia::LazyPixelRefList::const_iterator it = pixel_refs.begin();
+ it != pixel_refs.end();
+ ++it) {
+ gfx::Point min(
+ RoundDown(static_cast<int>(it->pixel_ref_rect.x()),
+ cell_size_.width()),
+ RoundDown(static_cast<int>(it->pixel_ref_rect.y()),
+ cell_size_.height()));
+ gfx::Point max(
+ RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.right())),
+ cell_size_.width()),
+ RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.bottom())),
+ cell_size_.height()));
+
+ for (int y = min.y(); y <= max.y(); y += cell_size_.height()) {
+ for (int x = min.x(); x <= max.x(); x += cell_size_.width()) {
PixelRefMapKey key(x, y);
- pixel_refs_[key].swap(pixel_refs);
- min_x = std::min(min_x, x);
- min_y = std::min(min_y, y);
- max_x = std::max(max_x, x);
- max_y = std::max(max_y, y);
+ pixel_refs_[key].push_back(it->lazy_pixel_ref);
}
}
+
+ min_x = std::min(min_x, min.x());
+ min_y = std::min(min_y, min.y());
+ max_x = std::max(max_x, max.x());
+ max_y = std::max(max_y, max.y());
}
if (stats) {