reed | 8e47478 | 2014-10-06 11:00:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
reed | 938dfba | 2014-10-06 06:08:16 -0700 | [diff] [blame] | 7 | |
reed | e332396 | 2014-10-24 11:16:19 -0700 | [diff] [blame] | 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL |
| 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY |
| 10 | |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 11 | #ifndef sk_surface_DEFINED |
| 12 | #define sk_surface_DEFINED |
reed | 8e47478 | 2014-10-06 11:00:51 -0700 | [diff] [blame] | 13 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "include/c/sk_types.h" |
reed | 8e47478 | 2014-10-06 11:00:51 -0700 | [diff] [blame] | 15 | |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD |
reed | 938dfba | 2014-10-06 06:08:16 -0700 | [diff] [blame] | 17 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 18 | /** |
| 19 | Return a new surface, with the memory for the pixels automatically |
| 20 | allocated. If the requested surface cannot be created, or the |
| 21 | request is not a supported configuration, NULL will be returned. |
| 22 | |
| 23 | @param sk_imageinfo_t* Specify the width, height, color type, and |
| 24 | alpha type for the surface. |
| 25 | |
| 26 | @param sk_surfaceprops_t* If not NULL, specify additional non-default |
| 27 | properties of the surface. |
| 28 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 29 | SK_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, const sk_surfaceprops_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | Create a new surface which will draw into the specified pixels |
| 33 | with the specified rowbytes. If the requested surface cannot be |
| 34 | created, or the request is not a supported configuration, NULL |
| 35 | will be returned. |
| 36 | |
| 37 | @param sk_imageinfo_t* Specify the width, height, color type, and |
| 38 | alpha type for the surface. |
| 39 | @param void* pixels Specify the location in memory where the |
| 40 | destination pixels are. This memory must |
| 41 | outlast this surface. |
| 42 | @param size_t rowBytes Specify the difference, in bytes, between |
| 43 | each adjacent row. Should be at least |
| 44 | (width * sizeof(one pixel)). |
| 45 | @param sk_surfaceprops_t* If not NULL, specify additional non-default |
| 46 | properties of the surface. |
| 47 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 48 | SK_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*, |
| 49 | void* pixels, size_t rowBytes, |
| 50 | const sk_surfaceprops_t* props); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | Decrement the reference count. If the reference count is 1 before |
| 54 | the decrement, then release both the memory holding the |
| 55 | sk_surface_t and any pixel memory it may be managing. New |
| 56 | sk_surface_t are created with a reference count of 1. |
| 57 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 58 | SK_API void sk_surface_unref(sk_surface_t*); |
reed | e332396 | 2014-10-24 11:16:19 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Return the canvas associated with this surface. Note: the canvas is owned by the surface, |
| 62 | * so the returned object is only valid while the owning surface is valid. |
| 63 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 64 | SK_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Call sk_image_unref() when the returned image is no longer used. |
| 68 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 69 | SK_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); |
reed | 938dfba | 2014-10-06 06:08:16 -0700 | [diff] [blame] | 70 | |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 71 | SK_C_PLUS_PLUS_END_GUARD |
| 72 | |
reed | 8e47478 | 2014-10-06 11:00:51 -0700 | [diff] [blame] | 73 | #endif |