Flutter Engine
The Flutter Engine
Image_BorrowTextureFrom.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Image_BorrowTextureFrom, 256, 128, false, 3) {
5void draw(SkCanvas* canvas) {
6 auto dContext = GrAsDirectContext(canvas->recordingContext());
7 if (!dContext) {
8 return;
9 }
10
11 canvas->scale(.25f, .25f);
12 int x = 0;
16 origin,
19 nullptr);
20 canvas->drawImage(image, x, 0);
21 x += 512;
22 }
23}
24} // END FIDDLE
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
REG_FIDDLE(Image_BorrowTextureFrom, 256, 128, false, 3)
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
GrBackendTexture backEndTexture
Definition: examples.cpp:25
double x
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_sp< const SkImage > image
Definition: SkRecords.h:269