/indra/llimage/llimageworker.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 104 lines · 62 code · 13 blank · 29 comment · 0 complexity · ec9c129f507a77af8ebf8ba523bcde50 MD5 · raw file

  1. /**
  2. * @file llimageworker.h
  3. * @brief Object for managing images and their textures.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLIMAGEWORKER_H
  27. #define LL_LLIMAGEWORKER_H
  28. #include "llimage.h"
  29. #include "llpointer.h"
  30. #include "llworkerthread.h"
  31. class LLImageDecodeThread : public LLQueuedThread
  32. {
  33. public:
  34. class Responder : public LLThreadSafeRefCount
  35. {
  36. protected:
  37. virtual ~Responder();
  38. public:
  39. virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0;
  40. };
  41. class ImageRequest : public LLQueuedThread::QueuedRequest
  42. {
  43. protected:
  44. virtual ~ImageRequest(); // use deleteRequest()
  45. public:
  46. ImageRequest(handle_t handle, LLImageFormatted* image,
  47. U32 priority, S32 discard, BOOL needs_aux,
  48. LLImageDecodeThread::Responder* responder);
  49. /*virtual*/ bool processRequest();
  50. /*virtual*/ void finishRequest(bool completed);
  51. // Used by unit tests to check the consitency of the request instance
  52. bool tut_isOK();
  53. private:
  54. // input
  55. LLPointer<LLImageFormatted> mFormattedImage;
  56. S32 mDiscardLevel;
  57. BOOL mNeedsAux;
  58. // output
  59. LLPointer<LLImageRaw> mDecodedImageRaw;
  60. LLPointer<LLImageRaw> mDecodedImageAux;
  61. BOOL mDecodedRaw;
  62. BOOL mDecodedAux;
  63. LLPointer<LLImageDecodeThread::Responder> mResponder;
  64. };
  65. public:
  66. LLImageDecodeThread(bool threaded = true);
  67. virtual ~LLImageDecodeThread();
  68. handle_t decodeImage(LLImageFormatted* image,
  69. U32 priority, S32 discard, BOOL needs_aux,
  70. Responder* responder);
  71. S32 update(F32 max_time_ms);
  72. // Used by unit tests to check the consistency of the thread instance
  73. S32 tut_size();
  74. private:
  75. struct creation_info
  76. {
  77. handle_t handle;
  78. LLPointer<LLImageFormatted> image;
  79. U32 priority;
  80. S32 discard;
  81. BOOL needs_aux;
  82. LLPointer<Responder> responder;
  83. creation_info(handle_t h, LLImageFormatted* i, U32 p, S32 d, BOOL aux, Responder* r)
  84. : handle(h), image(i), priority(p), discard(d), needs_aux(aux), responder(r)
  85. {}
  86. };
  87. typedef std::list<creation_info> creation_list_t;
  88. creation_list_t mCreationList;
  89. LLMutex* mCreationMutex;
  90. };
  91. #endif