Skip to content

Commit

Permalink
GRAPHICS: Use ScopedPtr in the Aurora texture class
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 26, 2016
1 parent 8419e09 commit f3bec6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/graphics/aurora/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ namespace Graphics {

namespace Aurora {

Texture::Texture() : _type(::Aurora::kFileTypeNone), _image(0), _txi(0), _width(0), _height(0) {
Texture::Texture() : _type(::Aurora::kFileTypeNone), _width(0), _height(0) {
}

Texture::Texture(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi) :
_name(name), _type(type), _image(0), _txi(0), _width(0), _height(0) {
_name(name), _type(type), _width(0), _height(0) {

set(name, image, type, txi);
addToQueues();
Expand All @@ -70,9 +70,6 @@ Texture::~Texture() {

if (_textureID != 0)
GfxMan.abandon(&_textureID, 1);

delete _txi;
delete _image;
}

uint32 Texture::getWidth() const {
Expand Down Expand Up @@ -364,13 +361,11 @@ Texture *Texture::create(ImageDecoder *image, ::Aurora::FileType type, TXI *txi)
}

void Texture::set(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi) {
delete _image;
delete _txi;

_name = name;
_image = image;
_type = type;
_txi = txi;

_image.reset(image);
_txi.reset(txi);

_width = _image->getMipMap(0).width;
_height = _image->getMipMap(0).height;
Expand Down
5 changes: 3 additions & 2 deletions src/graphics/aurora/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef GRAPHICS_AURORA_TEXTURE_H
#define GRAPHICS_AURORA_TEXTURE_H

#include "src/common/scopedptr.h"
#include "src/common/ustring.h"

#include "src/graphics/types.h"
Expand Down Expand Up @@ -83,8 +84,8 @@ class Texture : public Graphics::Texture {
Common::UString _name; ///< The name of the texture's image's file.
::Aurora::FileType _type; ///< The type of the texture's image's file.

ImageDecoder *_image; ///< The actual image.
TXI *_txi; ///< The TXI.
Common::ScopedPtr<ImageDecoder> _image; ///< The actual image.
Common::ScopedPtr<TXI> _txi; ///< The TXI.

uint32 _width;
uint32 _height;
Expand Down

0 comments on commit f3bec6e

Please sign in to comment.