Commit c08d90b4 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

cc: Refactor discardable image gathering to reduce plumbing.

This patch consolidates a few discardable image related work into fewer
classes in cc. Specifically, it moves all of the generation code into
discardable image map. It also removes display item list functionality
and just exposes discardable image map from there, since most of those
functions were pass-through.

R=enne@chromium.org, khushalsagar@chromium.org

Bug: 741775
Change-Id: I483d4544f35356465c09f9084d9a0ec3ae0a9029
Reviewed-on: https://chromium-review.googlesource.com/575347
Commit-Queue: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487546}
parent 39345e3f
......@@ -9,8 +9,6 @@ cc_component("paint") {
sources = [
"discardable_image_map.cc",
"discardable_image_map.h",
"discardable_image_store.cc",
"discardable_image_store.h",
"display_item_list.cc",
"display_item_list.h",
"draw_image.cc",
......
This diff is collapsed.
......@@ -22,25 +22,13 @@
namespace cc {
class DiscardableImageStore;
class PaintOpBuffer;
// This class is used for generating discardable images data (see DrawImage
// for the type of data it stores). It allows the client to query a particular
// rect and get back a list of DrawImages in that rect.
class CC_PAINT_EXPORT DiscardableImageMap {
public:
class CC_PAINT_EXPORT ScopedMetadataGenerator {
public:
ScopedMetadataGenerator(DiscardableImageMap* image_map,
const gfx::Size& bounds);
~ScopedMetadataGenerator();
DiscardableImageStore* image_store() { return image_store_.get(); }
private:
DiscardableImageMap* image_map_;
std::unique_ptr<DiscardableImageStore> image_store_;
};
DiscardableImageMap();
~DiscardableImageMap();
......@@ -52,6 +40,7 @@ class CC_PAINT_EXPORT DiscardableImageMap {
gfx::Rect GetRectForImage(PaintImage::Id image_id) const;
void Reset();
void Generate(const PaintOpBuffer* paint_op_buffer, const gfx::Rect& bounds);
private:
friend class ScopedMetadataGenerator;
......
......@@ -11,7 +11,6 @@
#include "base/memory/ref_counted.h"
#include "base/values.h"
#include "cc/base/region.h"
#include "cc/paint/discardable_image_store.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_op_buffer.h"
#include "cc/paint/paint_recorder.h"
......@@ -127,9 +126,7 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectTest) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
......@@ -212,9 +209,7 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
......@@ -326,9 +321,7 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
......@@ -365,9 +358,8 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
......@@ -386,20 +378,18 @@ TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) {
PaintImage discardable_image = CreateDiscardablePaintImage(gfx::Size(10, 10));
sk_sp<PaintRecord> record = CreateRecording(discardable_image, visible_rect);
DiscardableImageMap image_map;
{
DiscardableImageMap::ScopedMetadataGenerator generator(&image_map,
visible_rect.size());
DiscardableImageStore* image_store = generator.image_store();
{
std::unique_ptr<SkPaint> paint(new SkPaint());
image_store->GetNoDrawCanvas()->saveLayer(gfx::RectToSkRect(visible_rect),
paint.get());
}
image_store->GatherDiscardableImages(record.get());
image_store->GetNoDrawCanvas()->restore();
}
scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
PaintFlags paint;
PaintOpBuffer* buffer = display_list->StartPaint();
SkRect visible_sk_rect(gfx::RectToSkRect(visible_rect));
buffer->push<SaveLayerOp>(&visible_sk_rect, &paint);
buffer->push<DrawRecordOp>(std::move(record));
buffer->push<RestoreOp>();
display_list->EndPaintOfUnpaired(visible_rect);
display_list->Finalize();
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
EXPECT_EQ(1u, images.size());
......@@ -414,18 +404,17 @@ TEST_F(DiscardableImageMapTest, NullPaintOnSaveLayer) {
PaintImage discardable_image = CreateDiscardablePaintImage(gfx::Size(10, 10));
sk_sp<PaintRecord> record = CreateRecording(discardable_image, visible_rect);
DiscardableImageMap image_map;
{
DiscardableImageMap::ScopedMetadataGenerator generator(&image_map,
visible_rect.size());
DiscardableImageStore* image_store = generator.image_store();
SkPaint* null_paint = nullptr;
image_store->GetNoDrawCanvas()->saveLayer(gfx::RectToSkRect(visible_rect),
null_paint);
image_store->GatherDiscardableImages(record.get());
image_store->GetNoDrawCanvas()->restore();
}
scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
PaintOpBuffer* buffer = display_list->StartPaint();
SkRect visible_sk_rect(gfx::RectToSkRect(visible_rect));
buffer->push<SaveLayerOp>(&visible_sk_rect, nullptr);
buffer->push<DrawRecordOp>(std::move(record));
buffer->push<RestoreOp>();
display_list->EndPaintOfUnpaired(visible_rect);
display_list->Finalize();
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
EXPECT_EQ(1u, images.size());
......@@ -448,9 +437,8 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImage) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(42, 42, 1, 1));
std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
......@@ -492,9 +480,8 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
......@@ -543,9 +530,8 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesRectInBounds) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
......@@ -605,9 +591,7 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInShader) {
content_layer_client.PaintContentsToDisplayList(
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateXYZD50();
for (int y = 0; y < 4; ++y) {
......@@ -656,10 +640,9 @@ TEST_F(DiscardableImageMapTest, ClipsImageRects) {
display_list->EndPaintOfUnpaired(gfx::Rect(250, 250));
display_list->Finalize();
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map =
display_list->discardable_image_map_for_testing();
display_list->GenerateDiscardableImagesMetadata();
const DiscardableImageMap& image_map = display_list->discardable_image_map();
std::vector<PositionScaleDrawImage> images =
GetDiscardableImagesInRect(image_map, visible_rect);
std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
......@@ -692,23 +675,19 @@ TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) {
PaintOpBuffer root_buffer;
root_buffer.push<DrawRecordOp>(internal_record);
root_buffer.push<DrawRecordOp>(record2);
DiscardableImageMap image_map_;
{
DiscardableImageMap::ScopedMetadataGenerator generator(&image_map_,
gfx::Size(200, 200));
generator.image_store()->GatherDiscardableImages(&root_buffer);
}
DiscardableImageMap image_map;
image_map.Generate(&root_buffer, gfx::Rect(200, 200));
gfx::ColorSpace target_color_space;
std::vector<DrawImage> images;
image_map_.GetDiscardableImagesInRect(gfx::Rect(0, 0, 5, 95), 1.f,
target_color_space, &images);
image_map.GetDiscardableImagesInRect(gfx::Rect(0, 0, 5, 95), 1.f,
target_color_space, &images);
EXPECT_EQ(1u, images.size());
EXPECT_TRUE(discardable_image == images[0].paint_image());
images.clear();
image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f,
target_color_space, &images);
image_map.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f,
target_color_space, &images);
EXPECT_EQ(1u, images.size());
EXPECT_TRUE(discardable_image2 == images[0].paint_image());
}
......
// Copyright 2017 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/paint/discardable_image_store.h"
#include "base/containers/adapters.h"
#include "base/memory/ptr_util.h"
#include "cc/paint/display_item_list.h"
#include "third_party/skia/include/utils/SkNoDrawCanvas.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/skia_util.h"
namespace cc {
namespace {
SkRect MapRect(const SkMatrix& matrix, const SkRect& src) {
SkRect dst;
matrix.mapRect(&dst, src);
return dst;
}
} // namespace
class DiscardableImageStore::PaintTrackingCanvas : public SkNoDrawCanvas {
public:
PaintTrackingCanvas(int width, int height) : SkNoDrawCanvas(width, height) {}
~PaintTrackingCanvas() override = default;
bool ComputePaintBounds(const SkRect& rect,
const SkPaint* current_paint,
SkRect* paint_bounds) {
*paint_bounds = rect;
if (current_paint) {
if (!current_paint->canComputeFastBounds())
return false;
*paint_bounds =
current_paint->computeFastBounds(*paint_bounds, paint_bounds);
}
for (const auto& paint : base::Reversed(saved_paints_)) {
if (!paint.canComputeFastBounds())
return false;
*paint_bounds = paint.computeFastBounds(*paint_bounds, paint_bounds);
}
return true;
}
protected:
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override {
saved_paints_.push_back(rec.fPaint ? *rec.fPaint : SkPaint());
return SkNoDrawCanvas::getSaveLayerStrategy(rec);
}
void willSave() override {
saved_paints_.push_back(SkPaint());
return SkNoDrawCanvas::willSave();
}
void willRestore() override {
DCHECK_GT(saved_paints_.size(), 0u);
saved_paints_.pop_back();
SkNoDrawCanvas::willRestore();
}
private:
std::vector<SkPaint> saved_paints_;
};
DiscardableImageStore::DiscardableImageStore(int width, int height)
: canvas_(base::MakeUnique<PaintTrackingCanvas>(width, height)) {}
DiscardableImageStore::~DiscardableImageStore() = default;
SkNoDrawCanvas* DiscardableImageStore::GetNoDrawCanvas() {
return canvas_.get();
}
void DiscardableImageStore::GatherDiscardableImages(
const PaintOpBuffer* buffer) {
if (!buffer->HasDiscardableImages())
return;
SkMatrix original = canvas_->getTotalMatrix();
canvas_->save();
// TODO(khushalsagar): Optimize out save/restore blocks if there are no images
// in the draw ops between them.
for (auto* op : PaintOpBuffer::Iterator(buffer)) {
if (op->IsDrawOp()) {
switch (op->GetType()) {
case PaintOpType::DrawArc: {
auto* arc_op = static_cast<DrawArcOp*>(op);
AddImageFromFlags(arc_op->oval, arc_op->flags);
} break;
case PaintOpType::DrawCircle: {
auto* circle_op = static_cast<DrawCircleOp*>(op);
SkRect rect =
SkRect::MakeXYWH(circle_op->cx - circle_op->radius,
circle_op->cy - circle_op->radius,
2 * circle_op->radius, 2 * circle_op->radius);
AddImageFromFlags(rect, circle_op->flags);
} break;
case PaintOpType::DrawImage: {
auto* image_op = static_cast<DrawImageOp*>(op);
const SkImage* sk_image = image_op->image.sk_image().get();
AddImage(image_op->image,
SkRect::MakeIWH(sk_image->width(), sk_image->height()),
SkRect::MakeXYWH(image_op->left, image_op->top,
sk_image->width(), sk_image->height()),
nullptr, image_op->flags);
} break;
case PaintOpType::DrawImageRect: {
auto* image_rect_op = static_cast<DrawImageRectOp*>(op);
SkMatrix matrix;
matrix.setRectToRect(image_rect_op->src, image_rect_op->dst,
SkMatrix::kFill_ScaleToFit);
AddImage(image_rect_op->image, image_rect_op->src, image_rect_op->dst,
&matrix, image_rect_op->flags);
} break;
case PaintOpType::DrawIRect: {
auto* rect_op = static_cast<DrawIRectOp*>(op);
AddImageFromFlags(SkRect::Make(rect_op->rect), rect_op->flags);
} break;
case PaintOpType::DrawOval: {
auto* oval_op = static_cast<DrawOvalOp*>(op);
AddImageFromFlags(oval_op->oval, oval_op->flags);
} break;
case PaintOpType::DrawPath: {
auto* path_op = static_cast<DrawPathOp*>(op);
AddImageFromFlags(path_op->path.getBounds(), path_op->flags);
} break;
case PaintOpType::DrawRecord: {
auto* record_op = static_cast<DrawRecordOp*>(op);
GatherDiscardableImages(record_op->record.get());
} break;
case PaintOpType::DrawRect: {
auto* rect_op = static_cast<DrawRectOp*>(op);
AddImageFromFlags(rect_op->rect, rect_op->flags);
} break;
case PaintOpType::DrawRRect: {
auto* rect_op = static_cast<DrawRRectOp*>(op);
AddImageFromFlags(rect_op->rrect.rect(), rect_op->flags);
} break;
// TODO(khushalsagar): Check if we should be querying images from any of
// the following ops.
case PaintOpType::DrawPosText:
case PaintOpType::DrawLine:
case PaintOpType::DrawDRRect:
case PaintOpType::DrawText:
case PaintOpType::DrawTextBlob:
case PaintOpType::DrawColor:
break;
default:
NOTREACHED();
}
} else {
op->Raster(canvas_.get(), original);
}
}
canvas_->restore();
}
// Currently this function only handles extracting images from SkImageShaders
// embedded in SkPaints. Other embedded image cases, such as SkPictures,
// are not yet handled.
void DiscardableImageStore::AddImageFromFlags(const SkRect& rect,
const PaintFlags& flags) {
SkShader* shader = flags.getSkShader();
if (shader) {
SkMatrix matrix;
SkShader::TileMode xy[2];
SkImage* image = shader->isAImage(&matrix, xy);
if (image) {
// We currently use the wrong id for images that come from shaders. We
// don't know what the stable id is, but since the completion and
// animation states are both unknown, this value doesn't matter as it
// won't be used in checker imaging anyway. Keep this value the same to
// avoid id churn.
// TODO(vmpstr): Remove this when we can add paint images into shaders
// directly.
PaintImage paint_image(PaintImage::kUnknownStableId, sk_ref_sp(image),
PaintImage::AnimationType::UNKNOWN,
PaintImage::CompletionState::UNKNOWN);
// TODO(ericrk): Handle cases where we only need a sub-rect from the
// image. crbug.com/671821
AddImage(std::move(paint_image), SkRect::MakeFromIRect(image->bounds()),
rect, &matrix, flags);
}
}
}
void DiscardableImageStore::AddImage(PaintImage paint_image,
const SkRect& src_rect,
const SkRect& rect,
const SkMatrix* local_matrix,
const PaintFlags& flags) {
if (!paint_image.sk_image()->isLazyGenerated())
return;
const SkRect& clip_rect = SkRect::Make(canvas_->getDeviceClipBounds());
const SkMatrix& ctm = canvas_->getTotalMatrix();
SkRect paint_rect = MapRect(ctm, rect);
bool computed_paint_bounds =
canvas_->ComputePaintBounds(paint_rect, ToSkPaint(&flags), &paint_rect);
if (!computed_paint_bounds) {
// TODO(vmpstr): UMA this case.
paint_rect = clip_rect;
}
// Clamp the image rect by the current clip rect.
if (!paint_rect.intersect(clip_rect))
return;
SkFilterQuality filter_quality = flags.getFilterQuality();
SkIRect src_irect;
src_rect.roundOut(&src_irect);
gfx::Rect image_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(paint_rect));
// During raster, we use the device clip bounds on the canvas, which outsets
// the actual clip by 1 due to the possibility of antialiasing. Account for
// this here by outsetting the image rect by 1. Note that this only affects
// queries into the rtree, which will now return images that only touch the
// bounds of the query rect.
//
// Note that it's not sufficient for us to inset the device clip bounds at
// raster time, since we might be sending a larger-than-one-item display
// item to skia, which means that skia will internally determine whether to
// raster the picture (using device clip bounds that are outset).
image_rect.Inset(-1, -1);
// The true target color space will be assigned when it is known, in
// GetDiscardableImagesInRect.
gfx::ColorSpace target_color_space;
SkMatrix matrix = ctm;
if (local_matrix)
matrix.postConcat(*local_matrix);
image_id_to_rect_[paint_image.stable_id()].Union(image_rect);
image_set_.emplace_back(DrawImage(std::move(paint_image), src_irect,
filter_quality, matrix, target_color_space),
image_rect);
}
} // namespace cc
// Copyright 2017 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 CC_PAINT_DISCARDABLE_IMAGE_STORE_H_
#define CC_PAINT_DISCARDABLE_IMAGE_STORE_H_
#include "base/containers/flat_map.h"
#include "cc/paint/draw_image.h"
#include "cc/paint/image_id.h"
#include "cc/paint/paint_export.h"
#include "cc/paint/paint_op_buffer.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/utils/SkNoDrawCanvas.h"
namespace cc {
class PaintFlags;
class PaintImage;
class CC_PAINT_EXPORT DiscardableImageStore {
public:
DiscardableImageStore(int width, int height);
~DiscardableImageStore();
void GatherDiscardableImages(const PaintOpBuffer* buffer);
SkNoDrawCanvas* GetNoDrawCanvas();
std::vector<std::pair<DrawImage, gfx::Rect>> TakeImages() {
return std::move(image_set_);
}
base::flat_map<PaintImage::Id, gfx::Rect> TakeImageIdToRectMap() {
return std::move(image_id_to_rect_);
}
private:
class PaintTrackingCanvas;
void AddImageFromFlags(const SkRect& rect, const PaintFlags& flags);
void AddImage(PaintImage paint_image,
const SkRect& src_rect,
const SkRect& rect,
const SkMatrix* local_matrix,
const PaintFlags& flags);
// This canvas is used only for tracking transform/clip/filter state from the
// non-drawing ops.
std::unique_ptr<PaintTrackingCanvas> canvas_;
std::vector<std::pair<DrawImage, gfx::Rect>> image_set_;
base::flat_map<PaintImage::Id, gfx::Rect> image_id_to_rect_;
};
} // namespace cc
#endif // CC_PAINT_DISCARDABLE_IMAGE_STORE_H_
......@@ -14,7 +14,6 @@
#include "cc/base/math_util.h"
#include "cc/base/render_surface_filters.h"
#include "cc/debug/picture_debug_util.h"
#include "cc/paint/discardable_image_store.h"
#include "cc/paint/solid_color_analyzer.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
......@@ -141,28 +140,7 @@ DisplayItemList::CreateTracedValue(bool include_items) const {
}
void DisplayItemList::GenerateDiscardableImagesMetadata() {
// This should be only called once.
DCHECK(image_map_.empty());
if (!paint_op_buffer_.HasDiscardableImages())
return;
gfx::Rect bounds = rtree_.GetBounds();
DiscardableImageMap::ScopedMetadataGenerator generator(
&image_map_, gfx::Size(bounds.right(), bounds.bottom()));
generator.image_store()->GatherDiscardableImages(&paint_op_buffer_);
}
void DisplayItemList::GetDiscardableImagesInRect(
const gfx::Rect& rect,
float contents_scale,
const gfx::ColorSpace& target_color_space,
std::vector<DrawImage>* images) {
image_map_.GetDiscardableImagesInRect(rect, contents_scale,
target_color_space, images);
}
gfx::Rect DisplayItemList::GetRectForImage(PaintImage::Id image_id) const {
return image_map_.GetRectForImage(image_id);
image_map_.Generate(&paint_op_buffer_, rtree_.GetBounds());
}
void DisplayItemList::Reset() {
......
......@@ -114,25 +114,15 @@ class CC_PAINT_EXPORT DisplayItemList
size_t op_count() const { return paint_op_buffer_.size(); }
size_t BytesUsed() const;
void EmitTraceSnapshot() const;
const DiscardableImageMap& discardable_image_map() const {
return image_map_;
}
void EmitTraceSnapshot() const;
void GenerateDiscardableImagesMetadata();
void GetDiscardableImagesInRect(const gfx::Rect& rect,
float contents_scale,
const gfx::ColorSpace& target_color_space,
std::vector<DrawImage>* images);
gfx::Rect GetRectForImage(PaintImage::Id image_id) const;
gfx::Rect VisualRectForTesting(int index) { return visual_rects_[index]; }
const DiscardableImageMap& discardable_image_map_for_testing() const {
return image_map_;
}
bool HasDiscardableImages() const {
return paint_op_buffer_.HasDiscardableImages();
}
// Generate a PaintRecord from this DisplayItemList, leaving |this| in
// an empty state.
sk_sp<PaintRecord> ReleaseAsRecord();
......
......@@ -228,14 +228,14 @@ void RasterSource::GetDiscardableImagesInRect(
const gfx::ColorSpace& target_color_space,
std::vector<DrawImage>* images) const {
DCHECK_EQ(0u, images->size());
display_list_->GetDiscardableImagesInRect(layer_rect, contents_scale,
target_color_space, images);
display_list_->discardable_image_map().GetDiscardableImagesInRect(
layer_rect, contents_scale, target_color_space, images);
}
gfx::Rect RasterSource::GetRectForImage(PaintImage::Id image_id) const {
if (!display_list_)
return gfx::Rect();
return display_list_->GetRectForImage(image_id);
return display_list_->discardable_image_map().GetRectForImage(image_id);
}
bool RasterSource::CoversRect(const gfx::Rect& layer_rect) const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment