2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "SkMaskFilter.h"
15 #include "SkPictureRecorder.h"
16 #include "SkSurface.h"
18 #include "sk_canvas.h"
23 #include "sk_picture.h"
24 #include "sk_surface.h"
26 #include "sk_types_priv.h"
28 sk_colortype_t sk_colortype_get_default_8888() {
29 return (sk_colortype_t)SkColorType::kN32_SkColorType;
32 sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t* cinfo, const sk_surfaceprops_t* props) {
34 from_c(*cinfo, &info);
35 SkSurfaceProps* surfProps = nullptr;
37 from_c(props, surfProps);
39 return ToSurface(SkSurface::MakeRaster(info, surfProps).release());
42 sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_surfaceprops_t* props) {
44 from_c(*cinfo, &info);
45 SkSurfaceProps* surfProps = nullptr;
47 from_c(props, surfProps);
49 return ToSurface(SkSurface::MakeRasterDirect(info, pixels, rowBytes, surfProps).release());
52 void sk_surface_unref(sk_surface_t* csurf) {
53 SkSafeUnref(AsSurface(csurf));
56 sk_canvas_t* sk_surface_get_canvas(sk_surface_t* csurf) {
57 return ToCanvas(AsSurface(csurf)->getCanvas());
60 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t* csurf) {
61 return ToImage(AsSurface(csurf)->makeImageSnapshot().release());
64 sk_surface_t* sk_surface_new_backend_render_target(gr_context_t* context, const gr_backend_rendertarget_desc_t* desc, const sk_surfaceprops_t* props) {
65 SkSurfaceProps* surfProps = nullptr;
67 from_c(props, surfProps);
69 return ToSurface(SkSurface::MakeFromBackendRenderTarget(AsGrContext(context), AsGrBackendRenderTargetDesc(*desc), surfProps).release());
72 sk_surface_t* sk_surface_new_backend_texture(gr_context_t* context, const gr_backend_texture_desc_t* desc, const sk_surfaceprops_t* props) {
73 SkSurfaceProps* surfProps = nullptr;
75 from_c(props, surfProps);
77 return ToSurface(SkSurface::MakeFromBackendTexture(AsGrContext(context), AsGrBackendTextureDesc(*desc), surfProps).release());
80 sk_surface_t* sk_surface_new_backend_texture_as_render_target(gr_context_t* context, const gr_backend_texture_desc_t* desc, const sk_surfaceprops_t* props) {
81 SkSurfaceProps* surfProps = nullptr;
83 from_c(props, surfProps);
85 return ToSurface(SkSurface::MakeFromBackendTextureAsRenderTarget(AsGrContext(context), AsGrBackendTextureDesc(*desc), surfProps).release());
88 sk_surface_t* sk_surface_new_render_target(gr_context_t* context, bool budgeted, const sk_imageinfo_t* cinfo, int sampleCount, const sk_surfaceprops_t* props) {
90 from_c(*cinfo, &info);
91 SkSurfaceProps* surfProps = nullptr;
93 from_c(props, surfProps);
95 return ToSurface(SkSurface::MakeRenderTarget(AsGrContext(context), (SkBudgeted)budgeted, info, sampleCount, surfProps).release());