Ensure that the source rect used for the the raster cache replacement is the same as the size of the N32Premul surface. (flutter/engine#3889)

Also adds debug printers for SkRect and SkPoint.
This commit is contained in:
Chinmay Garde
2017-07-17 23:42:40 -07:00
committed by GitHub
parent 0b56c45c87
commit b0b010349e
3 changed files with 25 additions and 11 deletions

View File

@@ -53,6 +53,17 @@ std::ostream& operator<<(std::ostream& os, const SkVector4& v) {
return os;
}
std::ostream& operator<<(std::ostream& os, const SkRect& r) {
os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
<< r.fBottom;
return os;
}
std::ostream& operator<<(std::ostream& os, const SkPoint& r) {
os << "XY: " << r.fX << ", " << r.fY;
return os;
}
std::ostream& operator<<(std::ostream& os, const flow::RasterCacheKey& k) {
os << "Picture: " << k.picture_id() << " Scale: " << k.scale_key().width()
<< ", " << k.scale_key().height();

View File

@@ -20,5 +20,7 @@ DEF_PRINTER(SkMatrix);
DEF_PRINTER(SkMatrix44);
DEF_PRINTER(SkVector3);
DEF_PRINTER(SkVector4);
DEF_PRINTER(SkRect);
DEF_PRINTER(SkPoint);
#endif // FLUTTER_FLOW_DEBUG_PRINT_H_

View File

@@ -75,14 +75,17 @@ RasterCacheResult RasterizePicture(SkPicture* picture,
TRACE_EVENT0("flutter", "RasterCachePopulate");
const SkVector3& scale = matrix.scale();
SkRect logical_rect = picture->cullRect();
const SkImageInfo image_info = SkImageInfo::MakeN32Premul(
std::ceil(logical_rect.width() * std::abs(scale.x())), // physical width
std::ceil(logical_rect.height() *
std::abs(scale.y())), // physical height
nullptr // colorspace
);
const SkRect logical_rect = picture->cullRect();
const SkRect physical_rect =
SkRect::MakeWH(std::ceil(std::labs(logical_rect.width() * scale.x())),
std::ceil(std::labs(logical_rect.height() * scale.y())));
const SkImageInfo image_info =
SkImageInfo::MakeN32Premul(physical_rect.width(), // physical width
physical_rect.height(), // physical height
nullptr // colorspace
);
sk_sp<SkSurface> surface =
context
@@ -107,10 +110,8 @@ RasterCacheResult RasterizePicture(SkPicture* picture,
return {
surface->makeImageSnapshot(), // image
SkRect::MakeWH(
logical_rect.width() * std::abs(scale.x()),
logical_rect.height() * std::abs(scale.y())), // source rect
logical_rect // destination rect
physical_rect, // source rect
logical_rect // destination rect
};
}