From 3b043d90b60eca17dfcc014b21c4c8fc5b432384 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 13 Jun 2022 15:18:14 -0400 Subject: SL-17483: Per review feedback, avoid LLPointer refcount twiddling when passing LLPointers into functions. Only increment the refcount when storing in new ImageRequest. --- indra/llimage/llimageworker.cpp | 17 +++++++++++------ indra/llimage/llimageworker.h | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 3c21499673..0093958e6d 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -34,15 +34,17 @@ class ImageRequest { public: - ImageRequest(LLPointer image, + ImageRequest(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder); + const LLPointer& responder); virtual ~ImageRequest(); /*virtual*/ bool processRequest(); /*virtual*/ void finishRequest(bool completed); private: + // LLPointers stored in ImageRequest MUST be LLPointer instances rather + // than references: we need to increment the refcount when storing these. // input LLPointer mFormattedImage; S32 mDiscardLevel; @@ -82,8 +84,11 @@ S32 LLImageDecodeThread::getPending() return mThreadPool->getQueue().size(); } -LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLPointer image, - S32 discard, BOOL needs_aux, LLPointer responder) +LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage( + const LLPointer& image, + S32 discard, + BOOL needs_aux, + const LLPointer& responder) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -113,9 +118,9 @@ LLImageDecodeThread::Responder::~Responder() //---------------------------------------------------------------------------- -ImageRequest::ImageRequest(LLPointer image, +ImageRequest::ImageRequest(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder) + const LLPointer& responder) : mFormattedImage(image), mDiscardLevel(discard), mNeedsAux(needs_aux), diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index 6a0b2b4681..18398d9ae2 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -52,9 +52,9 @@ public: // meant to resemble LLQueuedThread::handle_t typedef U32 handle_t; - handle_t decodeImage(LLPointer image, + handle_t decodeImage(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder); + const LLPointer& responder); S32 getPending(); S32 update(F32 max_time_ms); void shutdown(); -- cgit v1.2.3