sk_surface.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. */
  7. // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
  8. // DO NOT USE -- FOR INTERNAL TESTING ONLY
  9. #ifndef sk_surface_DEFINED
  10. #define sk_surface_DEFINED
  11. #include "include/c/sk_types.h"
  12. SK_C_PLUS_PLUS_BEGIN_GUARD
  13. /**
  14. Return a new surface, with the memory for the pixels automatically
  15. allocated. If the requested surface cannot be created, or the
  16. request is not a supported configuration, NULL will be returned.
  17. @param sk_imageinfo_t* Specify the width, height, color type, and
  18. alpha type for the surface.
  19. @param sk_surfaceprops_t* If not NULL, specify additional non-default
  20. properties of the surface.
  21. */
  22. SK_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, const sk_surfaceprops_t*);
  23. /**
  24. Create a new surface which will draw into the specified pixels
  25. with the specified rowbytes. If the requested surface cannot be
  26. created, or the request is not a supported configuration, NULL
  27. will be returned.
  28. @param sk_imageinfo_t* Specify the width, height, color type, and
  29. alpha type for the surface.
  30. @param void* pixels Specify the location in memory where the
  31. destination pixels are. This memory must
  32. outlast this surface.
  33. @param size_t rowBytes Specify the difference, in bytes, between
  34. each adjacent row. Should be at least
  35. (width * sizeof(one pixel)).
  36. @param sk_surfaceprops_t* If not NULL, specify additional non-default
  37. properties of the surface.
  38. */
  39. SK_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*,
  40. void* pixels, size_t rowBytes,
  41. const sk_surfaceprops_t* props);
  42. /**
  43. Decrement the reference count. If the reference count is 1 before
  44. the decrement, then release both the memory holding the
  45. sk_surface_t and any pixel memory it may be managing. New
  46. sk_surface_t are created with a reference count of 1.
  47. */
  48. SK_API void sk_surface_unref(sk_surface_t*);
  49. /**
  50. * Return the canvas associated with this surface. Note: the canvas is owned by the surface,
  51. * so the returned object is only valid while the owning surface is valid.
  52. */
  53. SK_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
  54. /**
  55. * Call sk_image_unref() when the returned image is no longer used.
  56. */
  57. SK_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
  58. SK_C_PLUS_PLUS_END_GUARD
  59. #endif