Flutter Engine
The Flutter Engine
Surface_readPixels_2.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(Surface_readPixels_2, 256, 64, false, 0) {
5void draw(SkCanvas* canvas) {
7 auto surfCanvas = surf->getCanvas();
8 surfCanvas->clear(SK_ColorRED);
10 surfCanvas->drawOval({4, 8, 58, 54}, paint);
12 sk_sp<SkData> data(SkData::MakeUninitialized(info.minRowBytes() * info.height()));
13 sk_bzero(data->writable_data(), info.minRowBytes() * info.height());
14 for (int x : { 32, -32 } ) {
15 for (int y : { 32, -32 } ) {
16 surf->readPixels(info, data->writable_data(), info.minRowBytes(), x, y);
17 }
18 }
20 canvas->drawImage(image, 0, 0);
21}
22} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
sk_bzero(glyphs, sizeof(glyphs))
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
REG_FIDDLE(Surface_readPixels_2, 256, 64, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
bool readPixels(const SkPixmap &dst, int srcX, int srcY)
Definition: SkSurface.cpp:125
const Paint & paint
Definition: color_source.cc:38
double y
double x
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63