29 void setBuffersGeometry();
34 ANativeWindow_Buffer fBuffer;
42 fWidth = ANativeWindow_getWidth(fNativeWindow);
43 fHeight = ANativeWindow_getHeight(fNativeWindow);
44 this->setBuffersGeometry();
47void RasterWindowContext_android::setBuffersGeometry() {
49 switch(fDisplayParams.fColorType) {
51 format = WINDOW_FORMAT_RGBA_8888;
54 format = WINDOW_FORMAT_RGB_565;
57 SK_ABORT(
"Unsupported Android color type");
59 ANativeWindow_setBuffersGeometry(fNativeWindow, fWidth, fHeight,
format);
64 this->setBuffersGeometry();
67void RasterWindowContext_android::resize(
int w,
int h) {
70 this->setBuffersGeometry();
74 if (
nullptr == fBackbufferSurface) {
75 ANativeWindow_lock(fNativeWindow, &fBuffer, &
fBounds);
76 const int bytePerPixel = fBuffer.format == WINDOW_FORMAT_RGB_565 ? 2 : 4;
78 fDisplayParams.fColorType,
80 fDisplayParams.fColorSpace);
84 return fBackbufferSurface;
88void RasterWindowContext_android::onSwapBuffers() {
89 ANativeWindow_unlockAndPost(fNativeWindow);
90 fBackbufferSurface.reset(
nullptr);
97 std::unique_ptr<WindowContext> ctx(
new RasterWindowContext_android(
window,
params));
98 if (!ctx->isValid()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SK_ABORT(message,...)
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static constexpr bool SkToBool(const T &x)
virtual sk_sp< SkSurface > getBackbufferSurface()=0
virtual void setDisplayParams(const DisplayParams ¶ms)=0
virtual void resize(int w, int h)=0
virtual void onSwapBuffers()=0
const EmbeddedViewParams * params
uint32_t uint32_t * format
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
std::unique_ptr< WindowContext > MakeRasterForAndroid(ANativeWindow *window, const DisplayParams ¶ms)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
struct ANativeWindow ANativeWindow