Flutter Engine
The Flutter Engine
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
REG_FIDDLE
(Image_AdoptTextureFrom, 256, 256,
false
, 5) {
5
void
draw
(
SkCanvas
* canvas) {
6
GrDirectContext
* dContext =
GrAsDirectContext
(canvas->
recordingContext
());
7
// Example does not support DDL.
8
if
(!dContext) {
9
return
;
10
}
11
canvas->
scale
(.5f, .5f);
12
canvas->
clear
(0x7f3f5f7f);
13
int
x
= 0,
y
= 0;
14
for
(
auto
origin : {
kBottomLeft_GrSurfaceOrigin
,
kTopLeft_GrSurfaceOrigin
} ) {
15
for
(
auto
alpha : {
kOpaque_SkAlphaType
,
kPremul_SkAlphaType
,
kUnpremul_SkAlphaType
} ) {
16
sk_sp<SkImage>
image
=
SkImages::AdoptTextureFrom
(
17
dContext,
backEndTexture
, origin,
kRGBA_8888_SkColorType
, alpha);
18
canvas->
drawImage
(
image
,
x
,
y
);
19
x
+= 160;
20
}
21
x
-= 160 * 3;
22
y
+= 256;
23
}
24
}
25
}
// 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
REG_FIDDLE
REG_FIDDLE(Image_AdoptTextureFrom, 256, 256, false, 5)
Definition:
Image_AdoptTextureFrom.cpp:4
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:1637
SkCanvas::clear
void clear(SkColor color)
Definition:
SkCanvas.h:1199
SkCanvas::scale
void scale(SkScalar sx, SkScalar sy)
Definition:
SkCanvas.cpp:1289
SkCanvas::drawImage
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition:
SkCanvas.h:1528
sk_sp< SkImage >
backEndTexture
GrBackendTexture backEndTexture
Definition:
examples.cpp:25
examples.h
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
SkRecords::image
sk_sp< const SkImage > image
Definition:
SkRecords.h:269
Generated on Sun Jun 23 2024 21:55:55 for Flutter Engine by
1.9.4