Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
docs
examples
Image_AdoptTextureFrom.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.
3
#include "
tools/fiddle/examples.h
"
4
// HASH=b034517e39394b7543f06ec885e36d7d
5
REG_FIDDLE
(Image_AdoptTextureFrom, 256, 256,
false
, 5) {
6
void
draw
(
SkCanvas
* canvas) {
7
GrDirectContext
* dContext =
GrAsDirectContext
(canvas->
recordingContext
());
8
// Example does not support DDL.
9
if
(!dContext) {
10
return
;
11
}
12
canvas->
scale
(.5f, .5f);
13
canvas->
clear
(0x7f3f5f7f);
14
int
x
= 0,
y
= 0;
15
for
(
auto
origin : {
kBottomLeft_GrSurfaceOrigin
,
kTopLeft_GrSurfaceOrigin
} ) {
16
for
(
auto
alpha : {
kOpaque_SkAlphaType
,
kPremul_SkAlphaType
,
kUnpremul_SkAlphaType
} ) {
17
sk_sp<SkImage>
image
=
SkImages::AdoptTextureFrom
(
18
dContext,
backEndTexture
, origin,
kRGBA_8888_SkColorType
, alpha);
19
canvas->
drawImage
(
image
,
x
,
y
);
20
x
+= 160;
21
}
22
x
-= 160 * 3;
23
y
+= 256;
24
}
25
}
26
}
// END FIDDLE
GrAsDirectContext
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
Definition
GrRecordingContext.h:281
kBottomLeft_GrSurfaceOrigin
@ kBottomLeft_GrSurfaceOrigin
Definition
GrTypes.h:149
kTopLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
Definition
GrTypes.h:148
kUnpremul_SkAlphaType
kUnpremul_SkAlphaType
Definition
ReadPixBench.cpp:58
kOpaque_SkAlphaType
@ kOpaque_SkAlphaType
pixel is opaque
Definition
SkAlphaType.h:28
kPremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition
SkAlphaType.h:29
kRGBA_8888_SkColorType
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition
SkColorType.h:24
draw
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition
aaclip.cpp:27
GrDirectContext
Definition
GrDirectContext.h:60
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::recordingContext
virtual GrRecordingContext * recordingContext() const
Definition
SkCanvas.cpp:1961
SkCanvas::clear
void clear(SkColor color)
Definition
SkCanvas.h:1199
SkCanvas::scale
void scale(SkScalar sx, SkScalar sy)
Definition
SkCanvas.cpp:1613
SkCanvas::drawImage
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition
SkCanvas.h:1528
sk_sp
Definition
SkRefCnt.h:220
image
sk_sp< SkImage > image
Definition
examples.cpp:29
backEndTexture
GrBackendTexture backEndTexture
Definition
examples.cpp:25
examples.h
REG_FIDDLE
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition
examples.h:60
y
double y
Definition
mouse-input-test.cc:83
x
double x
Definition
mouse-input-test.cc:82
SkImages::AdoptTextureFrom
SK_API sk_sp< SkImage > AdoptTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin textureOrigin, SkColorType colorType)
Definition
SkImage_GaneshFactories.cpp:230
Generated on Fri Apr 26 2024 06:15:38 for Flutter Engine by
1.9.8