Add DlSamplingOptions & DlFilterMode (flutter/engine#34024)
This commit is contained in:
@@ -100,6 +100,7 @@ FILE: ../../../flutter/display_list/display_list_paint_unittests.cc
|
||||
FILE: ../../../flutter/display_list/display_list_path_effect.cc
|
||||
FILE: ../../../flutter/display_list/display_list_path_effect.h
|
||||
FILE: ../../../flutter/display_list/display_list_path_effect_unittests.cc
|
||||
FILE: ../../../flutter/display_list/display_list_sampling_options.h
|
||||
FILE: ../../../flutter/display_list/display_list_test_utils.cc
|
||||
FILE: ../../../flutter/display_list/display_list_test_utils.h
|
||||
FILE: ../../../flutter/display_list/display_list_tile_mode.h
|
||||
|
||||
@@ -48,6 +48,7 @@ source_set("display_list") {
|
||||
"display_list_paint.h",
|
||||
"display_list_path_effect.cc",
|
||||
"display_list_path_effect.h",
|
||||
"display_list_sampling_options.h",
|
||||
"display_list_tile_mode.h",
|
||||
"display_list_utils.cc",
|
||||
"display_list_utils.h",
|
||||
|
||||
@@ -16,15 +16,6 @@ const SaveLayerOptions SaveLayerOptions::kNoAttributes = SaveLayerOptions();
|
||||
const SaveLayerOptions SaveLayerOptions::kWithAttributes =
|
||||
kNoAttributes.with_renders_with_attributes();
|
||||
|
||||
const SkSamplingOptions DisplayList::NearestSampling =
|
||||
SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone);
|
||||
const SkSamplingOptions DisplayList::LinearSampling =
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone);
|
||||
const SkSamplingOptions DisplayList::MipmapSampling =
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
|
||||
const SkSamplingOptions DisplayList::CubicSampling =
|
||||
SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f});
|
||||
|
||||
DisplayList::DisplayList()
|
||||
: byte_count_(0),
|
||||
op_count_(0),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
@@ -216,11 +217,6 @@ class SaveLayerOptions {
|
||||
// through an instance of DisplayListBuilder::build().
|
||||
class DisplayList : public SkRefCnt {
|
||||
public:
|
||||
static const SkSamplingOptions NearestSampling;
|
||||
static const SkSamplingOptions LinearSampling;
|
||||
static const SkSamplingOptions MipmapSampling;
|
||||
static const SkSamplingOptions CubicSampling;
|
||||
|
||||
DisplayList();
|
||||
|
||||
~DisplayList();
|
||||
|
||||
@@ -939,7 +939,7 @@ sk_sp<SkImage> ImageFromBitmapWithNewID(const SkBitmap& bitmap) {
|
||||
void BM_DrawImage(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkSamplingOptions& options,
|
||||
DlImageSampling options,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
@@ -1017,7 +1017,7 @@ std::string ConstraintToString(SkCanvas::SrcRectConstraint constraint) {
|
||||
void BM_DrawImageRect(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkSamplingOptions& options,
|
||||
DlImageSampling options,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
@@ -1083,11 +1083,11 @@ void BM_DrawImageRect(benchmark::State& state,
|
||||
canvas_provider->Snapshot(filename);
|
||||
}
|
||||
|
||||
std::string FilterModeToString(const SkFilterMode mode) {
|
||||
std::string FilterModeToString(const DlFilterMode mode) {
|
||||
switch (mode) {
|
||||
case SkFilterMode::kNearest:
|
||||
case DlFilterMode::kNearest:
|
||||
return "Nearest";
|
||||
case SkFilterMode::kLinear:
|
||||
case DlFilterMode::kLinear:
|
||||
return "Linear";
|
||||
default:
|
||||
return "Unknown";
|
||||
@@ -1102,7 +1102,7 @@ std::string FilterModeToString(const SkFilterMode mode) {
|
||||
void BM_DrawImageNine(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkFilterMode filter,
|
||||
const DlFilterMode filter,
|
||||
bool upload_bitmap) {
|
||||
auto canvas_provider = CreateCanvasProvider(backend_type);
|
||||
DisplayListBuilder builder;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_H_
|
||||
|
||||
#include "flutter/display_list/display_list_benchmarks_canvas_provider.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_vertices.h"
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark.h"
|
||||
@@ -81,18 +82,18 @@ void BM_DrawVertices(benchmark::State& state,
|
||||
void BM_DrawImage(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkSamplingOptions& options,
|
||||
DlImageSampling options,
|
||||
bool upload_bitmap);
|
||||
void BM_DrawImageRect(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkSamplingOptions& options,
|
||||
DlImageSampling options,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
bool upload_bitmap);
|
||||
void BM_DrawImageNine(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
unsigned attributes,
|
||||
const SkFilterMode filter,
|
||||
const DlFilterMode filter,
|
||||
bool upload_bitmap);
|
||||
void BM_DrawTextBlob(benchmark::State& state,
|
||||
BackendType backend_type,
|
||||
@@ -331,7 +332,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImage, Texture/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), false) \
|
||||
DlImageSampling::kNearestNeighbor, false) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(128, 512) \
|
||||
->UseRealTime() \
|
||||
@@ -340,7 +341,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImage, Upload/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), true) \
|
||||
DlImageSampling::kNearestNeighbor, true) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(128, 512) \
|
||||
->UseRealTime() \
|
||||
@@ -352,7 +353,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BM_DrawImageRect, Texture/Strict/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), \
|
||||
DlImageSampling::kNearestNeighbor, \
|
||||
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, false) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
@@ -363,7 +364,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BM_DrawImageRect, Texture/Fast/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), \
|
||||
DlImageSampling::kNearestNeighbor, \
|
||||
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint, false) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
@@ -374,7 +375,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BM_DrawImageRect, Upload/Strict/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), \
|
||||
DlImageSampling::kNearestNeighbor, \
|
||||
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, true) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
@@ -385,7 +386,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BM_DrawImageRect, Upload/Fast/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkSamplingOptions(), \
|
||||
DlImageSampling::kNearestNeighbor, \
|
||||
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint, true) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
@@ -397,7 +398,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImageNine, Texture/Nearest/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkFilterMode::kNearest, false) \
|
||||
DlFilterMode::kNearest, false) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
->UseRealTime() \
|
||||
@@ -406,7 +407,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImageNine, Upload/Nearest/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkFilterMode::kNearest, true) \
|
||||
DlFilterMode::kNearest, true) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
->UseRealTime() \
|
||||
@@ -415,7 +416,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImageNine, Texture/Linear/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkFilterMode::kLinear, false) \
|
||||
DlFilterMode::kLinear, false) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
->UseRealTime() \
|
||||
@@ -424,7 +425,7 @@ void BM_SaveLayer(benchmark::State& state,
|
||||
BENCHMARK_CAPTURE(BM_DrawImageNine, Upload/Linear/BACKEND, \
|
||||
BackendType::k##BACKEND##_Backend, \
|
||||
ATTRIBUTES, \
|
||||
SkFilterMode::kLinear, true) \
|
||||
DlFilterMode::kLinear, true) \
|
||||
->RangeMultiplier(2) \
|
||||
->Range(32, 256) \
|
||||
->UseRealTime() \
|
||||
|
||||
@@ -852,7 +852,7 @@ void DisplayListBuilder::drawVertices(const DlVertices* vertices,
|
||||
|
||||
void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
render_with_attributes
|
||||
? Push<DrawImageWithAttrOp>(0, 1, std::move(image), point, sampling)
|
||||
@@ -861,7 +861,7 @@ void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
|
||||
}
|
||||
void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const DlPaint* paint) {
|
||||
if (paint != nullptr) {
|
||||
setAttributesFromDlPaint(*paint,
|
||||
@@ -874,7 +874,7 @@ void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
|
||||
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
Push<DrawImageRectOp>(0, 1, std::move(image), src, dst, sampling,
|
||||
@@ -884,7 +884,7 @@ void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
|
||||
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const DlPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
if (paint != nullptr) {
|
||||
@@ -898,7 +898,7 @@ void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
|
||||
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
render_with_attributes
|
||||
? Push<DrawImageNineWithAttrOp>(0, 1, std::move(image), center, dst,
|
||||
@@ -909,7 +909,7 @@ void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
|
||||
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
const DlPaint* paint) {
|
||||
if (paint != nullptr) {
|
||||
setAttributesFromDlPaint(*paint,
|
||||
@@ -922,7 +922,7 @@ void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
|
||||
void DisplayListBuilder::drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
int xDivCount = lattice.fXCount;
|
||||
int yDivCount = lattice.fYCount;
|
||||
@@ -947,7 +947,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) {
|
||||
int bytes = count * (sizeof(SkRSXform) + sizeof(SkRect));
|
||||
@@ -985,7 +985,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
const DlPaint* paint) {
|
||||
if (paint != nullptr) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "flutter/display_list/display_list_image.h"
|
||||
#include "flutter/display_list/display_list_paint.h"
|
||||
#include "flutter/display_list/display_list_path_effect.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
@@ -272,41 +273,41 @@ class DisplayListBuilder final : public virtual Dispatcher,
|
||||
}
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const DlPaint* paint = nullptr);
|
||||
void drawImageRect(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint =
|
||||
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint) override;
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const DlPaint* paint = nullptr,
|
||||
SkCanvas::SrcRectConstraint constraint =
|
||||
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint);
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
const DlPaint* paint = nullptr);
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -314,7 +315,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
bool render_with_attributes) override;
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
@@ -323,7 +324,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
const DlPaint* paint = nullptr);
|
||||
void drawPicture(const sk_sp<SkPicture> picture,
|
||||
|
||||
@@ -191,26 +191,26 @@ void DisplayListCanvasDispatcher::drawVertices(const DlVertices* vertices,
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
canvas_->drawImage(image ? image->skia_image() : nullptr, point.fX, point.fY,
|
||||
sampling, safe_paint(render_with_attributes));
|
||||
ToSk(sampling), safe_paint(render_with_attributes));
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawImageRect(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
canvas_->drawImageRect(image ? image->skia_image() : nullptr, src, dst,
|
||||
sampling, safe_paint(render_with_attributes),
|
||||
ToSk(sampling), safe_paint(render_with_attributes),
|
||||
constraint);
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
if (!image) {
|
||||
return;
|
||||
@@ -219,14 +219,14 @@ void DisplayListCanvasDispatcher::drawImageNine(const sk_sp<DlImage> image,
|
||||
if (!skia_image) {
|
||||
return;
|
||||
}
|
||||
canvas_->drawImageNine(skia_image.get(), center, dst, filter,
|
||||
canvas_->drawImageNine(skia_image.get(), center, dst, ToSk(filter),
|
||||
safe_paint(render_with_attributes));
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawImageLattice(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
if (!image) {
|
||||
return;
|
||||
@@ -235,7 +235,7 @@ void DisplayListCanvasDispatcher::drawImageLattice(
|
||||
if (!skia_image) {
|
||||
return;
|
||||
}
|
||||
canvas_->drawImageLattice(skia_image.get(), lattice, dst, filter,
|
||||
canvas_->drawImageLattice(skia_image.get(), lattice, dst, ToSk(filter),
|
||||
safe_paint(render_with_attributes));
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
@@ -244,7 +244,7 @@ void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
bool render_with_attributes) {
|
||||
if (!atlas) {
|
||||
@@ -256,7 +256,8 @@ void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
}
|
||||
const SkColor* sk_colors = reinterpret_cast<const SkColor*>(colors);
|
||||
canvas_->drawAtlas(skia_atlas.get(), xform, tex, sk_colors, count, ToSk(mode),
|
||||
sampling, cullRect, safe_paint(render_with_attributes));
|
||||
ToSk(sampling), cullRect,
|
||||
safe_paint(render_with_attributes));
|
||||
}
|
||||
void DisplayListCanvasDispatcher::drawPicture(const sk_sp<SkPicture> picture,
|
||||
const SkMatrix* matrix,
|
||||
|
||||
@@ -76,23 +76,23 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -100,7 +100,7 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
bool render_with_attributes) override;
|
||||
void drawPicture(const sk_sp<SkPicture> picture,
|
||||
|
||||
@@ -158,8 +158,8 @@ void DisplayListCanvasRecorder::onDrawImage2(const SkImage* image,
|
||||
if (paint != nullptr) {
|
||||
builder_->setAttributesFromPaint(*paint, kDrawImageWithPaintFlags);
|
||||
}
|
||||
builder_->drawImage(DlImage::Make(image), SkPoint::Make(dx, dy), sampling,
|
||||
paint != nullptr);
|
||||
builder_->drawImage(DlImage::Make(image), SkPoint::Make(dx, dy),
|
||||
ToDl(sampling), paint != nullptr);
|
||||
}
|
||||
void DisplayListCanvasRecorder::onDrawImageRect2(
|
||||
const SkImage* image,
|
||||
@@ -171,7 +171,7 @@ void DisplayListCanvasRecorder::onDrawImageRect2(
|
||||
if (paint != nullptr) {
|
||||
builder_->setAttributesFromPaint(*paint, kDrawImageRectWithPaintFlags);
|
||||
}
|
||||
builder_->drawImageRect(DlImage::Make(image), src, dst, sampling,
|
||||
builder_->drawImageRect(DlImage::Make(image), src, dst, ToDl(sampling),
|
||||
paint != nullptr, constraint);
|
||||
}
|
||||
void DisplayListCanvasRecorder::onDrawImageLattice2(const SkImage* image,
|
||||
@@ -189,7 +189,7 @@ void DisplayListCanvasRecorder::onDrawImageLattice2(const SkImage* image,
|
||||
builder_->setAttributesFromPaint(*paint, kDrawImageLatticeWithPaintFlags);
|
||||
}
|
||||
}
|
||||
builder_->drawImageLattice(DlImage::Make(image), lattice, dst, filter,
|
||||
builder_->drawImageLattice(DlImage::Make(image), lattice, dst, ToDl(filter),
|
||||
paint != nullptr);
|
||||
}
|
||||
void DisplayListCanvasRecorder::onDrawAtlas2(const SkImage* image,
|
||||
@@ -206,7 +206,7 @@ void DisplayListCanvasRecorder::onDrawAtlas2(const SkImage* image,
|
||||
}
|
||||
const DlColor* dl_colors = reinterpret_cast<const DlColor*>(colors);
|
||||
builder_->drawAtlas(DlImage::Make(image), xform, src, dl_colors, count,
|
||||
ToDl(mode), sampling, cull, paint != nullptr);
|
||||
ToDl(mode), ToDl(sampling), cull, paint != nullptr);
|
||||
}
|
||||
|
||||
void DisplayListCanvasRecorder::onDrawTextBlob(const SkTextBlob* blob,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/display_list/display_list_canvas_recorder.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/display_list_flags.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/fml/math.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkPictureRecorder.h"
|
||||
@@ -2218,7 +2219,7 @@ const DlImageColorSource CanvasCompareTester::kTestImageColorSource(
|
||||
kTestImage,
|
||||
DlTileMode::kRepeat,
|
||||
DlTileMode::kRepeat,
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone));
|
||||
DlImageSampling::kLinear);
|
||||
|
||||
// Eventually this bare bones testing::Test fixture will subsume the
|
||||
// CanvasCompareTester and the TestParameters could then become just
|
||||
@@ -2693,12 +2694,12 @@ TEST_F(DisplayListCanvas, DrawImageNearest) {
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImage(CanvasCompareTester::kTestImage, //
|
||||
kRenderLeft, kRenderTop,
|
||||
DisplayList::NearestSampling, &paint);
|
||||
ToSk(DlImageSampling::kNearestNeighbor), &paint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImage(DlImage::Make(CanvasCompareTester::kTestImage),
|
||||
SkPoint::Make(kRenderLeft, kRenderTop),
|
||||
DisplayList::NearestSampling, true);
|
||||
DlImageSampling::kNearestNeighbor, true);
|
||||
},
|
||||
kDrawImageWithPaintFlags));
|
||||
}
|
||||
@@ -2709,12 +2710,12 @@ TEST_F(DisplayListCanvas, DrawImageNearestNoPaint) {
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImage(CanvasCompareTester::kTestImage, //
|
||||
kRenderLeft, kRenderTop,
|
||||
DisplayList::NearestSampling, nullptr);
|
||||
ToSk(DlImageSampling::kNearestNeighbor), nullptr);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImage(DlImage::Make(CanvasCompareTester::kTestImage),
|
||||
SkPoint::Make(kRenderLeft, kRenderTop),
|
||||
DisplayList::NearestSampling, false);
|
||||
DlImageSampling::kNearestNeighbor, false);
|
||||
},
|
||||
kDrawImageFlags));
|
||||
}
|
||||
@@ -2725,12 +2726,12 @@ TEST_F(DisplayListCanvas, DrawImageLinear) {
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImage(CanvasCompareTester::kTestImage, //
|
||||
kRenderLeft, kRenderTop,
|
||||
DisplayList::LinearSampling, &paint);
|
||||
ToSk(DlImageSampling::kLinear), &paint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImage(DlImage::Make(CanvasCompareTester::kTestImage),
|
||||
SkPoint::Make(kRenderLeft, kRenderTop),
|
||||
DisplayList::LinearSampling, true);
|
||||
DlImageSampling::kLinear, true);
|
||||
},
|
||||
kDrawImageWithPaintFlags));
|
||||
}
|
||||
@@ -2742,13 +2743,13 @@ TEST_F(DisplayListCanvas, DrawImageRectNearest) {
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImageRect(CanvasCompareTester::kTestImage, src, dst,
|
||||
DisplayList::NearestSampling, &paint,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
ToSk(DlImageSampling::kNearestNeighbor),
|
||||
&paint, SkCanvas::kFast_SrcRectConstraint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImageRect(
|
||||
DlImage::Make(CanvasCompareTester::kTestImage), src, dst,
|
||||
DisplayList::NearestSampling, true);
|
||||
DlImageSampling::kNearestNeighbor, true);
|
||||
},
|
||||
kDrawImageRectWithPaintFlags));
|
||||
}
|
||||
@@ -2760,13 +2761,13 @@ TEST_F(DisplayListCanvas, DrawImageRectNearestNoPaint) {
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImageRect(CanvasCompareTester::kTestImage, src, dst,
|
||||
DisplayList::NearestSampling, nullptr,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
ToSk(DlImageSampling::kNearestNeighbor),
|
||||
nullptr, SkCanvas::kFast_SrcRectConstraint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImageRect(
|
||||
DlImage::Make(CanvasCompareTester::kTestImage), src, dst,
|
||||
DisplayList::NearestSampling, false);
|
||||
DlImageSampling::kNearestNeighbor, false);
|
||||
},
|
||||
kDrawImageRectFlags));
|
||||
}
|
||||
@@ -2778,13 +2779,13 @@ TEST_F(DisplayListCanvas, DrawImageRectLinear) {
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
canvas->drawImageRect(CanvasCompareTester::kTestImage, src, dst,
|
||||
DisplayList::LinearSampling, &paint,
|
||||
ToSk(DlImageSampling::kLinear), &paint,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawImageRect(
|
||||
DlImage::Make(CanvasCompareTester::kTestImage), src, dst,
|
||||
DisplayList::LinearSampling, true);
|
||||
DlImageSampling::kLinear, true);
|
||||
},
|
||||
kDrawImageRectWithPaintFlags));
|
||||
}
|
||||
@@ -2801,7 +2802,7 @@ TEST_F(DisplayListCanvas, DrawImageNineNearest) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageNine(DlImage::Make(image), src, dst,
|
||||
SkFilterMode::kNearest, true);
|
||||
DlFilterMode::kNearest, true);
|
||||
},
|
||||
kDrawImageNineWithPaintFlags));
|
||||
}
|
||||
@@ -2818,7 +2819,7 @@ TEST_F(DisplayListCanvas, DrawImageNineNearestNoPaint) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageNine(DlImage::Make(image), src, dst,
|
||||
SkFilterMode::kNearest, false);
|
||||
DlFilterMode::kNearest, false);
|
||||
},
|
||||
kDrawImageNineFlags));
|
||||
}
|
||||
@@ -2835,7 +2836,7 @@ TEST_F(DisplayListCanvas, DrawImageNineLinear) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageNine(DlImage::Make(image), src, dst,
|
||||
SkFilterMode::kLinear, true);
|
||||
DlFilterMode::kLinear, true);
|
||||
},
|
||||
kDrawImageNineWithPaintFlags));
|
||||
}
|
||||
@@ -2864,7 +2865,7 @@ TEST_F(DisplayListCanvas, DrawImageLatticeNearest) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
|
||||
SkFilterMode::kNearest, true);
|
||||
DlFilterMode::kNearest, true);
|
||||
},
|
||||
kDrawImageLatticeWithPaintFlags));
|
||||
}
|
||||
@@ -2893,7 +2894,7 @@ TEST_F(DisplayListCanvas, DrawImageLatticeNearestNoPaint) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
|
||||
SkFilterMode::kNearest, false);
|
||||
DlFilterMode::kNearest, false);
|
||||
},
|
||||
kDrawImageLatticeFlags));
|
||||
}
|
||||
@@ -2922,7 +2923,7 @@ TEST_F(DisplayListCanvas, DrawImageLatticeLinear) {
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
|
||||
SkFilterMode::kLinear, true);
|
||||
DlFilterMode::kLinear, true);
|
||||
},
|
||||
kDrawImageLatticeWithPaintFlags));
|
||||
}
|
||||
@@ -2951,13 +2952,14 @@ TEST_F(DisplayListCanvas, DrawAtlasNearest) {
|
||||
SK_ColorMAGENTA,
|
||||
};
|
||||
const sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
|
||||
const SkSamplingOptions sampling = DisplayList::NearestSampling;
|
||||
const DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) {
|
||||
const SkColor* sk_colors = reinterpret_cast<const SkColor*>(colors);
|
||||
canvas->drawAtlas(image.get(), xform, tex, sk_colors, 4,
|
||||
SkBlendMode::kSrcOver, sampling, nullptr, &paint);
|
||||
SkBlendMode::kSrcOver, ToSk(sampling), nullptr,
|
||||
&paint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
const DlColor* dl_colors = reinterpret_cast<const DlColor*>(colors);
|
||||
@@ -2992,13 +2994,13 @@ TEST_F(DisplayListCanvas, DrawAtlasNearestNoPaint) {
|
||||
SK_ColorMAGENTA,
|
||||
};
|
||||
const sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
|
||||
const SkSamplingOptions sampling = DisplayList::NearestSampling;
|
||||
const DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) {
|
||||
const SkColor* sk_colors = reinterpret_cast<const SkColor*>(colors);
|
||||
canvas->drawAtlas(image.get(), xform, tex, sk_colors, 4,
|
||||
SkBlendMode::kSrcOver, sampling, //
|
||||
SkBlendMode::kSrcOver, ToSk(sampling), //
|
||||
nullptr, nullptr);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
@@ -3035,13 +3037,14 @@ TEST_F(DisplayListCanvas, DrawAtlasLinear) {
|
||||
SK_ColorMAGENTA,
|
||||
};
|
||||
const sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
|
||||
const SkSamplingOptions sampling = DisplayList::LinearSampling;
|
||||
const DlImageSampling sampling = DlImageSampling::kLinear;
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) {
|
||||
const SkColor* sk_colors = reinterpret_cast<const SkColor*>(colors);
|
||||
canvas->drawAtlas(image.get(), xform, tex, sk_colors, 2, //
|
||||
SkBlendMode::kSrcOver, sampling, nullptr, &paint);
|
||||
SkBlendMode::kSrcOver, ToSk(sampling), nullptr,
|
||||
&paint);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) {
|
||||
const DlColor* dl_colors = reinterpret_cast<const DlColor*>(colors);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_color_source.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -16,8 +17,8 @@ std::shared_ptr<DlColorSource> DlColorSource::From(SkShader* sk_shader) {
|
||||
SkImage* image = sk_shader->isAImage(&local_matrix, xy);
|
||||
if (image) {
|
||||
return std::make_shared<DlImageColorSource>(
|
||||
sk_ref_sp(image), ToDl(xy[0]), ToDl(xy[1]),
|
||||
DisplayList::LinearSampling, &local_matrix);
|
||||
sk_ref_sp(image), ToDl(xy[0]), ToDl(xy[1]), DlImageSampling::kLinear,
|
||||
&local_matrix);
|
||||
}
|
||||
}
|
||||
// Skia provides |SkShader->asAGradient(&info)| method to access the
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_attributes.h"
|
||||
#include "flutter/display_list/display_list_color.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_tile_mode.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
@@ -105,7 +106,7 @@ class DlColorSource
|
||||
virtual bool is_opaque() const = 0;
|
||||
|
||||
virtual std::shared_ptr<DlColorSource> with_sampling(
|
||||
const SkSamplingOptions& options) const {
|
||||
DlImageSampling options) const {
|
||||
return shared();
|
||||
}
|
||||
|
||||
@@ -204,7 +205,7 @@ class DlImageColorSource final : public SkRefCnt,
|
||||
DlImageColorSource(sk_sp<const SkImage> image,
|
||||
DlTileMode horizontal_tile_mode,
|
||||
DlTileMode vertical_tile_mode,
|
||||
SkSamplingOptions sampling = DisplayList::LinearSampling,
|
||||
DlImageSampling sampling = DlImageSampling::kLinear,
|
||||
const SkMatrix* matrix = nullptr)
|
||||
: DlMatrixColorSourceBase(matrix),
|
||||
sk_image_(image),
|
||||
@@ -219,7 +220,7 @@ class DlImageColorSource final : public SkRefCnt,
|
||||
}
|
||||
|
||||
std::shared_ptr<DlColorSource> with_sampling(
|
||||
const SkSamplingOptions& sampling) const override {
|
||||
DlImageSampling sampling) const override {
|
||||
return std::make_shared<DlImageColorSource>(
|
||||
sk_image_, horizontal_tile_mode_, vertical_tile_mode_, sampling,
|
||||
matrix_ptr());
|
||||
@@ -233,11 +234,11 @@ class DlImageColorSource final : public SkRefCnt,
|
||||
sk_sp<const SkImage> image() const { return sk_image_; }
|
||||
DlTileMode horizontal_tile_mode() const { return horizontal_tile_mode_; }
|
||||
DlTileMode vertical_tile_mode() const { return vertical_tile_mode_; }
|
||||
SkSamplingOptions sampling() const { return sampling_; }
|
||||
DlImageSampling sampling() const { return sampling_; }
|
||||
|
||||
virtual sk_sp<SkShader> skia_object() const override {
|
||||
return sk_image_->makeShader(ToSk(horizontal_tile_mode_),
|
||||
ToSk(vertical_tile_mode_), sampling_,
|
||||
ToSk(vertical_tile_mode_), ToSk(sampling_),
|
||||
matrix_ptr());
|
||||
}
|
||||
|
||||
@@ -255,7 +256,7 @@ class DlImageColorSource final : public SkRefCnt,
|
||||
sk_sp<const SkImage> sk_image_;
|
||||
DlTileMode horizontal_tile_mode_;
|
||||
DlTileMode vertical_tile_mode_;
|
||||
SkSamplingOptions sampling_;
|
||||
DlImageSampling sampling_;
|
||||
|
||||
FML_DISALLOW_COPY_ASSIGN_AND_MOVE(DlImageColorSource);
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "flutter/display_list/display_list_attributes_testing.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_color_source.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
@@ -76,7 +77,7 @@ static const sk_sp<SkShader> kTestAlphaUnknownShader =
|
||||
|
||||
TEST(DisplayListColorSource, BuilderSetGet) {
|
||||
DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
|
||||
DisplayList::LinearSampling, &kTestMatrix1);
|
||||
DlImageSampling::kLinear, &kTestMatrix1);
|
||||
DisplayListBuilder builder;
|
||||
ASSERT_EQ(builder.getColorSource(), nullptr);
|
||||
builder.setColorSource(&source);
|
||||
@@ -117,10 +118,10 @@ TEST(DisplayListColorSource, FromSkiaColorShader) {
|
||||
|
||||
TEST(DisplayListColorSource, FromSkiaImageShader) {
|
||||
sk_sp<SkShader> shader =
|
||||
kTestImage1->makeShader(DisplayList::LinearSampling, &kTestMatrix1);
|
||||
kTestImage1->makeShader(ToSk(DlImageSampling::kLinear), &kTestMatrix1);
|
||||
std::shared_ptr<DlColorSource> source = DlColorSource::From(shader);
|
||||
DlImageColorSource dl_source(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kClamp, DisplayList::LinearSampling,
|
||||
DlTileMode::kClamp, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
ASSERT_EQ(source->type(), DlColorSourceType::kImage);
|
||||
ASSERT_EQ(*source->asImage(), dl_source);
|
||||
@@ -128,7 +129,7 @@ TEST(DisplayListColorSource, FromSkiaImageShader) {
|
||||
ASSERT_EQ(source->asImage()->matrix(), kTestMatrix1);
|
||||
ASSERT_EQ(source->asImage()->horizontal_tile_mode(), DlTileMode::kClamp);
|
||||
ASSERT_EQ(source->asImage()->vertical_tile_mode(), DlTileMode::kClamp);
|
||||
ASSERT_EQ(source->asImage()->sampling(), DisplayList::LinearSampling);
|
||||
ASSERT_EQ(source->asImage()->sampling(), DlImageSampling::kLinear);
|
||||
|
||||
ASSERT_EQ(source->asColor(), nullptr);
|
||||
ASSERT_EQ(source->asLinearGradient(), nullptr);
|
||||
@@ -278,19 +279,19 @@ TEST(DisplayListColorSource, ColorNotEquals) {
|
||||
|
||||
TEST(DisplayListColorSource, ImageConstructor) {
|
||||
DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
|
||||
DisplayList::LinearSampling, &kTestMatrix1);
|
||||
DlImageSampling::kLinear, &kTestMatrix1);
|
||||
}
|
||||
|
||||
TEST(DisplayListColorSource, ImageShared) {
|
||||
DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
|
||||
DisplayList::LinearSampling, &kTestMatrix1);
|
||||
DlImageSampling::kLinear, &kTestMatrix1);
|
||||
ASSERT_NE(source.shared().get(), &source);
|
||||
ASSERT_EQ(*source.shared(), source);
|
||||
}
|
||||
|
||||
TEST(DisplayListColorSource, ImageAsImage) {
|
||||
DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
|
||||
DisplayList::LinearSampling, &kTestMatrix1);
|
||||
DlImageSampling::kLinear, &kTestMatrix1);
|
||||
ASSERT_NE(source.asImage(), nullptr);
|
||||
ASSERT_EQ(source.asImage(), &source);
|
||||
|
||||
@@ -303,69 +304,69 @@ TEST(DisplayListColorSource, ImageAsImage) {
|
||||
|
||||
TEST(DisplayListColorSource, ImageContents) {
|
||||
DlImageColorSource source(kTestImage1, DlTileMode::kRepeat,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
ASSERT_EQ(source.image(), kTestImage1);
|
||||
ASSERT_EQ(source.horizontal_tile_mode(), DlTileMode::kRepeat);
|
||||
ASSERT_EQ(source.vertical_tile_mode(), DlTileMode::kMirror);
|
||||
ASSERT_EQ(source.sampling(), DisplayList::LinearSampling);
|
||||
ASSERT_EQ(source.sampling(), DlImageSampling::kLinear);
|
||||
ASSERT_EQ(source.matrix(), kTestMatrix1);
|
||||
ASSERT_EQ(source.is_opaque(), true);
|
||||
}
|
||||
|
||||
TEST(DisplayListColorSource, AlphaImageContents) {
|
||||
DlImageColorSource source(kTestAlphaImage1, DlTileMode::kRepeat,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
ASSERT_EQ(source.image(), kTestAlphaImage1);
|
||||
ASSERT_EQ(source.horizontal_tile_mode(), DlTileMode::kRepeat);
|
||||
ASSERT_EQ(source.vertical_tile_mode(), DlTileMode::kMirror);
|
||||
ASSERT_EQ(source.sampling(), DisplayList::LinearSampling);
|
||||
ASSERT_EQ(source.sampling(), DlImageSampling::kLinear);
|
||||
ASSERT_EQ(source.matrix(), kTestMatrix1);
|
||||
ASSERT_EQ(source.is_opaque(), false);
|
||||
}
|
||||
|
||||
TEST(DisplayListColorSource, ImageEquals) {
|
||||
DlImageColorSource source1(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
TestEquals(source1, source2);
|
||||
}
|
||||
|
||||
TEST(DisplayListColorSource, ImageNotEquals) {
|
||||
DlImageColorSource source1(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
{
|
||||
DlImageColorSource source2(kTestAlphaImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
TestNotEquals(source1, source2, "Image differs");
|
||||
}
|
||||
{
|
||||
DlImageColorSource source2(kTestImage1, DlTileMode::kRepeat,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
TestNotEquals(source1, source2, "hTileMode differs");
|
||||
}
|
||||
{
|
||||
DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kRepeat, DisplayList::LinearSampling,
|
||||
DlTileMode::kRepeat, DlImageSampling::kLinear,
|
||||
&kTestMatrix1);
|
||||
TestNotEquals(source1, source2, "vTileMode differs");
|
||||
}
|
||||
{
|
||||
DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::CubicSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kCubic,
|
||||
&kTestMatrix1);
|
||||
TestNotEquals(source1, source2, "Sampling differs");
|
||||
}
|
||||
{
|
||||
DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
|
||||
DlTileMode::kMirror, DisplayList::LinearSampling,
|
||||
DlTileMode::kMirror, DlImageSampling::kLinear,
|
||||
&kTestMatrix2);
|
||||
TestNotEquals(source1, source2, "Matrix differs");
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ void DisplayListGLComplexityCalculator::GLHelper::drawVertices(
|
||||
void DisplayListGLComplexityCalculator::GLHelper::drawImage(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
if (IsComplex()) {
|
||||
return;
|
||||
@@ -616,7 +616,7 @@ void DisplayListGLComplexityCalculator::GLHelper::drawImageNine(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
if (IsComplex()) {
|
||||
return;
|
||||
|
||||
@@ -59,12 +59,12 @@ class DisplayListGLComplexityCalculator
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
|
||||
void drawTextBlob(const sk_sp<SkTextBlob> blob,
|
||||
|
||||
@@ -149,7 +149,7 @@ class ComplexityCalculatorHelper
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override {
|
||||
if (IsComplex()) {
|
||||
@@ -162,7 +162,7 @@ class ComplexityCalculatorHelper
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override {
|
||||
if (IsComplex()) {
|
||||
return;
|
||||
@@ -181,7 +181,7 @@ class ComplexityCalculatorHelper
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) override {
|
||||
if (IsComplex()) {
|
||||
|
||||
@@ -485,7 +485,7 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawVertices(
|
||||
void DisplayListMetalComplexityCalculator::MetalHelper::drawImage(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
if (IsComplex()) {
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawImageNine(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
if (IsComplex()) {
|
||||
return;
|
||||
|
||||
@@ -60,12 +60,12 @@ class DisplayListMetalComplexityCalculator
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
|
||||
void drawTextBlob(const sk_sp<SkTextBlob> blob,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/display_list/display_list_complexity.h"
|
||||
#include "flutter/display_list/display_list_complexity_gl.h"
|
||||
#include "flutter/display_list/display_list_complexity_metal.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_test_utils.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
@@ -351,7 +352,7 @@ TEST(DisplayListComplexity, DrawImage) {
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.drawImage(DlImage::Make(image), SkPoint::Make(0, 0),
|
||||
SkSamplingOptions(), false);
|
||||
DlImageSampling::kNearestNeighbor, false);
|
||||
auto display_list = builder.Build();
|
||||
|
||||
auto calculators = AccumulatorCalculators();
|
||||
@@ -373,7 +374,7 @@ TEST(DisplayListComplexity, DrawImageNine) {
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.drawImageNine(DlImage::Make(image), center, dest,
|
||||
SkFilterMode::kNearest, true);
|
||||
DlFilterMode::kNearest, true);
|
||||
auto display_list = builder.Build();
|
||||
|
||||
auto calculators = AccumulatorCalculators();
|
||||
@@ -394,8 +395,8 @@ TEST(DisplayListComplexity, DrawImageRect) {
|
||||
SkRect dest = SkRect::MakeXYWH(0, 0, 50, 50);
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.drawImageRect(DlImage::Make(image), src, dest, SkSamplingOptions(),
|
||||
true);
|
||||
builder.drawImageRect(DlImage::Make(image), src, dest,
|
||||
DlImageSampling::kNearestNeighbor, true);
|
||||
auto display_list = builder.Build();
|
||||
|
||||
auto calculators = AccumulatorCalculators();
|
||||
@@ -421,7 +422,8 @@ TEST(DisplayListComplexity, DrawAtlas) {
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.drawAtlas(DlImage::Make(image), xforms.data(), rects.data(), nullptr,
|
||||
10, DlBlendMode::kSrc, SkSamplingOptions(), nullptr, true);
|
||||
10, DlBlendMode::kSrc, DlImageSampling::kNearestNeighbor,
|
||||
nullptr, true);
|
||||
auto display_list = builder.Build();
|
||||
|
||||
auto calculators = AccumulatorCalculators();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "flutter/display_list/display_list_mask_filter.h"
|
||||
#include "flutter/display_list/display_list_paint.h"
|
||||
#include "flutter/display_list/display_list_path_effect.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_vertices.h"
|
||||
|
||||
namespace flutter {
|
||||
@@ -216,23 +217,23 @@ class Dispatcher {
|
||||
virtual void drawVertices(const DlVertices* vertices, DlBlendMode mode) = 0;
|
||||
virtual void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) = 0;
|
||||
virtual void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) = 0;
|
||||
virtual void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) = 0;
|
||||
virtual void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) = 0;
|
||||
virtual void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -240,7 +241,7 @@ class Dispatcher {
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) = 0;
|
||||
virtual void drawPicture(const sk_sp<SkPicture> picture,
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
|
||||
#include "flutter/display_list/display_list_blend_mode.h"
|
||||
#include "flutter/display_list/display_list_paint.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_tile_mode.h"
|
||||
#include "flutter/display_list/display_list_vertices.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "include/core/SkSamplingOptions.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
@@ -82,6 +84,42 @@ TEST(DisplayListEnum, ToSkVertexMode) {
|
||||
SkVertices::VertexMode::kTriangleFan_VertexMode);
|
||||
}
|
||||
|
||||
TEST(DisplayListEnum, ToDlFilterMode) {
|
||||
ASSERT_EQ(ToDl(SkFilterMode::kLinear), DlFilterMode::kLinear);
|
||||
ASSERT_EQ(ToDl(SkFilterMode::kNearest), DlFilterMode::kNearest);
|
||||
ASSERT_EQ(ToDl(SkFilterMode::kLast), DlFilterMode::kLast);
|
||||
}
|
||||
|
||||
TEST(DisplayListEnum, ToSkFilterMode) {
|
||||
ASSERT_EQ(ToSk(DlFilterMode::kLinear), SkFilterMode::kLinear);
|
||||
ASSERT_EQ(ToSk(DlFilterMode::kNearest), SkFilterMode::kNearest);
|
||||
ASSERT_EQ(ToSk(DlFilterMode::kLast), SkFilterMode::kLast);
|
||||
}
|
||||
|
||||
TEST(DisplayListEnum, ToDlImageSampling) {
|
||||
ASSERT_EQ(ToDl(SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone)),
|
||||
DlImageSampling::kLinear);
|
||||
ASSERT_EQ(
|
||||
ToDl(SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear)),
|
||||
DlImageSampling::kMipmapLinear);
|
||||
ASSERT_EQ(
|
||||
ToDl(SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone)),
|
||||
DlImageSampling::kNearestNeighbor);
|
||||
ASSERT_EQ(ToDl(SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f})),
|
||||
DlImageSampling::kCubic);
|
||||
}
|
||||
|
||||
TEST(DisplayListEnum, ToSkSamplingOptions) {
|
||||
ASSERT_EQ(ToSk(DlImageSampling::kLinear),
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone));
|
||||
ASSERT_EQ(ToSk(DlImageSampling::kMipmapLinear),
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear));
|
||||
ASSERT_EQ(ToSk(DlImageSampling::kNearestNeighbor),
|
||||
SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone));
|
||||
ASSERT_EQ(ToSk(DlImageSampling::kCubic),
|
||||
SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f}));
|
||||
}
|
||||
|
||||
#define CHECK_TO_DLENUM(V) ASSERT_EQ(ToDl(SkBlendMode::V), DlBlendMode::V);
|
||||
#define CHECK_TO_SKENUM(V) ASSERT_EQ(ToSk(DlBlendMode::V), SkBlendMode::V);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "flutter/display_list/display_list_attributes.h"
|
||||
#include "flutter/display_list/display_list_color_filter.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/display_list_tile_mode.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
@@ -309,7 +310,7 @@ class DlErodeImageFilter final : public DlImageFilter {
|
||||
|
||||
class DlMatrixImageFilter final : public DlImageFilter {
|
||||
public:
|
||||
DlMatrixImageFilter(const SkMatrix& matrix, const SkSamplingOptions& sampling)
|
||||
DlMatrixImageFilter(const SkMatrix& matrix, DlImageSampling sampling)
|
||||
: matrix_(matrix), sampling_(sampling) {}
|
||||
explicit DlMatrixImageFilter(const DlMatrixImageFilter* filter)
|
||||
: DlMatrixImageFilter(filter->matrix_, filter->sampling_) {}
|
||||
@@ -324,7 +325,7 @@ class DlMatrixImageFilter final : public DlImageFilter {
|
||||
size_t size() const override { return sizeof(*this); }
|
||||
|
||||
const SkMatrix& matrix() const { return matrix_; }
|
||||
const SkSamplingOptions& sampling() const { return sampling_; }
|
||||
DlImageSampling sampling() const { return sampling_; }
|
||||
|
||||
const DlMatrixImageFilter* asMatrix() const override { return this; }
|
||||
|
||||
@@ -353,7 +354,7 @@ class DlMatrixImageFilter final : public DlImageFilter {
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> skia_object() const override {
|
||||
return SkImageFilters::MatrixTransform(matrix_, sampling_, nullptr);
|
||||
return SkImageFilters::MatrixTransform(matrix_, ToSk(sampling_), nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -365,7 +366,7 @@ class DlMatrixImageFilter final : public DlImageFilter {
|
||||
|
||||
private:
|
||||
SkMatrix matrix_;
|
||||
SkSamplingOptions sampling_;
|
||||
DlImageSampling sampling_;
|
||||
};
|
||||
|
||||
class DlComposeImageFilter final : public DlImageFilter {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_comparable.h"
|
||||
#include "flutter/display_list/display_list_image_filter.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -84,7 +85,7 @@ TEST(DisplayListImageFilter, FromSkiaErodeImageFilter) {
|
||||
|
||||
TEST(DisplayListImageFilter, FromSkiaMatrixImageFilter) {
|
||||
sk_sp<SkImageFilter> sk_image_filter = SkImageFilters::MatrixTransform(
|
||||
SkMatrix::RotateDeg(45), DisplayList::LinearSampling, nullptr);
|
||||
SkMatrix::RotateDeg(45), ToSk(DlImageSampling::kLinear), nullptr);
|
||||
std::shared_ptr<DlImageFilter> filter = DlImageFilter::From(sk_image_filter);
|
||||
|
||||
ASSERT_EQ(filter->type(), DlImageFilterType::kUnknown);
|
||||
@@ -102,7 +103,7 @@ TEST(DisplayListImageFilter, FromSkiaComposeImageFilter) {
|
||||
sk_sp<SkImageFilter> sk_blur_filter =
|
||||
SkImageFilters::Blur(5.0, 5.0, SkTileMode::kRepeat, nullptr);
|
||||
sk_sp<SkImageFilter> sk_matrix_filter = SkImageFilters::MatrixTransform(
|
||||
SkMatrix::RotateDeg(45), DisplayList::LinearSampling, nullptr);
|
||||
SkMatrix::RotateDeg(45), ToSk(DlImageSampling::kLinear), nullptr);
|
||||
sk_sp<SkImageFilter> sk_image_filter =
|
||||
SkImageFilters::Compose(sk_blur_filter, sk_matrix_filter);
|
||||
std::shared_ptr<DlImageFilter> filter = DlImageFilter::From(sk_image_filter);
|
||||
@@ -271,14 +272,14 @@ TEST(DisplayListImageFilter, MatrixConstructor) {
|
||||
DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
}
|
||||
|
||||
TEST(DisplayListImageFilter, MatrixShared) {
|
||||
DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
|
||||
ASSERT_NE(filter.shared().get(), &filter);
|
||||
ASSERT_EQ(*filter.shared(), filter);
|
||||
@@ -288,7 +289,7 @@ TEST(DisplayListImageFilter, MatrixAsMatrix) {
|
||||
DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
|
||||
ASSERT_NE(filter.asMatrix(), nullptr);
|
||||
ASSERT_EQ(filter.asMatrix(), &filter);
|
||||
@@ -298,18 +299,18 @@ TEST(DisplayListImageFilter, MatrixContents) {
|
||||
SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1);
|
||||
DlMatrixImageFilter filter(matrix, DisplayList::LinearSampling);
|
||||
DlMatrixImageFilter filter(matrix, DlImageSampling::kLinear);
|
||||
|
||||
ASSERT_EQ(filter.matrix(), matrix);
|
||||
ASSERT_EQ(filter.sampling(), DisplayList::LinearSampling);
|
||||
ASSERT_EQ(filter.sampling(), DlImageSampling::kLinear);
|
||||
}
|
||||
|
||||
TEST(DisplayListImageFilter, MatrixEquals) {
|
||||
SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1);
|
||||
DlMatrixImageFilter filter1(matrix, DisplayList::LinearSampling);
|
||||
DlMatrixImageFilter filter2(matrix, DisplayList::LinearSampling);
|
||||
DlMatrixImageFilter filter1(matrix, DlImageSampling::kLinear);
|
||||
DlMatrixImageFilter filter2(matrix, DlImageSampling::kLinear);
|
||||
|
||||
TestEquals(filter1, filter2);
|
||||
}
|
||||
@@ -321,9 +322,9 @@ TEST(DisplayListImageFilter, MatrixNotEquals) {
|
||||
SkMatrix matrix2 = SkMatrix::MakeAll(5.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1);
|
||||
DlMatrixImageFilter filter1(matrix1, DisplayList::LinearSampling);
|
||||
DlMatrixImageFilter filter2(matrix2, DisplayList::LinearSampling);
|
||||
DlMatrixImageFilter filter3(matrix1, DisplayList::NearestSampling);
|
||||
DlMatrixImageFilter filter1(matrix1, DlImageSampling::kLinear);
|
||||
DlMatrixImageFilter filter2(matrix2, DlImageSampling::kLinear);
|
||||
DlMatrixImageFilter filter3(matrix1, DlImageSampling::kNearestNeighbor);
|
||||
|
||||
TestNotEquals(filter1, filter2, "Matrix differs");
|
||||
TestNotEquals(filter1, filter3, "Sampling differs");
|
||||
@@ -333,7 +334,7 @@ TEST(DisplayListImageFilter, ComposeConstructor) {
|
||||
DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter(outer, inner);
|
||||
}
|
||||
@@ -342,7 +343,7 @@ TEST(DisplayListImageFilter, ComposeShared) {
|
||||
DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter(outer, inner);
|
||||
|
||||
@@ -354,7 +355,7 @@ TEST(DisplayListImageFilter, ComposeAsCompose) {
|
||||
DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter(outer, inner);
|
||||
|
||||
@@ -366,7 +367,7 @@ TEST(DisplayListImageFilter, ComposeContents) {
|
||||
DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter(outer, inner);
|
||||
|
||||
@@ -378,14 +379,14 @@ TEST(DisplayListImageFilter, ComposeEquals) {
|
||||
DlMatrixImageFilter outer1(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner1(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter1(outer1, inner1);
|
||||
|
||||
DlMatrixImageFilter outer2(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner2(5.0, 6.0, DlTileMode::kMirror);
|
||||
DlComposeImageFilter filter2(outer1, inner1);
|
||||
|
||||
@@ -396,13 +397,13 @@ TEST(DisplayListImageFilter, ComposeNotEquals) {
|
||||
DlMatrixImageFilter outer1(SkMatrix::MakeAll(2.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner1(5.0, 6.0, DlTileMode::kMirror);
|
||||
|
||||
DlMatrixImageFilter outer2(SkMatrix::MakeAll(5.0, 0.0, 10, //
|
||||
0.5, 3.0, 15, //
|
||||
0.0, 0.0, 1),
|
||||
DisplayList::LinearSampling);
|
||||
DlImageSampling::kLinear);
|
||||
DlBlurImageFilter inner2(7.0, 6.0, DlTileMode::kMirror);
|
||||
|
||||
DlComposeImageFilter filter1(outer1, inner1);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_blend_mode.h"
|
||||
#include "flutter/display_list/display_list_dispatcher.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/display_list/types.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
@@ -681,11 +682,11 @@ struct DrawSkVerticesOp final : DLOp {
|
||||
\
|
||||
name##Op(const sk_sp<DlImage> image, \
|
||||
const SkPoint& point, \
|
||||
const SkSamplingOptions& sampling) \
|
||||
DlImageSampling sampling) \
|
||||
: point(point), sampling(sampling), image(std::move(image)) {} \
|
||||
\
|
||||
const SkPoint point; \
|
||||
const SkSamplingOptions sampling; \
|
||||
const DlImageSampling sampling; \
|
||||
const sk_sp<DlImage> image; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
@@ -704,7 +705,7 @@ struct DrawImageRectOp final : DLOp {
|
||||
DrawImageRectOp(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint)
|
||||
: src(src),
|
||||
@@ -716,7 +717,7 @@ struct DrawImageRectOp final : DLOp {
|
||||
|
||||
const SkRect src;
|
||||
const SkRect dst;
|
||||
const SkSamplingOptions sampling;
|
||||
const DlImageSampling sampling;
|
||||
const bool render_with_attributes;
|
||||
const SkCanvas::SrcRectConstraint constraint;
|
||||
const sk_sp<DlImage> image;
|
||||
@@ -735,12 +736,12 @@ struct DrawImageRectOp final : DLOp {
|
||||
name##Op(const sk_sp<DlImage> image, \
|
||||
const SkIRect& center, \
|
||||
const SkRect& dst, \
|
||||
SkFilterMode filter) \
|
||||
DlFilterMode filter) \
|
||||
: center(center), dst(dst), filter(filter), image(std::move(image)) {} \
|
||||
\
|
||||
const SkIRect center; \
|
||||
const SkRect dst; \
|
||||
const SkFilterMode filter; \
|
||||
const DlFilterMode filter; \
|
||||
const sk_sp<DlImage> image; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
@@ -762,7 +763,7 @@ struct DrawImageLatticeOp final : DLOp {
|
||||
int cell_count,
|
||||
const SkIRect& src,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool with_paint)
|
||||
: with_paint(with_paint),
|
||||
x_count(x_count),
|
||||
@@ -777,7 +778,7 @@ struct DrawImageLatticeOp final : DLOp {
|
||||
const int x_count;
|
||||
const int y_count;
|
||||
const int cell_count;
|
||||
const SkFilterMode filter;
|
||||
const DlFilterMode filter;
|
||||
const SkIRect src;
|
||||
const SkRect dst;
|
||||
const sk_sp<DlImage> image;
|
||||
@@ -810,7 +811,7 @@ struct DrawAtlasBaseOp : DLOp {
|
||||
DrawAtlasBaseOp(const sk_sp<DlImage> atlas,
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool has_colors,
|
||||
bool render_with_attributes)
|
||||
: count(count),
|
||||
@@ -824,7 +825,7 @@ struct DrawAtlasBaseOp : DLOp {
|
||||
const uint16_t mode_index;
|
||||
const uint8_t has_colors;
|
||||
const uint8_t render_with_attributes;
|
||||
const SkSamplingOptions sampling;
|
||||
const DlImageSampling sampling;
|
||||
const sk_sp<DlImage> atlas;
|
||||
};
|
||||
|
||||
@@ -836,7 +837,7 @@ struct DrawAtlasOp final : DrawAtlasBaseOp {
|
||||
DrawAtlasOp(const sk_sp<DlImage> atlas,
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool has_colors,
|
||||
bool render_with_attributes)
|
||||
: DrawAtlasBaseOp(atlas,
|
||||
@@ -867,7 +868,7 @@ struct DrawAtlasCulledOp final : DrawAtlasBaseOp {
|
||||
DrawAtlasCulledOp(const sk_sp<DlImage> atlas,
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool has_colors,
|
||||
const SkRect& cull_rect,
|
||||
bool render_with_attributes)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright 2013 The Flutter 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 FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_
|
||||
#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_
|
||||
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkSamplingOptions.h"
|
||||
namespace flutter {
|
||||
|
||||
enum class DlFilterMode {
|
||||
kNearest, // single sample point (nearest neighbor)
|
||||
kLinear, // interporate between 2x2 sample points (bilinear interpolation)
|
||||
|
||||
kLast = kLinear,
|
||||
};
|
||||
|
||||
inline DlFilterMode ToDl(const SkFilterMode filter_mode) {
|
||||
return static_cast<DlFilterMode>(filter_mode);
|
||||
}
|
||||
|
||||
inline SkFilterMode ToSk(const DlFilterMode filter_mode) {
|
||||
return static_cast<SkFilterMode>(filter_mode);
|
||||
}
|
||||
|
||||
enum class DlImageSampling {
|
||||
kNearestNeighbor,
|
||||
kLinear,
|
||||
kMipmapLinear,
|
||||
kCubic,
|
||||
};
|
||||
|
||||
inline DlImageSampling ToDl(const SkSamplingOptions& so) {
|
||||
if (so.useCubic) {
|
||||
return DlImageSampling::kCubic;
|
||||
}
|
||||
if (so.filter == SkFilterMode::kLinear) {
|
||||
if (so.mipmap == SkMipmapMode::kNone) {
|
||||
return DlImageSampling::kLinear;
|
||||
}
|
||||
if (so.mipmap == SkMipmapMode::kLinear) {
|
||||
return DlImageSampling::kMipmapLinear;
|
||||
}
|
||||
}
|
||||
return DlImageSampling::kNearestNeighbor;
|
||||
}
|
||||
|
||||
inline SkSamplingOptions ToSk(DlImageSampling sampling) {
|
||||
switch (sampling) {
|
||||
case DlImageSampling::kCubic:
|
||||
return SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f});
|
||||
case DlImageSampling::kLinear:
|
||||
return SkSamplingOptions(SkFilterMode::kLinear);
|
||||
case DlImageSampling::kMipmapLinear:
|
||||
return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
|
||||
case DlImageSampling::kNearestNeighbor:
|
||||
return SkSamplingOptions(SkFilterMode::kNearest);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_DISPLAY_LIST_SAMPLING_OPTIONS_H_
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_blend_mode.h"
|
||||
#include "flutter/display_list/display_list_builder.h"
|
||||
#include "flutter/display_list/display_list_canvas_recorder.h"
|
||||
#include "flutter/display_list/display_list_utils.h"
|
||||
@@ -63,10 +64,8 @@ constexpr SkPoint TestPoints[] = {
|
||||
};
|
||||
#define TestPointCount sizeof(TestPoints) / (sizeof(TestPoints[0]))
|
||||
|
||||
static const SkSamplingOptions kNearestSampling =
|
||||
SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone);
|
||||
static const SkSamplingOptions kLinearSampling =
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone);
|
||||
static DlImageSampling kNearestSampling = DlImageSampling::kNearestNeighbor;
|
||||
static DlImageSampling kLinearSampling = DlImageSampling::kLinear;
|
||||
|
||||
static sk_sp<DlImage> MakeTestImage(int w, int h, int checker_size) {
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(w, h);
|
||||
@@ -391,7 +390,7 @@ std::vector<DisplayListInvocationGroup> allGroups = {
|
||||
}
|
||||
},
|
||||
{ "SetColorSource", {
|
||||
{0, 112, 0, 0, [](DisplayListBuilder& b) {b.setColorSource(&kTestSource1);}},
|
||||
{0, 96, 0, 0, [](DisplayListBuilder& b) {b.setColorSource(&kTestSource1);}},
|
||||
// stop_count * (sizeof(float) + sizeof(uint32_t)) = 80
|
||||
{0, 80 + 6 * 4, 0, 0, [](DisplayListBuilder& b) {b.setColorSource(kTestSource2.get());}},
|
||||
{0, 80 + 6 * 4, 0, 0, [](DisplayListBuilder& b) {b.setColorSource(kTestSource3.get());}},
|
||||
@@ -411,9 +410,9 @@ std::vector<DisplayListInvocationGroup> allGroups = {
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestErodeImageFilter1);}},
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestErodeImageFilter2);}},
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestErodeImageFilter3);}},
|
||||
{0, 80, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter1);}},
|
||||
{0, 80, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter2);}},
|
||||
{0, 80, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter3);}},
|
||||
{0, 64, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter1);}},
|
||||
{0, 64, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter2);}},
|
||||
{0, 64, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestMatrixImageFilter3);}},
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestComposeImageFilter1);}},
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestComposeImageFilter2);}},
|
||||
{0, 24, 0, 0, [](DisplayListBuilder& b) {b.setImageFilter(&kTestComposeImageFilter3);}},
|
||||
@@ -709,46 +708,46 @@ std::vector<DisplayListInvocationGroup> allGroups = {
|
||||
}
|
||||
},
|
||||
{ "DrawImage", {
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kNearestSampling, false);}},
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kNearestSampling, true);}},
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {20, 10}, kNearestSampling, false);}},
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 20}, kNearestSampling, false);}},
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kLinearSampling, false);}},
|
||||
{1, 48, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage2, {10, 10}, kNearestSampling, false);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kNearestSampling, false);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kNearestSampling, true);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {20, 10}, kNearestSampling, false);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 20}, kNearestSampling, false);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, kLinearSampling, false);}},
|
||||
{1, 24, -1, 48, [](DisplayListBuilder& b) {b.drawImage(TestImage2, {10, 10}, kNearestSampling, false);}},
|
||||
}
|
||||
},
|
||||
{ "DrawImageRect", {
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
kNearestSampling, false);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
kNearestSampling, true);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
kNearestSampling, false,
|
||||
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
|
||||
kNearestSampling, false);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
|
||||
kNearestSampling, false);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
kLinearSampling, false);}},
|
||||
{1, 80, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
|
||||
{1, 56, -1, 80, [](DisplayListBuilder& b) {b.drawImageRect(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
|
||||
kNearestSampling, false);}},
|
||||
}
|
||||
},
|
||||
{ "DrawImageNine", {
|
||||
// SkVanvas::drawImageNine is immediately converted to drawImageLattice
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
SkFilterMode::kNearest, false);}},
|
||||
DlFilterMode::kNearest, false);}},
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
SkFilterMode::kNearest, true);}},
|
||||
DlFilterMode::kNearest, true);}},
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
|
||||
SkFilterMode::kNearest, false);}},
|
||||
DlFilterMode::kNearest, false);}},
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
|
||||
SkFilterMode::kNearest, false);}},
|
||||
DlFilterMode::kNearest, false);}},
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
|
||||
SkFilterMode::kLinear, false);}},
|
||||
DlFilterMode::kLinear, false);}},
|
||||
{1, 48, -1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
|
||||
SkFilterMode::kNearest, false);}},
|
||||
DlFilterMode::kNearest, false);}},
|
||||
}
|
||||
},
|
||||
{ "DrawImageLattice", {
|
||||
@@ -764,80 +763,80 @@ std::vector<DisplayListInvocationGroup> allGroups = {
|
||||
// if fColors and fRectTypes are not null, add (fXCount + 1) * (fYCount + 1) * 5
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 45}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 45}, DlFilterMode::kNearest, false);}},
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs2, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
// One less yDiv does not change the allocation due to 8-byte alignment
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 2, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kLinear, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kLinear, false);}},
|
||||
{1, 96, -1, 96, [](DisplayListBuilder& b) {b.setColor(SK_ColorMAGENTA);
|
||||
b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, true);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, true);}},
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage2,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
// Supplying fBounds does not change size because the Op record always includes it
|
||||
{1, 88, -1, 88, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, &kTestLatticeSrcRect, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
{1, 128, -1, 128, [](DisplayListBuilder& b) {b.drawImageLattice(TestImage1,
|
||||
{kTestDivs3, kTestDivs3, kTestRTypes, 2, 2, nullptr, kTestLatticeColors},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);}},
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);}},
|
||||
}
|
||||
},
|
||||
{ "DrawAtlas", {
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, nullptr, false);}},
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, nullptr, true);}},
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {0, 1, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, nullptr, false);}},
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 25, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, nullptr, false);}},
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kLinearSampling, nullptr, false);}},
|
||||
{1, 48 + 32 + 32, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8, -1, 48 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, DlBlendMode::kDstIn,
|
||||
kNearestSampling, nullptr, false);}},
|
||||
{1, 64 + 32 + 32, -1, 64 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
{1, 64 + 32 + 8, -1, 64 + 32 + 32, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
static SkRect cullRect = { 0, 0, 200, 200 };
|
||||
b.drawAtlas(TestImage2, xforms, texs, nullptr, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, &cullRect, false);}},
|
||||
{1, 48 + 32 + 32 + 8, -1, 48 + 32 + 32 + 8, [](DisplayListBuilder& b) {
|
||||
{1, 48 + 32 + 8 + 8, -1, 48 + 32 + 32 + 8, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
static DlColor colors[] = { DlColor::kBlue(), DlColor::kGreen() };
|
||||
b.drawAtlas(TestImage1, xforms, texs, colors, 2, DlBlendMode::kSrcIn,
|
||||
kNearestSampling, nullptr, false);}},
|
||||
{1, 64 + 32 + 32 + 8, -1, 64 + 32 + 32 + 8, [](DisplayListBuilder& b) {
|
||||
{1, 64 + 32 + 8 + 8, -1, 64 + 32 + 32 + 8, [](DisplayListBuilder& b) {
|
||||
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
|
||||
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
|
||||
static DlColor colors[] = { DlColor::kBlue(), DlColor::kGreen() };
|
||||
@@ -893,7 +892,7 @@ TEST(DisplayList, SingleOpSizes) {
|
||||
sk_sp<DisplayList> dl = invocation.Build();
|
||||
auto desc = group.op_name + "(variant " + std::to_string(i + 1) + ")";
|
||||
ASSERT_EQ(dl->op_count(false), invocation.op_count()) << desc;
|
||||
EXPECT_EQ(dl->bytes(false), invocation.byte_count()) << desc;
|
||||
ASSERT_EQ(dl->bytes(false), invocation.byte_count()) << desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1502,18 +1501,18 @@ TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
|
||||
kNearestSampling, false);
|
||||
, true);
|
||||
RUN_TESTS(builder.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
|
||||
SkFilterMode::kLinear, true););
|
||||
DlFilterMode::kLinear, true););
|
||||
RUN_TESTS2(builder.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
|
||||
SkFilterMode::kLinear, false);
|
||||
DlFilterMode::kLinear, false);
|
||||
, true);
|
||||
RUN_TESTS(builder.drawImageLattice(
|
||||
TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, &kTestLatticeSrcRect, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, true););
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, true););
|
||||
RUN_TESTS2(builder.drawImageLattice(
|
||||
TestImage1,
|
||||
{kTestDivs1, kTestDivs1, nullptr, 3, 3, &kTestLatticeSrcRect, nullptr},
|
||||
{10, 10, 40, 40}, SkFilterMode::kNearest, false);
|
||||
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
|
||||
, true);
|
||||
static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
|
||||
static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
|
||||
|
||||
@@ -476,7 +476,7 @@ void DisplayListBoundsCalculator::drawVertices(const DlVertices* vertices,
|
||||
}
|
||||
void DisplayListBoundsCalculator::drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
SkRect bounds = SkRect::MakeXYWH(point.fX, point.fY, //
|
||||
image->width(), image->height());
|
||||
@@ -489,7 +489,7 @@ void DisplayListBoundsCalculator::drawImageRect(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
DisplayListAttributeFlags flags = render_with_attributes
|
||||
@@ -500,7 +500,7 @@ void DisplayListBoundsCalculator::drawImageRect(
|
||||
void DisplayListBoundsCalculator::drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
DisplayListAttributeFlags flags = render_with_attributes
|
||||
? kDrawImageNineWithPaintFlags
|
||||
@@ -511,7 +511,7 @@ void DisplayListBoundsCalculator::drawImageLattice(
|
||||
const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
DisplayListAttributeFlags flags = render_with_attributes
|
||||
? kDrawImageLatticeWithPaintFlags
|
||||
@@ -524,7 +524,7 @@ void DisplayListBoundsCalculator::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
bool render_with_attributes) {
|
||||
SkPoint quad[4];
|
||||
|
||||
@@ -120,23 +120,23 @@ class IgnoreDrawDispatchHelper : public virtual Dispatcher {
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override {}
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override {}
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override {}
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override {}
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override {}
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -144,7 +144,7 @@ class IgnoreDrawDispatchHelper : public virtual Dispatcher {
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) override {}
|
||||
void drawPicture(const sk_sp<SkPicture> picture,
|
||||
@@ -435,23 +435,23 @@ class DisplayListBoundsCalculator final
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -459,7 +459,7 @@ class DisplayListBoundsCalculator final
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cullRect,
|
||||
bool render_with_attributes) override;
|
||||
void drawPicture(const sk_sp<SkPicture> picture,
|
||||
|
||||
@@ -12,7 +12,7 @@ TextureLayer::TextureLayer(const SkPoint& offset,
|
||||
const SkSize& size,
|
||||
int64_t texture_id,
|
||||
bool freeze,
|
||||
const SkSamplingOptions& sampling)
|
||||
DlImageSampling sampling)
|
||||
: offset_(offset),
|
||||
size_(size),
|
||||
texture_id_(texture_id),
|
||||
@@ -61,7 +61,7 @@ void TextureLayer::Paint(PaintContext& context) const {
|
||||
}
|
||||
AutoCachePaint cache_paint(context);
|
||||
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
|
||||
context.gr_context, sampling_, cache_paint.paint());
|
||||
context.gr_context, ToSk(sampling_), cache_paint.paint());
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -17,7 +17,7 @@ class TextureLayer : public Layer {
|
||||
const SkSize& size,
|
||||
int64_t texture_id,
|
||||
bool freeze,
|
||||
const SkSamplingOptions& sampling);
|
||||
DlImageSampling sampling);
|
||||
|
||||
bool IsReplacing(DiffContext* context, const Layer* layer) const override {
|
||||
return layer->as_texture_layer() != nullptr;
|
||||
@@ -35,7 +35,7 @@ class TextureLayer : public Layer {
|
||||
SkSize size_;
|
||||
int64_t texture_id_;
|
||||
bool freeze_;
|
||||
SkSamplingOptions sampling_;
|
||||
DlImageSampling sampling_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(TextureLayer);
|
||||
};
|
||||
|
||||
@@ -19,8 +19,8 @@ using TextureLayerTest = LayerTest;
|
||||
TEST_F(TextureLayerTest, InvalidTexture) {
|
||||
const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
|
||||
const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
|
||||
auto layer = std::make_shared<TextureLayer>(layer_offset, layer_size, 0,
|
||||
false, SkSamplingOptions());
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
layer_offset, layer_size, 0, false, DlImageSampling::kNearestNeighbor);
|
||||
|
||||
layer->Preroll(preroll_context(), SkMatrix());
|
||||
EXPECT_EQ(layer->paint_bounds(),
|
||||
@@ -38,8 +38,9 @@ TEST_F(TextureLayerTest, PaintingEmptyLayerDies) {
|
||||
const SkSize layer_size = SkSize::Make(0.0f, 0.0f);
|
||||
const int64_t texture_id = 0;
|
||||
auto mock_texture = std::make_shared<MockTexture>(texture_id);
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
layer_offset, layer_size, texture_id, false, SkSamplingOptions());
|
||||
auto layer =
|
||||
std::make_shared<TextureLayer>(layer_offset, layer_size, texture_id,
|
||||
false, DlImageSampling::kNearestNeighbor);
|
||||
|
||||
// Ensure the texture is located by the Layer.
|
||||
preroll_context()->texture_registry.RegisterTexture(mock_texture);
|
||||
@@ -58,8 +59,7 @@ TEST_F(TextureLayerTest, PaintBeforePrerollDies) {
|
||||
const int64_t texture_id = 0;
|
||||
auto mock_texture = std::make_shared<MockTexture>(texture_id);
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
layer_offset, layer_size, texture_id, false,
|
||||
SkSamplingOptions(SkFilterMode::kLinear));
|
||||
layer_offset, layer_size, texture_id, false, DlImageSampling::kLinear);
|
||||
|
||||
// Ensure the texture is located by the Layer.
|
||||
preroll_context()->texture_registry.RegisterTexture(mock_texture);
|
||||
@@ -75,8 +75,7 @@ TEST_F(TextureLayerTest, PaintingWithLinearSampling) {
|
||||
const int64_t texture_id = 0;
|
||||
auto mock_texture = std::make_shared<MockTexture>(texture_id);
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
layer_offset, layer_size, texture_id, false,
|
||||
SkSamplingOptions(SkFilterMode::kLinear));
|
||||
layer_offset, layer_size, texture_id, false, DlImageSampling::kLinear);
|
||||
|
||||
// Ensure the texture is located by the Layer.
|
||||
preroll_context()->texture_registry.RegisterTexture(mock_texture);
|
||||
@@ -101,9 +100,9 @@ TEST_F(TextureLayerDiffTest, TextureInRetainedLayer) {
|
||||
MockLayerTree tree1;
|
||||
auto container = std::make_shared<ContainerLayer>();
|
||||
tree1.root()->Add(container);
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
SkPoint::Make(0, 0), SkSize::Make(100, 100), 0, false,
|
||||
SkSamplingOptions(SkFilterMode::kLinear));
|
||||
auto layer = std::make_shared<TextureLayer>(SkPoint::Make(0, 0),
|
||||
SkSize::Make(100, 100), 0, false,
|
||||
DlImageSampling::kLinear);
|
||||
container->Add(layer);
|
||||
|
||||
MockLayerTree tree2;
|
||||
@@ -122,8 +121,7 @@ TEST_F(TextureLayerTest, OpacityInheritance) {
|
||||
const int64_t texture_id = 0;
|
||||
auto mock_texture = std::make_shared<MockTexture>(texture_id);
|
||||
auto layer = std::make_shared<TextureLayer>(
|
||||
layer_offset, layer_size, texture_id, false,
|
||||
SkSamplingOptions(SkFilterMode::kLinear));
|
||||
layer_offset, layer_size, texture_id, false, DlImageSampling::kLinear);
|
||||
|
||||
// Ensure the texture is located by the Layer.
|
||||
preroll_context()->texture_registry.RegisterTexture(mock_texture);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/testing/mock_texture.h"
|
||||
#include "flutter/flow/testing/skia_gpu_object_layer_test.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "display_list/display_list_tile_mode.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/display_list/display_list_image_impeller.h"
|
||||
#include "impeller/entity/contents/filters/filter_contents.h"
|
||||
#include "impeller/entity/contents/linear_gradient_contents.h"
|
||||
#include "impeller/entity/contents/solid_stroke_contents.h"
|
||||
@@ -724,7 +725,7 @@ void DisplayListDispatcher::drawVertices(const flutter::DlVertices* vertices,
|
||||
// |flutter::Dispatcher|
|
||||
void DisplayListDispatcher::drawImage(const sk_sp<flutter::DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
if (!image) {
|
||||
return;
|
||||
@@ -751,14 +752,14 @@ void DisplayListDispatcher::drawImage(const sk_sp<flutter::DlImage> image,
|
||||
}
|
||||
|
||||
static impeller::SamplerDescriptor ToSamplerDescriptor(
|
||||
const SkSamplingOptions& options) {
|
||||
const flutter::DlImageSampling options) {
|
||||
impeller::SamplerDescriptor desc;
|
||||
switch (options.filter) {
|
||||
case SkFilterMode::kNearest:
|
||||
switch (options) {
|
||||
case flutter::DlImageSampling::kNearestNeighbor:
|
||||
desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kNearest;
|
||||
desc.label = "Nearest Sampler";
|
||||
break;
|
||||
case SkFilterMode::kLinear:
|
||||
case flutter::DlImageSampling::kLinear:
|
||||
desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
|
||||
desc.label = "Linear Sampler";
|
||||
break;
|
||||
@@ -773,7 +774,7 @@ void DisplayListDispatcher::drawImageRect(
|
||||
const sk_sp<flutter::DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
canvas_.DrawImageRect(
|
||||
@@ -789,7 +790,7 @@ void DisplayListDispatcher::drawImageRect(
|
||||
void DisplayListDispatcher::drawImageNine(const sk_sp<flutter::DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
flutter::DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
// Needs https://github.com/flutter/flutter/issues/95434
|
||||
UNIMPLEMENTED;
|
||||
@@ -800,7 +801,7 @@ void DisplayListDispatcher::drawImageLattice(
|
||||
const sk_sp<flutter::DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
flutter::DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
// Needs https://github.com/flutter/flutter/issues/95434
|
||||
UNIMPLEMENTED;
|
||||
@@ -813,7 +814,7 @@ void DisplayListDispatcher::drawAtlas(const sk_sp<flutter::DlImage> atlas,
|
||||
const flutter::DlColor colors[],
|
||||
int count,
|
||||
flutter::DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) {
|
||||
// Needs https://github.com/flutter/flutter/issues/95434
|
||||
|
||||
@@ -180,14 +180,14 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
|
||||
// |flutter::Dispatcher|
|
||||
void drawImage(const sk_sp<flutter::DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
|
||||
// |flutter::Dispatcher|
|
||||
void drawImageRect(const sk_sp<flutter::DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override;
|
||||
|
||||
@@ -195,14 +195,14 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
|
||||
void drawImageNine(const sk_sp<flutter::DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
flutter::DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
|
||||
// |flutter::Dispatcher|
|
||||
void drawImageLattice(const sk_sp<flutter::DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
flutter::DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
|
||||
// |flutter::Dispatcher|
|
||||
@@ -212,7 +212,7 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
|
||||
const flutter::DlColor colors[],
|
||||
int count,
|
||||
flutter::DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
flutter::DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) override;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_P(DisplayListTest, CanDrawImage) {
|
||||
auto texture = CreateTextureForFixture("embarcadero.jpg");
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
|
||||
SkSamplingOptions{}, true);
|
||||
flutter::DlImageSampling::kNearestNeighbor, true);
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ TEST_P(DisplayListTest, CanDrawWithMaskBlur) {
|
||||
auto filter = flutter::DlBlurMaskFilter(kNormal_SkBlurStyle, 10.0f);
|
||||
builder.setMaskFilter(&filter);
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
|
||||
SkSamplingOptions{}, true);
|
||||
flutter::DlImageSampling::kNearestNeighbor, true);
|
||||
}
|
||||
|
||||
// Mask blurred filled path.
|
||||
@@ -241,7 +241,7 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
|
||||
flutter::DlBlendMode::kModulate);
|
||||
builder.setColorFilter(&filter);
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
|
||||
SkSamplingOptions{}, true);
|
||||
flutter::DlImageSampling::kNearestNeighbor, true);
|
||||
}
|
||||
|
||||
// Advanced blended image.
|
||||
@@ -250,7 +250,7 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
|
||||
flutter::DlBlendColorFilter(SK_ColorRED, flutter::DlBlendMode::kScreen);
|
||||
builder.setColorFilter(&filter);
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(250, 250),
|
||||
SkSamplingOptions{}, true);
|
||||
flutter::DlImageSampling::kNearestNeighbor, true);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
@@ -279,7 +279,7 @@ TEST_P(DisplayListTest, CanDrawWithImageBlurFilter) {
|
||||
flutter::DlTileMode::kClamp);
|
||||
builder.setImageFilter(&filter);
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(200, 200),
|
||||
SkSamplingOptions{}, true);
|
||||
flutter::DlImageSampling::kNearestNeighbor, true);
|
||||
|
||||
return builder.Build();
|
||||
};
|
||||
|
||||
@@ -492,7 +492,7 @@ void Canvas::drawImage(const CanvasImage* image,
|
||||
return;
|
||||
}
|
||||
SkPaint sk_paint;
|
||||
canvas_->drawImage(sk_image, x, y, sampling, paint.paint(sk_paint));
|
||||
canvas_->drawImage(sk_image, x, y, ToSk(sampling), paint.paint(sk_paint));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,8 @@ void Canvas::drawImageRect(const CanvasImage* image,
|
||||
return;
|
||||
}
|
||||
SkPaint sk_paint;
|
||||
canvas_->drawImageRect(sk_image, src, dst, sampling, paint.paint(sk_paint),
|
||||
canvas_->drawImageRect(sk_image, src, dst, ToSk(sampling),
|
||||
paint.paint(sk_paint),
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +578,7 @@ void Canvas::drawImageNine(const CanvasImage* image,
|
||||
return;
|
||||
}
|
||||
SkPaint sk_paint;
|
||||
canvas_->drawImageNine(sk_image.get(), icenter, dst, filter,
|
||||
canvas_->drawImageNine(sk_image.get(), icenter, dst, ToSk(filter),
|
||||
paint.paint(sk_paint));
|
||||
}
|
||||
}
|
||||
@@ -706,7 +707,7 @@ void Canvas::drawAtlas(const Paint& paint,
|
||||
reinterpret_cast<const SkRect*>(rects.data()),
|
||||
reinterpret_cast<const SkColor*>(colors.data()),
|
||||
rects.num_elements() / 4, // SkRect have four floats.
|
||||
ToSk(blend_mode), sampling,
|
||||
ToSk(blend_mode), ToSk(sampling),
|
||||
reinterpret_cast<const SkRect*>(cull_rect.data()),
|
||||
paint.paint(sk_paint));
|
||||
}
|
||||
|
||||
@@ -72,11 +72,14 @@ fml::RefPtr<FragmentShader> FragmentProgram::shader(
|
||||
uniforms.Release();
|
||||
std::vector<sk_sp<SkShader>> sk_samplers(sampler_shaders.size());
|
||||
for (size_t i = 0; i < sampler_shaders.size(); i++) {
|
||||
SkSamplingOptions sampling;
|
||||
DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
|
||||
ImageShader* image_shader = sampler_shaders[i];
|
||||
// The default value for SkSamplingOptions is used because ImageShader
|
||||
// uses a cached value set by the user in the Dart constructor.
|
||||
// Users are instructed to make use of this in the Dart docs.
|
||||
// ImageShaders can hold a preferred value for sampling options and
|
||||
// developers are encouraged to use that value or the value will be supplied
|
||||
// by "the environment where it is used". The environment here does not
|
||||
// contain a value to be used if the developer did not specify a preference
|
||||
// when they constructed the ImageShader, so we will use kNearest which is
|
||||
// the default filterQuality in a Paint object.
|
||||
sk_samplers[i] = image_shader->shader(sampling)->skia_object();
|
||||
uniform_floats[uniform_count + 2 * i] = image_shader->width();
|
||||
uniform_floats[uniform_count + 2 * i + 1] = image_shader->height();
|
||||
|
||||
@@ -34,7 +34,7 @@ void FragmentShader::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
}
|
||||
|
||||
std::shared_ptr<DlColorSource> FragmentShader::shader(
|
||||
SkSamplingOptions& sampling) {
|
||||
DlImageSampling sampling) {
|
||||
// Sampling options are ignored, since sampling options don't make sense for
|
||||
// generative shaders.
|
||||
return source_;
|
||||
|
||||
@@ -32,7 +32,7 @@ class FragmentShader : public Shader {
|
||||
static fml::RefPtr<FragmentShader> Create(Dart_Handle dart_handle,
|
||||
sk_sp<SkShader> shader);
|
||||
|
||||
std::shared_ptr<DlColorSource> shader(SkSamplingOptions&) override;
|
||||
std::shared_ptr<DlColorSource> shader(DlImageSampling) override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class CanvasGradient : public Shader {
|
||||
SkTileMode tile_mode,
|
||||
const tonic::Float64List& matrix4);
|
||||
|
||||
std::shared_ptr<DlColorSource> shader(SkSamplingOptions& sampling) override {
|
||||
std::shared_ptr<DlColorSource> shader(DlImageSampling sampling) override {
|
||||
return dl_shader_->with_sampling(sampling);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ fml::RefPtr<ImageFilter> ImageFilter::Create() {
|
||||
return fml::MakeRefCounted<ImageFilter>();
|
||||
}
|
||||
|
||||
static const std::array<SkSamplingOptions, 4> kFilterQualities = {
|
||||
SkSamplingOptions(SkFilterMode::kNearest, SkMipmapMode::kNone),
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone),
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear),
|
||||
SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f}),
|
||||
static const std::array<DlImageSampling, 4> kFilterQualities = {
|
||||
DlImageSampling::kNearestNeighbor,
|
||||
DlImageSampling::kLinear,
|
||||
DlImageSampling::kMipmapLinear,
|
||||
DlImageSampling::kCubic,
|
||||
};
|
||||
|
||||
SkSamplingOptions ImageFilter::SamplingFromIndex(int filterQualityIndex) {
|
||||
DlImageSampling ImageFilter::SamplingFromIndex(int filterQualityIndex) {
|
||||
if (filterQualityIndex < 0) {
|
||||
return kFilterQualities.front();
|
||||
} else if (static_cast<size_t>(filterQualityIndex) >=
|
||||
@@ -58,11 +58,11 @@ SkSamplingOptions ImageFilter::SamplingFromIndex(int filterQualityIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
SkFilterMode ImageFilter::FilterModeFromIndex(int filterQualityIndex) {
|
||||
DlFilterMode ImageFilter::FilterModeFromIndex(int filterQualityIndex) {
|
||||
if (filterQualityIndex <= 0) {
|
||||
return SkFilterMode::kNearest;
|
||||
return DlFilterMode::kNearest;
|
||||
}
|
||||
return SkFilterMode::kLinear;
|
||||
return DlFilterMode::kLinear;
|
||||
}
|
||||
|
||||
ImageFilter::ImageFilter() {}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define FLUTTER_LIB_UI_PAINTING_IMAGE_FILTER_H_
|
||||
|
||||
#include "flutter/display_list/display_list_image_filter.h"
|
||||
#include "flutter/display_list/display_list_sampling_options.h"
|
||||
#include "flutter/lib/ui/dart_wrapper.h"
|
||||
#include "flutter/lib/ui/painting/color_filter.h"
|
||||
#include "third_party/tonic/typed_data/typed_list.h"
|
||||
@@ -26,8 +27,8 @@ class ImageFilter : public RefCountedDartWrappable<ImageFilter> {
|
||||
~ImageFilter() override;
|
||||
static fml::RefPtr<ImageFilter> Create();
|
||||
|
||||
static SkSamplingOptions SamplingFromIndex(int filterQualityIndex);
|
||||
static SkFilterMode FilterModeFromIndex(int index);
|
||||
static DlImageSampling SamplingFromIndex(int filterQualityIndex);
|
||||
static DlFilterMode FilterModeFromIndex(int index);
|
||||
|
||||
void initBlur(double sigma_x, double sigma_y, SkTileMode tile_mode);
|
||||
void initDilate(double radius_x, double radius_y);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "flutter/lib/ui/painting/image_filter.h"
|
||||
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "lib/ui/painting/display_list_image_gpu.h"
|
||||
#include "third_party/tonic/converter/dart_converter.h"
|
||||
#include "third_party/tonic/dart_args.h"
|
||||
#include "third_party/tonic/dart_binding_macros.h"
|
||||
@@ -54,15 +55,14 @@ void ImageShader::initWithImage(CanvasImage* image,
|
||||
sk_image_ = UIDartState::CreateGPUObject(std::move(raw_sk_image));
|
||||
SkMatrix local_matrix = ToSkMatrix(matrix4);
|
||||
sampling_is_locked_ = filter_quality_index >= 0;
|
||||
SkSamplingOptions sampling =
|
||||
DlImageSampling sampling =
|
||||
sampling_is_locked_ ? ImageFilter::SamplingFromIndex(filter_quality_index)
|
||||
: DisplayList::LinearSampling;
|
||||
: DlImageSampling::kLinear;
|
||||
cached_shader_ = UIDartState::CreateGPUObject(sk_make_sp<DlImageColorSource>(
|
||||
sk_image_.skia_object(), ToDl(tmx), ToDl(tmy), sampling, &local_matrix));
|
||||
}
|
||||
|
||||
std::shared_ptr<DlColorSource> ImageShader::shader(
|
||||
SkSamplingOptions& sampling) {
|
||||
std::shared_ptr<DlColorSource> ImageShader::shader(DlImageSampling sampling) {
|
||||
if (sampling_is_locked_) {
|
||||
sampling = cached_shader_.skia_object()->sampling();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class ImageShader : public Shader {
|
||||
int filter_quality_index,
|
||||
const tonic::Float64List& matrix4);
|
||||
|
||||
std::shared_ptr<DlColorSource> shader(SkSamplingOptions&) override;
|
||||
std::shared_ptr<DlColorSource> shader(DlImageSampling) override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Shader : public RefCountedDartWrappable<Shader> {
|
||||
public:
|
||||
~Shader() override;
|
||||
|
||||
virtual std::shared_ptr<DlColorSource> shader(SkSamplingOptions&) = 0;
|
||||
virtual std::shared_ptr<DlColorSource> shader(DlImageSampling) = 0;
|
||||
|
||||
protected:
|
||||
Shader() {}
|
||||
|
||||
@@ -221,10 +221,10 @@ static std::ostream& operator<<(std::ostream& os,
|
||||
}
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& os, const SkFilterMode& mode) {
|
||||
static std::ostream& operator<<(std::ostream& os, const DlFilterMode& mode) {
|
||||
switch (mode) {
|
||||
case SkFilterMode::kNearest: return os << "FilterMode::kNearest";
|
||||
case SkFilterMode::kLinear: return os << "FilterMode::kLinear";
|
||||
case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
|
||||
case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
|
||||
|
||||
default: return os << "FilterMode::????";
|
||||
}
|
||||
@@ -235,20 +235,21 @@ static std::ostream& operator<<(std::ostream& os, const DlColor& color) {
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& os,
|
||||
const SkSamplingOptions sampling) {
|
||||
if (sampling == DisplayList::NearestSampling) {
|
||||
return os << "NearestSampling";
|
||||
DlImageSampling sampling) {
|
||||
switch (sampling) {
|
||||
case DlImageSampling::kNearestNeighbor: {
|
||||
return os << "NearestSampling";
|
||||
}
|
||||
case DlImageSampling::kLinear: {
|
||||
return os << "LinearSampling";
|
||||
}
|
||||
case DlImageSampling::kMipmapLinear: {
|
||||
return os << "MipmapSampling";
|
||||
}
|
||||
case DlImageSampling::kCubic: {
|
||||
return os << "CubicSampling";
|
||||
}
|
||||
}
|
||||
if (sampling == DisplayList::LinearSampling) {
|
||||
return os << "LinearSampling";
|
||||
}
|
||||
if (sampling == DisplayList::MipmapSampling) {
|
||||
return os << "MipmapSampling";
|
||||
}
|
||||
if (sampling == DisplayList::CubicSampling) {
|
||||
return os << "CubicSampling";
|
||||
}
|
||||
return os << "UnkownSampling";
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& os, const SkTextBlob* blob) {
|
||||
@@ -753,7 +754,7 @@ void DisplayListStreamDispatcher::drawVertices(const DlVertices* vertices,
|
||||
}
|
||||
void DisplayListStreamDispatcher::drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) {
|
||||
startl() << "drawImage(" << image.get() << "," << std::endl;
|
||||
startl() << " " << point << ", "
|
||||
@@ -764,7 +765,7 @@ void DisplayListStreamDispatcher::drawImage(const sk_sp<DlImage> image,
|
||||
void DisplayListStreamDispatcher::drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
startl() << "drawImageRect(" << image.get() << "," << std::endl;
|
||||
@@ -778,7 +779,7 @@ void DisplayListStreamDispatcher::drawImageRect(const sk_sp<DlImage> image,
|
||||
void DisplayListStreamDispatcher::drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
startl() << "drawImageNine(" << image.get() << "," << std::endl;
|
||||
startl() << " center: " << center << "," << std::endl;
|
||||
@@ -790,7 +791,7 @@ void DisplayListStreamDispatcher::drawImageNine(const sk_sp<DlImage> image,
|
||||
void DisplayListStreamDispatcher::drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) {
|
||||
startl() << "drawImageLattice(blah blah);" << std::endl;
|
||||
}
|
||||
@@ -800,7 +801,7 @@ void DisplayListStreamDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) {
|
||||
startl() << "drawAtlas(" << atlas.get() << ", ";
|
||||
|
||||
@@ -104,23 +104,23 @@ class DisplayListStreamDispatcher final : public Dispatcher {
|
||||
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
|
||||
void drawImage(const sk_sp<DlImage> image,
|
||||
const SkPoint point,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageRect(const sk_sp<DlImage> image,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
bool render_with_attributes,
|
||||
SkCanvas::SrcRectConstraint constraint) override;
|
||||
void drawImageNine(const sk_sp<DlImage> image,
|
||||
const SkIRect& center,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawImageLattice(const sk_sp<DlImage> image,
|
||||
const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
SkFilterMode filter,
|
||||
DlFilterMode filter,
|
||||
bool render_with_attributes) override;
|
||||
void drawAtlas(const sk_sp<DlImage> atlas,
|
||||
const SkRSXform xform[],
|
||||
@@ -128,7 +128,7 @@ class DisplayListStreamDispatcher final : public Dispatcher {
|
||||
const DlColor colors[],
|
||||
int count,
|
||||
DlBlendMode mode,
|
||||
const SkSamplingOptions& sampling,
|
||||
DlImageSampling sampling,
|
||||
const SkRect* cull_rect,
|
||||
bool render_with_attributes) override;
|
||||
void drawPicture(const sk_sp<SkPicture> picture,
|
||||
|
||||
Reference in New Issue
Block a user