Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imagedecoderfactory.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 1995-2003 Opera Software AS. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. **
  8. */
  9. #ifndef IMAGEDECODERFACTORY_H
  10. #define IMAGEDECODERFACTORY_H
  11. class ImageDecoder;
  12. class ImageDecoderListener;
  13. /**
  14. * An ImageDecoderFactory can create ImageDecoder objects that can decode images of a specific
  15. * type. It can also check if it can decode a specific size, and peek the size of an image given
  16. * a small amount of data.
  17. */
  18. class ImageDecoderFactory
  19. {
  20. public:
  21. /**
  22. * Deletes the ImageDecoder factory object.
  23. */
  24. virtual ~ImageDecoderFactory() {}
  25. #if defined(INTERNAL_IMG_DECODERS_SUPPORT) || defined(ASYNC_IMAGE_DECODERS_EMULATION)
  26. /**
  27. * Creates an image decoder belonging to this factory.
  28. * @return the ImageDecoder created, or NULL if OOM.
  29. * @param listener, the listener that will be called by the image decoder.
  30. */
  31. virtual ImageDecoder* CreateImageDecoder(ImageDecoderListener* listener) = 0;
  32. #endif // INTERNAL_IMG_DECODERS_SUPPORT
  33. /**
  34. * Check the size of an image.
  35. * @return YES if width and height could be found, NO if we cannot find the size, and MAYBE if we might find the size with more data.
  36. * @param data pointer to the data to check the size for, must point to the start of the data stream.
  37. * @param len length of the data to check size for.
  38. * @param width will be set to the width of the image, if return value is YES.
  39. * @param height will be set to the height of the image, if return value is YES.
  40. */
  41. virtual BOOL3 CheckSize(const UCHAR* data, INT32 len, INT32& width, INT32& height) = 0;
  42. /**
  43. * Check if the type of an image is supported by this ImageDecoderFactory.
  44. * @return YES if this factory can create decoders for this type of image, NO if it cannot, and MAYBE if it need more data to find out if that is possible.
  45. * @param data pointer to the data to check the type for, must point to the start of the data stream.
  46. * @param len length of the data to check the type for.
  47. */
  48. virtual BOOL3 CheckType(const UCHAR* data, INT32 len) = 0;
  49. };
  50. #ifdef ASYNC_IMAGE_DECODERS
  51. /**
  52. * When using asynchronous image decoders, we need an interface that is readding the CreateImageDecoder
  53. * function to the ImageDecoder interface, since we do not want to be able to create image decoders in
  54. * the image decoder factories that is only used to check for type and for size.
  55. */
  56. class AsyncImageDecoderFactory
  57. {
  58. public:
  59. static OP_STATUS Create(AsyncImageDecoderFactory** new_decoder);
  60. virtual ~AsyncImageDecoderFactory() {}
  61. /**
  62. * Create an image decoder belonging to this factory. This interface is needed since when using
  63. * asynchronous image decoding, the normal image decoder objects will not have this function.
  64. * @return the image decoder created, or NULL if OOM.
  65. * @param listener, the listener that will be called by the image decoder.
  66. * @param type, when using asynchronous image decoding emulation, we also need to give this function the type to create. The emulated asynchronous decoder factory will then create an asynchronous image decoder, which owns a image decoder of the specified type, that is used to actually decode the image.
  67. */
  68. virtual ImageDecoder* CreateImageDecoder(ImageDecoderListener* listener
  69. #ifdef ASYNC_IMAGE_DECODERS_EMULATION
  70. , int type
  71. #endif // ASYNC_IMAGE_DECODERS_EMULATION
  72. ) = 0;
  73. };
  74. #endif // ASYNC_IMAGE_DECODERS
  75. inline UINT32 MakeUINT32(UCHAR c0, UCHAR c1, UCHAR c2, UCHAR c3)
  76. {
  77. return
  78. c0 << 24 |
  79. c1 << 16 |
  80. c2 << 8 |
  81. c3;
  82. }
  83. #endif // !IMAGEDECODERFACTORY_H