Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont snap in preroll #36239

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions flow/layers/clip_shape_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions flow/layers/color_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 0 additions & 3 deletions flow/layers/display_list_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions flow/layers/image_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions flow/layers/layer_raster_cache_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 0 additions & 3 deletions flow/layers/opacity_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions flow/layers/shader_mask_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
25 changes: 11 additions & 14 deletions flow/raster_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(),
Expand All @@ -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_) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
7 changes: 0 additions & 7 deletions flow/testing/mock_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down