Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 5 of file Image_MakeBackendTextureFromImage.cpp.

5 {
9 SkCanvas* canvas = surface->getCanvas();
10 canvas->clear(SK_ColorWHITE);
12 paint.setColor(SK_ColorBLACK);
13 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint);
14 return surface->makeImageSnapshot();
15 }
16
17 void draw(SkCanvas * canvas) {
18 auto dContext = GrAsDirectContext(canvas->recordingContext());
19 if (!dContext) {
20 return;
21 }
22 sk_sp<SkImage> backEndImage = create_gpu_image(dContext);
23 canvas->drawImage(backEndImage, 0, 0);
27 dContext, std::move(backEndImage), &texture, &proc)) {
28 return;
29 }
31 texture,
33 kN32_SkColorType,
35 nullptr);
36 canvas->drawImage(i2, 30, 30);
37 }
38} // 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)
@ 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)
virtual GrRecordingContext * recordingContext() const
void clear(SkColor color)
Definition SkCanvas.h:1199
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
FlTexture * texture
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
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