Flutter Engine
The Flutter Engine
Functions
Image_MakeBackendTextureFromImage.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Image_MakeBackendTextureFromImage, 256, 64, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Image_MakeBackendTextureFromImage  ,
256  ,
64  ,
false  ,
 
)

Definition at line 4 of file Image_MakeBackendTextureFromImage.cpp.

4 {
8 SkCanvas* canvas = surface->getCanvas();
9 canvas->clear(SK_ColorWHITE);
11 paint.setColor(SK_ColorBLACK);
12 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint);
13 return surface->makeImageSnapshot();
14 }
15
16 void draw(SkCanvas * canvas) {
17 auto dContext = GrAsDirectContext(canvas->recordingContext());
18 if (!dContext) {
19 return;
20 }
21 sk_sp<SkImage> backEndImage = create_gpu_image(dContext);
22 canvas->drawImage(backEndImage, 0, 0);
26 dContext, std::move(backEndImage), &texture, &proc)) {
27 return;
28 }
30 texture,
32 kN32_SkColorType,
34 nullptr);
35 canvas->drawImage(i2, 30, 30);
36 }
37} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
static sk_sp< SkImage > create_gpu_image(GrRecordingContext *rContext, bool withMips=false, skgpu::Budgeted budgeted=skgpu::Budgeted::kYes)
Definition: ImageTest.cpp:210
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
FlTexture * texture
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Definition: SkImageGanesh.h:43
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API bool MakeBackendTextureFromImage(GrDirectContext *context, sk_sp< SkImage > image, GrBackendTexture *backendTexture, BackendTextureReleaseProc *backendTextureReleaseProc)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659