PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 27#ifndef LL_LLIMAGEWORKER_H
 28#define LL_LLIMAGEWORKER_H
 29
 30#include "llimage.h"
 31#include "llpointer.h"
 32#include "llworkerthread.h"
 33
 34class LLImageDecodeThread : public LLQueuedThread
 35{
 36public:
 37	class Responder : public LLThreadSafeRefCount
 38	{
 39	protected:
 40		virtual ~Responder();
 41	public:
 42		virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0;
 43	};
 44
 45	class ImageRequest : public LLQueuedThread::QueuedRequest
 46	{
 47	protected:
 48		virtual ~ImageRequest(); // use deleteRequest()
 49		
 50	public:
 51		ImageRequest(handle_t handle, LLImageFormatted* image,
 52					 U32 priority, S32 discard, BOOL needs_aux,
 53					 LLImageDecodeThread::Responder* responder);
 54
 55		/*virtual*/ bool processRequest();
 56		/*virtual*/ void finishRequest(bool completed);
 57
 58		// Used by unit tests to check the consitency of the request instance
 59		bool tut_isOK();
 60		
 61	private:
 62		// input
 63		LLPointer<LLImageFormatted> mFormattedImage;
 64		S32 mDiscardLevel;
 65		BOOL mNeedsAux;
 66		// output
 67		LLPointer<LLImageRaw> mDecodedImageRaw;
 68		LLPointer<LLImageRaw> mDecodedImageAux;
 69		BOOL mDecodedRaw;
 70		BOOL mDecodedAux;
 71		LLPointer<LLImageDecodeThread::Responder> mResponder;
 72	};
 73	
 74public:
 75	LLImageDecodeThread(bool threaded = true);
 76	virtual ~LLImageDecodeThread();
 77
 78	handle_t decodeImage(LLImageFormatted* image,
 79						 U32 priority, S32 discard, BOOL needs_aux,
 80						 Responder* responder);
 81	S32 update(F32 max_time_ms);
 82
 83	// Used by unit tests to check the consistency of the thread instance
 84	S32 tut_size();
 85	
 86private:
 87	struct creation_info
 88	{
 89		handle_t handle;
 90		LLPointer<LLImageFormatted> image;
 91		U32 priority;
 92		S32 discard;
 93		BOOL needs_aux;
 94		LLPointer<Responder> responder;
 95		creation_info(handle_t h, LLImageFormatted* i, U32 p, S32 d, BOOL aux, Responder* r)
 96			: handle(h), image(i), priority(p), discard(d), needs_aux(aux), responder(r)
 97		{}
 98	};
 99	typedef std::list<creation_info> creation_list_t;
100	creation_list_t mCreationList;
101	LLMutex* mCreationMutex;
102};
103
104#endif