Skip to content

Commit

Permalink
Refactor|libgui: Interface cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 28, 2013
1 parent eab4b49 commit 18099ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doomsday/libgui/include/de/gui/drawable.h
Expand Up @@ -106,10 +106,10 @@ class LIBGUI_PUBLIC Drawable : public AssetGroup
* @param id Identifier of the buffer.
* @return GL buffer.
*/
GLBuffer &buffer(Id id) const;
GLBuffer &buffer(Id id = 1) const;

template <typename VBType>
VBType &buffer(Id id) const {
VBType &buffer(Id id = 1) const {
DENG2_ASSERT(dynamic_cast<VBType *>(&buffer(id)) != 0);
return static_cast<VBType &>(buffer(id));
}
Expand Down
8 changes: 8 additions & 0 deletions doomsday/libgui/include/de/gui/image.h
Expand Up @@ -99,6 +99,9 @@ class LIBGUI_PUBLIC Image : public ISerializable
Size size() const;
Rectanglei rect() const;

duint width() const { return size().x; }
duint height() const { return size().y; }

/**
* Number of bits per pixel.
*/
Expand All @@ -118,6 +121,11 @@ class LIBGUI_PUBLIC Image : public ISerializable

void *bits();

/**
* Determines if the image has a zero size (no pixels).
*/
bool isNull() const;

/**
* Determines if the image format can be uploaded to OpenGL without
* conversion of any kind.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/atlas.cpp
Expand Up @@ -208,7 +208,7 @@ Atlas::Size Atlas::totalSize() const

Id Atlas::alloc(Image const &image)
{
if(image.size() == Image::Size(0, 0))
if(image.isNull())
{
return Id::None;
}
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libgui/src/image.cpp
Expand Up @@ -190,6 +190,11 @@ void *Image::bits()
return d->refPixels.base();
}

bool Image::isNull() const
{
return size() == Size(0, 0);
}

bool Image::isGLCompatible() const
{
if(d->format == UseQImageFormat)
Expand Down

0 comments on commit 18099ec

Please sign in to comment.