Flutter Engine
The Flutter Engine
ganesh_vulkan.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
21
22int main(int argc, char** argv) {
23 // This will not run (since it's missing all the Vulkan setup code),
24 // but it should compile and link to test the build system.
25 skgpu::VulkanBackendContext backendContext;
26
27 std::unique_ptr<skgpu::VulkanExtensions> extensions(new skgpu::VulkanExtensions());
28 backendContext.fInstance = VK_NULL_HANDLE;
29 backendContext.fDevice = VK_NULL_HANDLE;
30
31 // This call will fail if run, due to the context not being set up.
33 if (!ctx) {
34 // There would need to be vulkan cleanup here.
35 return 1;
36 }
37
38 SkImageInfo imageInfo =
40
43 if (!surface) {
44 printf("Could not make surface from Vulkan DirectContext\n");
45 return 1;
46 }
47
48 SkCanvas* canvas = surface->getCanvas();
49 canvas->clear(SK_ColorYELLOW);
50 SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeLTRB(10, 20, 50, 70), 10, 10);
51
53 paint.setColor(SK_ColorMAGENTA);
54 paint.setAntiAlias(true);
55
56 canvas->drawRRect(rrect, paint);
57
58 ctx->flush();
59
60 // There would need to be vulkan cleanup here.
61 return 0;
62}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
int main(int argc, char **argv)
char ** argv
Definition: library.h:9
SK_API sk_sp< GrDirectContext > MakeVulkan(const skgpu::VulkanBackendContext &, const GrContextOptions &)
SkRRect rrect
Definition: SkRecords.h:232
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46