Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ec28df5

Browse files
committed
added GetImageInfo() method to DlCanvas
1 parent b73df92 commit ec28df5

File tree

10 files changed

+40
-7
lines changed

10 files changed

+40
-7
lines changed

display_list/display_list_builder.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ DisplayListBuilder::~DisplayListBuilder() {
9898
}
9999
}
100100

101+
SkISize DisplayListBuilder::GetBaseLayerSize() const {
102+
return tracker_.base_device_cull_rect().roundOut().size();
103+
}
104+
105+
SkImageInfo DisplayListBuilder::GetImageInfo() const {
106+
SkISize size = GetBaseLayerSize();
107+
return SkImageInfo::MakeUnknown(size.width(), size.height());
108+
}
109+
101110
void DisplayListBuilder::onSetAntiAlias(bool aa) {
102111
current_.setAntiAlias(aa);
103112
Push<SetAntiAliasOp>(0, 0, aa);

display_list/display_list_builder.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ class DisplayListBuilder final : public virtual DlCanvas,
4141
explicit DisplayListBuilder(const SkRect& cull_rect = kMaxCullRect,
4242
bool prepare_rtree = false);
4343

44-
SkISize GetBaseLayerSize() const override {
45-
return tracker_.base_device_cull_rect().roundOut().size();
46-
}
44+
SkISize GetBaseLayerSize() const override;
45+
SkImageInfo GetImageInfo() const override;
4746

4847
~DisplayListBuilder();
4948

display_list/display_list_unittests.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ TEST(DisplayList, RecorderInitialClipBoundsNaN) {
5959
ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds);
6060
}
6161

62+
TEST(DisplayList, BuilderBoundsTransformComparedToSkia) {
63+
const SkRect frame_rect = SkRect::MakeLTRB(10, 10, 100, 100);
64+
DisplayListBuilder builder(frame_rect);
65+
SkPictureRecorder recorder;
66+
SkCanvas* canvas = recorder.beginRecording(frame_rect);
67+
ASSERT_EQ(builder.GetDestinationClipBounds(),
68+
SkRect::Make(canvas->getDeviceClipBounds()));
69+
ASSERT_EQ(builder.GetLocalClipBounds().makeOutset(1, 1),
70+
canvas->getLocalClipBounds());
71+
ASSERT_EQ(builder.GetTransform(), canvas->getTotalMatrix());
72+
}
73+
6274
TEST(DisplayList, RecorderClipBoundsAfterClipRect) {
6375
SkRect cull_rect = SkRect::MakeWH(100, 100);
6476
SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20);

display_list/dl_canvas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class DlCanvas {
3838
virtual ~DlCanvas() = default;
3939

4040
virtual SkISize GetBaseLayerSize() const = 0;
41+
virtual SkImageInfo GetImageInfo() const = 0;
4142

4243
virtual void Save() = 0;
4344
virtual void SaveLayer(const SkRect* bounds,

display_list/skia/dl_sk_canvas.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ SkISize DlSkCanvasAdapter::GetBaseLayerSize() const {
8787
return delegate_->getBaseLayerSize();
8888
}
8989

90+
SkImageInfo DlSkCanvasAdapter::GetImageInfo() const {
91+
return delegate_->imageInfo();
92+
}
93+
9094
void DlSkCanvasAdapter::Save() {
9195
delegate_->save();
9296
}

display_list/skia/dl_sk_canvas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DlSkCanvasAdapter final : public virtual DlCanvas {
2121
SkCanvas* canvas() { return delegate_; }
2222

2323
SkISize GetBaseLayerSize() const override;
24+
SkImageInfo GetImageInfo() const override;
2425

2526
void Save() override;
2627
void SaveLayer(const SkRect* bounds,

flow/embedded_views.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,10 @@ enum class PostPrerollResult {
326326

327327
// The |EmbedderViewSlice| represents the details of recording all of
328328
// the layer tree rendering operations that appear between before, after
329-
// and between the embedded views. The Slice may be recorded into an
330-
// SkPicture or a DisplayListBuilder depending on the ScopedFrame.
329+
// and between the embedded views. The Slice used to abstract away
330+
// implementations that were based on either an SkPicture or a
331+
// DisplayListBuilder but more recently all of the embedder recordings
332+
// have standardized on the DisplayList.
331333
class EmbedderViewSlice {
332334
public:
333335
virtual ~EmbedderViewSlice() = default;

flow/layers/layer_tree.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ LayerTree::LayerTree(const SkISize& frame_size, float device_pixel_ratio)
3030
}
3131

3232
inline SkColorSpace* GetColorSpace(DlCanvas* canvas) {
33-
// return canvas ? canvas->imageInfo().colorSpace() : nullptr;
34-
return nullptr;
33+
return canvas ? canvas->GetImageInfo().colorSpace() : nullptr;
3534
}
3635

3736
bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame,

testing/mock_canvas.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ SkISize MockCanvas::GetBaseLayerSize() const {
3232
return tracker_.base_device_cull_rect().roundOut().size();
3333
}
3434

35+
SkImageInfo MockCanvas::GetImageInfo() const {
36+
SkISize size = GetBaseLayerSize();
37+
return SkImageInfo::MakeUnknown(size.width(), size.height());
38+
}
39+
3540
void MockCanvas::Save() {
3641
draw_calls_.emplace_back(
3742
DrawCall{current_layer_, SaveData{current_layer_ + 1}});

testing/mock_canvas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class MockCanvas final : public DlCanvas {
165165
void reset_draw_calls() { draw_calls_.clear(); }
166166

167167
SkISize GetBaseLayerSize() const override;
168+
SkImageInfo GetImageInfo() const override;
168169

169170
void Save() override;
170171
void SaveLayer(const SkRect* bounds,

0 commit comments

Comments
 (0)