Convert more smart pointers in the MovieTexture class.

This commit is contained in:
Brandon W
2025-04-29 21:42:13 -07:00
committed by teejusb
parent a4978f4476
commit 2bd541a927
2 changed files with 11 additions and 16 deletions
+6 -10
View File
@@ -36,7 +36,7 @@ MovieTexture_Generic::MovieTexture_Generic(RageTextureID ID, std::unique_ptr<Mov
texture_lock_ = nullptr; texture_lock_ = nullptr;
rate_ = 1; rate_ = 1;
clock_ = 0; clock_ = 0;
sprite_ = new Sprite; sprite_ = std::make_unique<Sprite>();
} }
RString MovieTexture_Generic::Init() RString MovieTexture_Generic::Init()
@@ -81,8 +81,7 @@ MovieTexture_Generic::~MovieTexture_Generic()
} }
/* sprite_ may reference the texture; delete it before DestroyTexture. */ /* sprite_ may reference the texture; delete it before DestroyTexture. */
delete sprite_; sprite_.reset();
DestroyTexture(); DestroyTexture();
} }
@@ -103,9 +102,6 @@ void MovieTexture_Generic::DestroyTexture()
texture_handle_ = 0; texture_handle_ = 0;
} }
delete render_target_;
render_target_ = nullptr;
delete intermediate_texture_;
intermediate_texture_ = nullptr; intermediate_texture_ = nullptr;
} }
@@ -259,7 +255,7 @@ void MovieTexture_Generic::CreateTexture()
if (fmt != PixelFormatYCbCr_Invalid) if (fmt != PixelFormatYCbCr_Invalid)
{ {
RageUtil::SafeDelete(intermediate_texture_); intermediate_texture_.reset();
sprite_->UnloadTexture(); sprite_->UnloadTexture();
/* Create the render target. This will receive the final, converted texture. */ /* Create the render target. This will receive the final, converted texture. */
@@ -269,13 +265,13 @@ void MovieTexture_Generic::CreateTexture()
RageTextureID TargetID(GetID()); RageTextureID TargetID(GetID());
TargetID.filename += " target"; TargetID.filename += " target";
render_target_ = new RageTextureRenderTarget(TargetID, param); render_target_ = std::make_unique<RageTextureRenderTarget>(TargetID, param);
/* Create the intermediate texture. This receives the YUV image. */ /* Create the intermediate texture. This receives the YUV image. */
RageTextureID IntermedID(GetID()); RageTextureID IntermedID(GetID());
IntermedID.filename += " intermediate"; IntermedID.filename += " intermediate";
intermediate_texture_ = new RageMovieTexture_Generic_Intermediate(IntermedID, intermediate_texture_ = std::make_unique<RageMovieTexture_Generic_Intermediate>(IntermedID,
decoder_->GetWidth(), decoder_->GetHeight(), decoder_->GetWidth(), decoder_->GetHeight(),
surface_->w, surface_->h, surface_->w, surface_->h,
power_of_two(surface_->w), power_of_two(surface_->h), power_of_two(surface_->w), power_of_two(surface_->h),
@@ -289,7 +285,7 @@ void MovieTexture_Generic::CreateTexture()
* when it unloads the texture. Normally we'd make a "copy", but we can't access * when it unloads the texture. Normally we'd make a "copy", but we can't access
* RageTextureManager from here. Just increment the refcount. */ * RageTextureManager from here. Just increment the refcount. */
++intermediate_texture_->m_iRefCount; ++intermediate_texture_->m_iRefCount;
sprite_->SetTexture(intermediate_texture_); sprite_->SetTexture(intermediate_texture_.get());
sprite_->SetEffectMode(GetEffectMode(fmt)); sprite_->SetEffectMode(GetEffectMode(fmt));
return; return;
+5 -6
View File
@@ -120,13 +120,12 @@ private:
bool failure_ = false; bool failure_ = false;
uintptr_t texture_handle_; uintptr_t texture_handle_;
RageTextureRenderTarget *render_target_; std::unique_ptr<RageTextureRenderTarget> render_target_;
RageTexture * intermediate_texture_; std::unique_ptr<RageTexture> intermediate_texture_;
Sprite *sprite_; std::unique_ptr<Sprite> sprite_;
RageSurface *surface_; RageSurface* surface_;
RageTextureLock* texture_lock_;
RageTextureLock *texture_lock_;
/* The time the movie is actually at: */ /* The time the movie is actually at: */
float clock_; float clock_;