forked from firka/flutter
dont snap in preroll (flutter/engine#36239)
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "flutter/flow/layers/cacheable_layer.h"
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/paint_utils.h"
|
||||
#include "flutter/flow/raster_cache_util.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -51,9 +50,6 @@ class ClipShapeLayer : public CacheableContainerLayer {
|
||||
context->cull_rect.setEmpty();
|
||||
}
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache && uses_save_layer) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
// We can use the raster_cache for children only when the use_save_layer is
|
||||
// true so if use_save_layer is false we pass the layer_raster_item is
|
||||
// nullptr which mean we don't do raster cache logic.
|
||||
|
||||
@@ -42,9 +42,6 @@ void ColorFilterLayer::Preroll(PrerollContext* context,
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
AutoCache cache =
|
||||
AutoCache(layer_raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
|
||||
@@ -100,9 +100,6 @@ void DisplayListLayer::Preroll(PrerollContext* context,
|
||||
TRACE_EVENT0("flutter", "DisplayListLayer::Preroll");
|
||||
DisplayList* disp_list = display_list();
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
|
||||
AutoCache cache =
|
||||
AutoCache(display_list_raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
@@ -53,9 +53,6 @@ void ImageFilterLayer::Preroll(PrerollContext* context,
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
|
||||
AutoCache cache =
|
||||
AutoCache(layer_raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "flutter/flow/layers/layer_raster_cache_item.h"
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/raster_cache_item.h"
|
||||
#include "flutter/flow/raster_cache_util.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
||||
|
||||
SkMatrix child_matrix = matrix;
|
||||
child_matrix.preTranslate(offset_.fX, offset_.fY);
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
|
||||
// Similar to what's done in TransformLayer::Preroll, we have to apply the
|
||||
// reverse transformation to the cull rect to properly cull child layers.
|
||||
|
||||
@@ -39,10 +39,6 @@ void ShaderMaskLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
|
||||
AutoCache cache =
|
||||
AutoCache(layer_raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
|
||||
@@ -32,8 +32,9 @@ void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const {
|
||||
TRACE_EVENT0("flutter", "RasterCacheResult::draw");
|
||||
SkAutoCanvasRestore auto_restore(&canvas, true);
|
||||
|
||||
SkRect bounds = RasterCacheUtil::GetRoundedOutDeviceBounds(
|
||||
logical_rect_, canvas.getTotalMatrix());
|
||||
auto matrix = RasterCacheUtil::GetIntegralTransCTM(canvas.getTotalMatrix());
|
||||
SkRect bounds =
|
||||
RasterCacheUtil::GetRoundedOutDeviceBounds(logical_rect_, matrix);
|
||||
FML_DCHECK(std::abs(bounds.width() - image_->dimensions().width()) <= 1 &&
|
||||
std::abs(bounds.height() - image_->dimensions().height()) <= 1);
|
||||
canvas.resetMatrix();
|
||||
@@ -55,9 +56,9 @@ std::unique_ptr<RasterCacheResult> RasterCache::Rasterize(
|
||||
const std::function<void(SkCanvas*, const SkRect& rect)>& draw_checkerboard)
|
||||
const {
|
||||
TRACE_EVENT0("flutter", "RasterCachePopulate");
|
||||
|
||||
SkRect dest_rect = RasterCacheUtil::GetRoundedOutDeviceBounds(
|
||||
context.logical_rect, context.matrix);
|
||||
auto matrix = RasterCacheUtil::GetIntegralTransCTM(context.matrix);
|
||||
SkRect dest_rect =
|
||||
RasterCacheUtil::GetRoundedOutDeviceBounds(context.logical_rect, matrix);
|
||||
|
||||
const SkImageInfo image_info =
|
||||
SkImageInfo::MakeN32Premul(dest_rect.width(), dest_rect.height(),
|
||||
@@ -75,7 +76,7 @@ std::unique_ptr<RasterCacheResult> RasterCache::Rasterize(
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
canvas->translate(-dest_rect.left(), -dest_rect.top());
|
||||
canvas->concat(context.matrix);
|
||||
canvas->concat(matrix);
|
||||
draw_function(canvas);
|
||||
|
||||
if (checkerboard_images_) {
|
||||
@@ -113,8 +114,7 @@ bool RasterCache::UpdateCacheEntry(
|
||||
int RasterCache::MarkSeen(const RasterCacheKeyID& id,
|
||||
const SkMatrix& matrix,
|
||||
bool visible) const {
|
||||
RasterCacheKey key =
|
||||
RasterCacheKey(id, RasterCacheUtil::GetIntegralTransCTM(matrix));
|
||||
RasterCacheKey key = RasterCacheKey(id, matrix);
|
||||
Entry& entry = cache_[key];
|
||||
entry.encountered_this_frame = true;
|
||||
entry.visible_this_frame = visible;
|
||||
@@ -126,8 +126,7 @@ int RasterCache::MarkSeen(const RasterCacheKeyID& id,
|
||||
|
||||
int RasterCache::GetAccessCount(const RasterCacheKeyID& id,
|
||||
const SkMatrix& matrix) const {
|
||||
RasterCacheKey key =
|
||||
RasterCacheKey(id, RasterCacheUtil::GetIntegralTransCTM(matrix));
|
||||
RasterCacheKey key = RasterCacheKey(id, matrix);
|
||||
auto entry = cache_.find(key);
|
||||
if (entry != cache_.cend()) {
|
||||
return entry->second.accesses_since_visible;
|
||||
@@ -137,8 +136,7 @@ int RasterCache::GetAccessCount(const RasterCacheKeyID& id,
|
||||
|
||||
bool RasterCache::HasEntry(const RasterCacheKeyID& id,
|
||||
const SkMatrix& matrix) const {
|
||||
RasterCacheKey key =
|
||||
RasterCacheKey(id, RasterCacheUtil::GetIntegralTransCTM(matrix));
|
||||
RasterCacheKey key = RasterCacheKey(id, matrix);
|
||||
if (cache_.find(key) != cache_.cend()) {
|
||||
return true;
|
||||
}
|
||||
@@ -148,8 +146,7 @@ bool RasterCache::HasEntry(const RasterCacheKeyID& id,
|
||||
bool RasterCache::Draw(const RasterCacheKeyID& id,
|
||||
SkCanvas& canvas,
|
||||
const SkPaint* paint) const {
|
||||
auto it = cache_.find(RasterCacheKey(
|
||||
id, RasterCacheUtil::GetIntegralTransCTM(canvas.getTotalMatrix())));
|
||||
auto it = cache_.find(RasterCacheKey(id, canvas.getTotalMatrix()));
|
||||
if (it == cache_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,6 @@ void MockCacheableContainerLayer::Preroll(PrerollContext* context,
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
|
||||
auto cache = AutoCache(layer_raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
ContainerLayer::Preroll(context, child_matrix);
|
||||
@@ -80,9 +76,6 @@ void MockCacheableLayer::Preroll(PrerollContext* context,
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
SkMatrix child_matrix = matrix;
|
||||
if (context->raster_cache) {
|
||||
child_matrix = RasterCacheUtil::GetIntegralTransCTM(child_matrix);
|
||||
}
|
||||
auto cache = AutoCache(raster_cache_item_.get(), context, child_matrix);
|
||||
|
||||
MockLayer::Preroll(context, child_matrix);
|
||||
|
||||
Reference in New Issue
Block a user