Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
TextureSetRenderer Class Reference
Inheritance diagram for TextureSetRenderer:
ClipTileRenderer SkRefCntBase

Public Member Functions

int drawTiles (SkCanvas *canvas) override
 
int drawTile (SkCanvas *canvas, const SkRect &rect, const SkPoint clip[4], const bool edgeAA[4], int tileID, int quadID) override
 
void drawBanner (SkCanvas *canvas) override
 
virtual int drawTile (SkCanvas *canvas, const SkRect &rect, const SkPoint clip[4], const bool edgeAA[4], int tileID, int quadID)=0
 
virtual void drawBanner (SkCanvas *canvas)=0
 
virtual int drawTiles (SkCanvas *canvas)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< ClipTileRendererMakeUnbatched (sk_sp< SkImage > image)
 
static sk_sp< ClipTileRendererMakeBatched (sk_sp< SkImage > image, int transformCount)
 
static sk_sp< ClipTileRendererMakeShader (const char *name, sk_sp< SkImage > image, sk_sp< SkShader > shader, bool local)
 
static sk_sp< ClipTileRendererMakeColorFilter (const char *name, sk_sp< SkImage > image, sk_sp< SkColorFilter > filter)
 
static sk_sp< ClipTileRendererMakeImageFilter (const char *name, sk_sp< SkImage > image, sk_sp< SkImageFilter > filter)
 
static sk_sp< ClipTileRendererMakeMaskFilter (const char *name, sk_sp< SkImage > image, sk_sp< SkMaskFilter > filter)
 
static sk_sp< ClipTileRendererMakeAlpha (sk_sp< SkImage > image, SkScalar alpha)
 
static sk_sp< ClipTileRendererMake (const char *topBanner, const char *bottomBanner, sk_sp< SkImage > image, sk_sp< SkShader > shader, sk_sp< SkColorFilter > colorFilter, sk_sp< SkImageFilter > imageFilter, sk_sp< SkMaskFilter > maskFilter, SkScalar paintAlpha, bool resetAfterEachQuad, int transformCount)
 

Additional Inherited Members

- Protected Member Functions inherited from ClipTileRenderer
SkCanvas::QuadAAFlags maskToFlags (const bool edgeAA[4]) const
 
int clipTile (SkCanvas *canvas, int tileID, const SkRect &baseRect, const SkPoint quad[4], const bool edgeAA[4], const SkPoint lines[], int lineCount, int *quadCount)
 

Detailed Description

Definition at line 648 of file compositor_quads.cpp.

Member Function Documentation

◆ drawBanner()

void TextureSetRenderer::drawBanner ( SkCanvas canvas)
inlineoverridevirtual

Implements ClipTileRenderer.

Definition at line 764 of file compositor_quads.cpp.

764 {
765 if (fTopBanner.size() > 0) {
766 draw_text(canvas, fTopBanner.c_str());
767 }
768 canvas->translate(0.f, 15.f);
769 if (fBottomBanner.size() > 0) {
770 draw_text(canvas, fBottomBanner.c_str());
771 }
772 }
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133
static void draw_text(SkCanvas *canvas, const char *text)

◆ drawTile()

int TextureSetRenderer::drawTile ( SkCanvas canvas,
const SkRect rect,
const SkPoint  clip[4],
const bool  edgeAA[4],
int  tileID,
int  quadID 
)
inlineoverridevirtual

Implements ClipTileRenderer.

Definition at line 709 of file compositor_quads.cpp.

710 {
711 // Now don't actually draw the tile, accumulate it in the growing entry set
712 bool hasClip = false;
713 if (clip) {
714 // Record the four points into fDstClips
715 fDstClips.push_back_n(4, clip);
716 hasClip = true;
717 }
718
719 int matrixIdx = -1;
720 if (!fResetEachQuad && fTransformBatchCount > 0) {
721 // Handle transform batching. This works by capturing the CTM of the first tile draw,
722 // and then calculate the difference between that and future CTMs for later tiles.
723 if (fPreViewMatrices.size() == 0) {
724 fBaseCTM = canvas->getTotalMatrix();
725 fPreViewMatrices.push_back(SkMatrix::I());
726 matrixIdx = 0;
727 } else {
728 // Calculate matrix s.t. getTotalMatrix() = fBaseCTM * M
729 SkMatrix invBase;
730 if (!fBaseCTM.invert(&invBase)) {
731 SkDebugf("Cannot invert CTM, transform batching will not be correct.\n");
732 } else {
733 SkMatrix preView = SkMatrix::Concat(invBase, canvas->getTotalMatrix());
734 if (preView != fPreViewMatrices[fPreViewMatrices.size() - 1]) {
735 // Add the new matrix
736 fPreViewMatrices.push_back(preView);
737 } // else re-use the last matrix
738 matrixIdx = fPreViewMatrices.size() - 1;
739 }
740 }
741 }
742
743 // This acts like the whole image is rendered over the entire tile grid, so derive local
744 // coordinates from 'rect', based on the grid to image transform.
747 SkRect::MakeWH(fImage->width(),
748 fImage->height()));
749 SkRect localRect = gridToImage.mapRect(rect);
750
751 // drawTextureSet automatically derives appropriate local quad from localRect if clipPtr
752 // is not null.
753 fSetEntries.push_back(
754 {fImage, localRect, rect, matrixIdx, 1.f, this->maskToFlags(edgeAA), hasClip});
755
756 if (fResetEachQuad) {
757 // Only ever draw one entry at a time
758 return this->drawAndReset(canvas);
759 } else {
760 return 0;
761 }
762 }
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
SkCanvas::QuadAAFlags maskToFlags(const bool edgeAA[4]) const
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition: SkMatrix.h:1775
bool invert(SkMatrix *inverse) const
Definition: SkMatrix.h:1206
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
T * push_back_n(int n)
Definition: SkTArray.h:267
int size() const
Definition: SkTArray.h:421
static constexpr SkScalar kTileHeight
static constexpr SkScalar kTileWidth
static constexpr int kRowCount
static constexpr int kColCount
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ drawTiles()

int TextureSetRenderer::drawTiles ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from ClipTileRenderer.

Definition at line 702 of file compositor_quads.cpp.

702 {
703 int draws = this->INHERITED::drawTiles(canvas);
704 // Push the last tile set
705 draws += this->drawAndReset(canvas);
706 return draws;
707 }
virtual int drawTiles(SkCanvas *canvas)

◆ Make()

static sk_sp< ClipTileRenderer > TextureSetRenderer::Make ( const char *  topBanner,
const char *  bottomBanner,
sk_sp< SkImage image,
sk_sp< SkShader shader,
sk_sp< SkColorFilter colorFilter,
sk_sp< SkImageFilter imageFilter,
sk_sp< SkMaskFilter maskFilter,
SkScalar  paintAlpha,
bool  resetAfterEachQuad,
int  transformCount 
)
inlinestatic

Definition at line 691 of file compositor_quads.cpp.

696 {
697 return sk_sp<ClipTileRenderer>(new TextureSetRenderer(topBanner, bottomBanner,
698 std::move(image), std::move(shader), std::move(colorFilter), std::move(imageFilter),
699 std::move(maskFilter), paintAlpha, resetAfterEachQuad, transformCount));
700 }
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ MakeAlpha()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeAlpha ( sk_sp< SkImage image,
SkScalar  alpha 
)
inlinestatic

Definition at line 686 of file compositor_quads.cpp.

686 {
687 return Make("Alpha", SkStringPrintf("a = %.2f", alpha).c_str(), std::move(image), nullptr,
688 nullptr, nullptr, nullptr, alpha, false, 0);
689 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static sk_sp< ClipTileRenderer > Make(const char *topBanner, const char *bottomBanner, sk_sp< SkImage > image, sk_sp< SkShader > shader, sk_sp< SkColorFilter > colorFilter, sk_sp< SkImageFilter > imageFilter, sk_sp< SkMaskFilter > maskFilter, SkScalar paintAlpha, bool resetAfterEachQuad, int transformCount)

◆ MakeBatched()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeBatched ( sk_sp< SkImage image,
int  transformCount 
)
inlinestatic

Definition at line 656 of file compositor_quads.cpp.

656 {
657 const char* subtitle = transformCount == 0 ? "" : "w/ xforms";
658 return Make("Texture Set", subtitle, std::move(image), nullptr, nullptr, nullptr, nullptr,
659 1.f, false, transformCount);
660 }

◆ MakeColorFilter()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeColorFilter ( const char *  name,
sk_sp< SkImage image,
sk_sp< SkColorFilter filter 
)
inlinestatic

Definition at line 668 of file compositor_quads.cpp.

669 {
670 return Make("Color Filter", name, std::move(image), nullptr, std::move(filter), nullptr,
671 nullptr, 1.f, false, 0);
672 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ MakeImageFilter()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeImageFilter ( const char *  name,
sk_sp< SkImage image,
sk_sp< SkImageFilter filter 
)
inlinestatic

Definition at line 674 of file compositor_quads.cpp.

675 {
676 return Make("Image Filter", name, std::move(image), nullptr, nullptr, std::move(filter),
677 nullptr, 1.f, false, 0);
678 }

◆ MakeMaskFilter()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeMaskFilter ( const char *  name,
sk_sp< SkImage image,
sk_sp< SkMaskFilter filter 
)
inlinestatic

Definition at line 680 of file compositor_quads.cpp.

681 {
682 return Make("Mask Filter", name, std::move(image), nullptr, nullptr, nullptr,
683 std::move(filter), 1.f, false, 0);
684 }

◆ MakeShader()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeShader ( const char *  name,
sk_sp< SkImage image,
sk_sp< SkShader shader,
bool  local 
)
inlinestatic

Definition at line 662 of file compositor_quads.cpp.

663 {
664 return Make("Shader", name, std::move(image), std::move(shader),
665 nullptr, nullptr, nullptr, 1.f, local, 0);
666 }

◆ MakeUnbatched()

static sk_sp< ClipTileRenderer > TextureSetRenderer::MakeUnbatched ( sk_sp< SkImage image)
inlinestatic

Definition at line 651 of file compositor_quads.cpp.

651 {
652 return Make("Texture", "", std::move(image), nullptr, nullptr, nullptr, nullptr,
653 1.f, true, 0);
654 }

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