gvplugin_quartz.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #include "config.h"
  11. #include <common/types.h>
  12. #include <gvc/gvplugin.h>
  13. #include "gvplugin_quartz.h"
  14. #include <gvc/gvio.h>
  15. extern gvplugin_installed_t gvrender_quartz_types;
  16. extern gvplugin_installed_t gvtextlayout_quartz_types;
  17. extern gvplugin_installed_t gvloadimage_quartz_types;
  18. extern gvplugin_installed_t gvdevice_quartz_types;
  19. #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040
  20. extern gvplugin_installed_t gvdevice_quartz_types_for_cairo;
  21. #endif
  22. /* data consumer backed by the gvdevice */
  23. static size_t device_data_consumer_put_bytes (void *info, const void *buffer, size_t count)
  24. {
  25. return gvwrite(info, buffer, count);
  26. }
  27. CGDataConsumerCallbacks device_data_consumer_callbacks = {
  28. device_data_consumer_put_bytes,
  29. NULL
  30. };
  31. #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040 || __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000
  32. CFStringRef format_to_uti(format_type format)
  33. {
  34. switch (format) {
  35. case FORMAT_BMP:
  36. return CFSTR("com.microsoft.bmp");
  37. case FORMAT_EXR:
  38. return CFSTR("com.ilm.openexr-image");
  39. case FORMAT_GIF:
  40. return CFSTR("com.compuserve.gif");
  41. case FORMAT_ICNS:
  42. return CFSTR("com.apple.icns");
  43. case FORMAT_ICO:
  44. return CFSTR("com.microsoft.ico");
  45. case FORMAT_JPEG:
  46. return CFSTR("public.jpeg");
  47. case FORMAT_JPEG2000:
  48. return CFSTR("public.jpeg-2000");
  49. case FORMAT_PICT:
  50. return CFSTR("com.apple.pict");
  51. case FORMAT_PNG:
  52. return CFSTR("public.png");
  53. case FORMAT_PSD:
  54. return CFSTR("com.adobe.photoshop-image");
  55. case FORMAT_SGI:
  56. return CFSTR("com.sgi.sgi-image");
  57. case FORMAT_TIFF:
  58. return CFSTR("public.tiff");
  59. case FORMAT_TGA:
  60. return CFSTR("com.truevision.tga-image");
  61. default:
  62. return NULL;
  63. }
  64. }
  65. #endif
  66. static gvplugin_api_t apis[] = {
  67. {API_render, &gvrender_quartz_types},
  68. {API_textlayout, &gvtextlayout_quartz_types},
  69. {API_loadimage, &gvloadimage_quartz_types},
  70. {API_device, &gvdevice_quartz_types},
  71. #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040 && defined(HAVE_PANGOCAIRO)
  72. {API_device, &gvdevice_quartz_types_for_cairo},
  73. #endif
  74. {(api_t)0, 0},
  75. };
  76. gvplugin_library_t gvplugin_quartz_LTX_library = { "quartz", apis };