Browse Source

Misc

pull/6/head
falkTX 9 years ago
parent
commit
db4c38c4eb
3 changed files with 39 additions and 49 deletions
  1. +1
    -1
      dgl/Color.hpp
  2. +7
    -6
      dgl/NanoVG.hpp
  3. +31
    -42
      dgl/src/NanoVG.cpp

+ 1
- 1
dgl/Color.hpp View File

@@ -38,7 +38,7 @@ struct Color {
};

/**
Create black color.
Create solid black color.
*/
Color() noexcept;



+ 7
- 6
dgl/NanoVG.hpp View File

@@ -25,6 +25,11 @@ struct NVGpaint;

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Forward class names

class NanoVG;

// -----------------------------------------------------------------------
// NanoImage

@@ -72,7 +77,7 @@ public:
NanoImage& operator=(const Handle& handle);

/**
Wherever the image is valid.
Wherever this image is valid.
*/
bool isValid() const noexcept;

@@ -86,16 +91,12 @@ public:
*/
GLuint getTextureHandle() const;

/**
Update image data.
*/
void updateImage(const uchar* const data);

private:
Handle fHandle;
Size<uint> fSize;
friend class NanoVG;

/** @internal */
void _updateSize();

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoImage)


+ 31
- 42
dgl/src/NanoVG.cpp View File

@@ -76,45 +76,13 @@

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Paint

NanoVG::Paint::Paint() noexcept
: radius(0.0f), feather(0.0f), innerColor(), outerColor(), imageId(0)
{
std::memset(xform, 0, sizeof(float)*6);
std::memset(extent, 0, sizeof(float)*2);
}

NanoVG::Paint::Paint(const NVGpaint& p) noexcept
: radius(p.radius), feather(p.feather), innerColor(p.innerColor), outerColor(p.outerColor), imageId(p.image)
{
std::memcpy(xform, p.xform, sizeof(float)*6);
std::memcpy(extent, p.extent, sizeof(float)*2);
}

NanoVG::Paint::operator NVGpaint() const noexcept
{
NVGpaint p;
p.radius = radius;
p.feather = feather;
p.innerColor = innerColor;
p.outerColor = outerColor;
p.image = imageId;
std::memcpy(p.xform, xform, sizeof(float)*6);
std::memcpy(p.extent, extent, sizeof(float)*2);
return p;
}

// -----------------------------------------------------------------------
// NanoImage

NanoImage::NanoImage()
: fHandle(),
fSize(),
leakDetector_NanoImage()
{
}
leakDetector_NanoImage() {}

NanoImage::NanoImage(const Handle& handle)
: fHandle(handle),
@@ -160,15 +128,6 @@ GLuint NanoImage::getTextureHandle() const
return nvglImageHandle(fHandle.context, fHandle.imageId);
}

void NanoImage::updateImage(const uchar* const data)
{
DISTRHO_SAFE_ASSERT_RETURN(data != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fHandle.context != nullptr && fHandle.imageId != 0,);

nvgUpdateImage(fHandle.context, fHandle.imageId, data);
_updateSize();
}

void NanoImage::_updateSize()
{
int w=0, h=0;
@@ -181,6 +140,36 @@ void NanoImage::_updateSize()
fSize.setSize(static_cast<uint>(w), static_cast<uint>(h));
}

// -----------------------------------------------------------------------
// Paint

NanoVG::Paint::Paint() noexcept
: radius(0.0f), feather(0.0f), innerColor(), outerColor(), imageId(0)
{
std::memset(xform, 0, sizeof(float)*6);
std::memset(extent, 0, sizeof(float)*2);
}

NanoVG::Paint::Paint(const NVGpaint& p) noexcept
: radius(p.radius), feather(p.feather), innerColor(p.innerColor), outerColor(p.outerColor), imageId(p.image)
{
std::memcpy(xform, p.xform, sizeof(float)*6);
std::memcpy(extent, p.extent, sizeof(float)*2);
}

NanoVG::Paint::operator NVGpaint() const noexcept
{
NVGpaint p;
p.radius = radius;
p.feather = feather;
p.innerColor = innerColor;
p.outerColor = outerColor;
p.image = imageId;
std::memcpy(p.xform, xform, sizeof(float)*6);
std::memcpy(p.extent, extent, sizeof(float)*2);
return p;
}

// -----------------------------------------------------------------------
// NanoVG



Loading…
Cancel
Save