Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
flutter::testing::RenderEnvironment Class Reference

Public Member Functions

 RenderEnvironment (const DlSurfaceProvider *provider, PixelFormat format)
 
void init_ref (SkSetup &sk_setup, SkRenderer &sk_renderer, DlSetup &dl_setup, DlRenderer &dl_renderer, DlRenderer &imp_renderer, DlColor bg=DlColor::kTransparent())
 
std::unique_ptr< RenderResultgetResult (const RenderJobInfo &info, JobRenderer &renderer) const
 
std::unique_ptr< RenderResultgetResult (sk_sp< DisplayList > dl) const
 
std::unique_ptr< ImpellerRenderResultgetImpellerResult (const RenderJobInfo &info, DlJobRenderer &renderer) const
 
const DlSurfaceProviderprovider () const
 
bool valid () const
 
const std::string backend_name () const
 
bool supports_impeller () const
 
PixelFormat format () const
 
const DlPaintref_dl_paint () const
 
const SkMatrixref_matrix () const
 
const SkIRectref_clip_bounds () const
 
const RenderResultref_sk_result () const
 
const RenderResultref_dl_result () const
 
const ImpellerRenderResultref_impeller_result () const
 
const sk_sp< SkImagesk_image () const
 
const sk_sp< DlImagedl_image () const
 
const sk_sp< DlImageimpeller_image () const
 

Static Public Member Functions

static RenderEnvironment Make565 (const DlSurfaceProvider *provider)
 
static RenderEnvironment MakeN32 (const DlSurfaceProvider *provider)
 

Static Public Attributes

static bool EnableImpeller = true
 

Detailed Description

Definition at line 585 of file dl_rendering_unittests.cc.

Constructor & Destructor Documentation

◆ RenderEnvironment()

flutter::testing::RenderEnvironment::RenderEnvironment ( const DlSurfaceProvider provider,
PixelFormat  format 
)
inline

Definition at line 589 of file dl_rendering_unittests.cc.

590 : provider_(provider), format_(format) {
591 if (provider->supports(format)) {
592 surface_1x_ =
594 surface_2x_ = provider->MakeOffscreenSurface(kTestWidth * 2,
595 kTestHeight * 2, format);
596 }
597 }
virtual bool supports(PixelFormat format) const =0
virtual std::shared_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format=kN32PremulPixelFormat) const =0
const DlSurfaceProvider * provider() const

Member Function Documentation

◆ backend_name()

const std::string flutter::testing::RenderEnvironment::backend_name ( ) const
inline

Definition at line 675 of file dl_rendering_unittests.cc.

675{ return provider_->backend_name(); }
virtual const std::string backend_name() const =0

◆ dl_image()

const sk_sp< DlImage > flutter::testing::RenderEnvironment::dl_image ( ) const
inline

Definition at line 691 of file dl_rendering_unittests.cc.

691{ return kTestDlImage; }

◆ format()

PixelFormat flutter::testing::RenderEnvironment::format ( ) const
inline

Definition at line 680 of file dl_rendering_unittests.cc.

680{ return format_; }

◆ getImpellerResult()

std::unique_ptr< ImpellerRenderResult > flutter::testing::RenderEnvironment::getImpellerResult ( const RenderJobInfo info,
DlJobRenderer renderer 
) const
inline

Definition at line 658 of file dl_rendering_unittests.cc.

660 {
661 FML_DCHECK(info.scale == SK_Scalar1);
662
663 DisplayListBuilder builder;
664 builder.Clear(info.bg);
665 auto render_dl = renderer.MakeDisplayList(info);
666 builder.DrawDisplayList(render_dl);
667 auto dl = builder.Build();
668 auto snap = provider_->ImpellerSnapshot(dl, kTestWidth, kTestHeight);
669 return std::make_unique<ImpellerRenderResult>(std::move(snap),
670 render_dl->bounds());
671 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SK_Scalar1
Definition: SkScalar.h:18
virtual sk_sp< DlPixelData > ImpellerSnapshot(const sk_sp< DisplayList > &list, int width, int height) const
#define FML_DCHECK(condition)
Definition: logging.h:103

◆ getResult() [1/2]

std::unique_ptr< RenderResult > flutter::testing::RenderEnvironment::getResult ( const RenderJobInfo info,
JobRenderer renderer 
) const
inline

Definition at line 633 of file dl_rendering_unittests.cc.

634 {
635 auto surface = getSurface(info.width, info.height);
636 FML_DCHECK(surface != nullptr);
637 auto canvas = surface->getCanvas();
638 canvas->clear(ToSk(info.bg));
639
640 int restore_count = canvas->save();
641 canvas->scale(info.scale, info.scale);
642 renderer.Render(canvas, info);
643 canvas->restoreToCount(restore_count);
644
645 if (GrDirectContext* dContext =
646 GrAsDirectContext(surface->recordingContext())) {
647 dContext->flushAndSubmit(surface.get(), GrSyncCpu::kYes);
648 }
649 return std::make_unique<SkRenderResult>(surface);
650 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
VkSurfaceKHR surface
Definition: main.cc:49
SkPaint ToSk(const DlPaint &paint)

◆ getResult() [2/2]

std::unique_ptr< RenderResult > flutter::testing::RenderEnvironment::getResult ( sk_sp< DisplayList dl) const
inline

Definition at line 652 of file dl_rendering_unittests.cc.

652 {
653 DisplayListJobRenderer job(std::move(dl));
654 RenderJobInfo info = {};
655 return getResult(info, job);
656 }
std::unique_ptr< RenderResult > getResult(const RenderJobInfo &info, JobRenderer &renderer) const

◆ impeller_image()

const sk_sp< DlImage > flutter::testing::RenderEnvironment::impeller_image ( ) const
inline

Definition at line 692 of file dl_rendering_unittests.cc.

692{ return test_impeller_image_; }

◆ init_ref()

void flutter::testing::RenderEnvironment::init_ref ( SkSetup sk_setup,
SkRenderer sk_renderer,
DlSetup dl_setup,
DlRenderer dl_renderer,
DlRenderer imp_renderer,
DlColor  bg = DlColor::kTransparent() 
)
inline

Definition at line 607 of file dl_rendering_unittests.cc.

612 {
613 SkJobRenderer sk_job(sk_setup, sk_renderer, kEmptySkRenderer, kTestSkImage);
614 RenderJobInfo info = {
615 .bg = bg,
616 };
617 ref_sk_result_ = getResult(info, sk_job);
618 DlJobRenderer dl_job(dl_setup, dl_renderer, kEmptyDlRenderer, kTestDlImage);
619 ref_dl_result_ = getResult(info, dl_job);
620 ref_dl_paint_ = dl_job.setup_paint();
621 ref_matrix_ = dl_job.setup_matrix();
622 ref_clip_bounds_ = dl_job.setup_clip_bounds();
623 ASSERT_EQ(sk_job.setup_matrix(), ref_matrix_);
624 ASSERT_EQ(sk_job.setup_clip_bounds(), ref_clip_bounds_);
625 if (supports_impeller()) {
626 test_impeller_image_ = makeTestImpellerImage(provider_);
627 DlJobRenderer imp_job(dl_setup, imp_renderer, kEmptyDlRenderer,
628 test_impeller_image_);
629 ref_impeller_result_ = getImpellerResult(info, imp_job);
630 }
631 }
std::unique_ptr< ImpellerRenderResult > getImpellerResult(const RenderJobInfo &info, DlJobRenderer &renderer) const
static const SkRenderer kEmptySkRenderer
static const DlRenderer kEmptyDlRenderer

◆ Make565()

static RenderEnvironment flutter::testing::RenderEnvironment::Make565 ( const DlSurfaceProvider provider)
inlinestatic

Definition at line 599 of file dl_rendering_unittests.cc.

599 {
600 return RenderEnvironment(provider, PixelFormat::k565PixelFormat);
601 }
RenderEnvironment(const DlSurfaceProvider *provider, PixelFormat format)

◆ MakeN32()

static RenderEnvironment flutter::testing::RenderEnvironment::MakeN32 ( const DlSurfaceProvider provider)
inlinestatic

Definition at line 603 of file dl_rendering_unittests.cc.

603 {
604 return RenderEnvironment(provider, PixelFormat::kN32PremulPixelFormat);
605 }

◆ provider()

const DlSurfaceProvider * flutter::testing::RenderEnvironment::provider ( ) const
inline

Definition at line 673 of file dl_rendering_unittests.cc.

673{ return provider_; }

◆ ref_clip_bounds()

const SkIRect & flutter::testing::RenderEnvironment::ref_clip_bounds ( ) const
inline

Definition at line 683 of file dl_rendering_unittests.cc.

683{ return ref_clip_bounds_; }

◆ ref_dl_paint()

const DlPaint & flutter::testing::RenderEnvironment::ref_dl_paint ( ) const
inline

Definition at line 681 of file dl_rendering_unittests.cc.

681{ return ref_dl_paint_; }

◆ ref_dl_result()

const RenderResult * flutter::testing::RenderEnvironment::ref_dl_result ( ) const
inline

Definition at line 685 of file dl_rendering_unittests.cc.

685{ return ref_dl_result_.get(); }

◆ ref_impeller_result()

const ImpellerRenderResult * flutter::testing::RenderEnvironment::ref_impeller_result ( ) const
inline

Definition at line 686 of file dl_rendering_unittests.cc.

686 {
687 return ref_impeller_result_.get();
688 }

◆ ref_matrix()

const SkMatrix & flutter::testing::RenderEnvironment::ref_matrix ( ) const
inline

Definition at line 682 of file dl_rendering_unittests.cc.

682{ return ref_matrix_; }

◆ ref_sk_result()

const RenderResult * flutter::testing::RenderEnvironment::ref_sk_result ( ) const
inline

Definition at line 684 of file dl_rendering_unittests.cc.

684{ return ref_sk_result_.get(); }

◆ sk_image()

const sk_sp< SkImage > flutter::testing::RenderEnvironment::sk_image ( ) const
inline

Definition at line 690 of file dl_rendering_unittests.cc.

690{ return kTestSkImage; }

◆ supports_impeller()

bool flutter::testing::RenderEnvironment::supports_impeller ( ) const
inline

Definition at line 676 of file dl_rendering_unittests.cc.

676 {
677 return EnableImpeller && provider_->supports_impeller();
678 }

◆ valid()

bool flutter::testing::RenderEnvironment::valid ( ) const
inline

Definition at line 674 of file dl_rendering_unittests.cc.

674{ return provider_->supports(format_); }

Member Data Documentation

◆ EnableImpeller

bool flutter::testing::RenderEnvironment::EnableImpeller = true
static

Definition at line 587 of file dl_rendering_unittests.cc.


The documentation for this class was generated from the following file: