Browse Source

Minor posix tweaks. Added a tag value to images. Internal changes to Drawables.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
640042dc64
12 changed files with 252 additions and 91 deletions
  1. +76
    -31
      juce_amalgamated.cpp
  2. +48
    -14
      juce_amalgamated.h
  3. +1
    -1
      src/core/juce_StandardHeader.h
  4. +23
    -9
      src/gui/graphics/drawables/juce_Drawable.cpp
  5. +4
    -2
      src/gui/graphics/drawables/juce_Drawable.h
  6. +18
    -0
      src/gui/graphics/drawables/juce_DrawableImage.cpp
  7. +3
    -0
      src/gui/graphics/drawables/juce_DrawableImage.h
  8. +19
    -16
      src/gui/graphics/drawables/juce_DrawablePath.cpp
  9. +8
    -6
      src/gui/graphics/drawables/juce_DrawablePath.h
  10. +10
    -0
      src/gui/graphics/imaging/juce_Image.cpp
  11. +36
    -6
      src/gui/graphics/imaging/juce_Image.h
  12. +6
    -6
      src/native/linux/juce_linux_Threads.cpp

+ 76
- 31
juce_amalgamated.cpp View File

@@ -83856,6 +83856,8 @@ const Identifier Drawable::ValueTreeWrapperBase::gradientPoint2 ("point2");
const Identifier Drawable::ValueTreeWrapperBase::colour ("colour");
const Identifier Drawable::ValueTreeWrapperBase::radial ("radial");
const Identifier Drawable::ValueTreeWrapperBase::colours ("colours");
const Identifier Drawable::ValueTreeWrapperBase::imageId ("imageId");
const Identifier Drawable::ValueTreeWrapperBase::imageOpacity ("imageOpacity");

Drawable::ValueTreeWrapperBase::ValueTreeWrapperBase (const ValueTree& state_)
: state (state_)
@@ -83871,7 +83873,7 @@ const String Drawable::ValueTreeWrapperBase::getID() const
return state [idProperty];
}

void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* undoManager)
void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* const undoManager)
{
if (newID.isEmpty())
state.removeProperty (idProperty, undoManager);
@@ -83879,8 +83881,8 @@ void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* un
state.setProperty (idProperty, newID, undoManager);
}

const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* gp1, RelativePoint* gp2,
RelativeCoordinate::NamedCoordinateFinder* nameFinder)
const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* const gp1, RelativePoint* const gp2,
RelativeCoordinate::NamedCoordinateFinder* const nameFinder, ImageProvider* imageProvider)
{
const String newType (v[type].toString());

@@ -83916,7 +83918,13 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
}
else if (newType == "image")
{
jassertfalse; //xxx todo
Image im;
if (imageProvider != 0)
im = imageProvider->getImageForIdentifier (v[imageId]);

FillType f (im, AffineTransform::identity);
f.setOpacity ((float) v.getProperty (imageOpacity, 1.0f));
return f;
}

jassertfalse;
@@ -83924,8 +83932,8 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
}

void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType& fillType,
const RelativePoint* gp1, const RelativePoint* gp2,
UndoManager* const undoManager)
const RelativePoint* const gp1, const RelativePoint* const gp2,
ImageProvider* imageProvider, UndoManager* const undoManager)
{
if (fillType.isColour())
{
@@ -83941,8 +83949,8 @@ void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType

String s;
for (int i = 0; i < fillType.gradient->getNumColours(); ++i)
s << " " << fillType.gradient->getColourPosition (i)
<< " " << String::toHexString ((int) fillType.gradient->getColour(i).getARGB());
s << ' ' << fillType.gradient->getColourPosition (i)
<< ' ' << String::toHexString ((int) fillType.gradient->getColour(i).getARGB());

v.setProperty (colours, s.trimStart(), undoManager);
}
@@ -83950,7 +83958,13 @@ void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType
{
v.setProperty (type, "image", undoManager);

jassertfalse; //xxx todo
if (imageProvider != 0)
v.setProperty (imageId, imageProvider->getIdentifierForImage (fillType.image), undoManager);

if (fillType.getOpacity() < 1.0f)
v.setProperty (imageOpacity, fillType.getOpacity(), undoManager);
else
v.removeProperty (imageOpacity, undoManager);
}
else
{
@@ -84759,6 +84773,11 @@ const var DrawableImage::ValueTreeWrapper::getImageIdentifier() const
return state [image];
}

Value DrawableImage::ValueTreeWrapper::getImageIdentifierValue (UndoManager* undoManager)
{
return state.getPropertyAsValue (image, undoManager);
}

void DrawableImage::ValueTreeWrapper::setImageIdentifier (const var& newIdentifier, UndoManager* undoManager)
{
state.setProperty (image, newIdentifier, undoManager);
@@ -84769,6 +84788,14 @@ float DrawableImage::ValueTreeWrapper::getOpacity() const
return (float) state.getProperty (opacity, 1.0);
}

Value DrawableImage::ValueTreeWrapper::getOpacityValue (UndoManager* undoManager)
{
if (! state.hasProperty (opacity))
state.setProperty (opacity, 1.0, undoManager);

return state.getPropertyAsValue (opacity, undoManager);
}

void DrawableImage::ValueTreeWrapper::setOpacity (float newOpacity, UndoManager* undoManager)
{
state.setProperty (opacity, newOpacity, undoManager);
@@ -84787,6 +84814,11 @@ void DrawableImage::ValueTreeWrapper::setOverlayColour (const Colour& newColour,
state.setProperty (overlay, String::toHexString ((int) newColour.getARGB()), undoManager);
}

Value DrawableImage::ValueTreeWrapper::getOverlayColourValue (UndoManager* undoManager)
{
return state.getPropertyAsValue (overlay, undoManager);
}

const RelativePoint DrawableImage::ValueTreeWrapper::getTargetPositionForTopLeft() const
{
const String pos (state [topLeft].toString());
@@ -85065,7 +85097,7 @@ ValueTree DrawablePath::ValueTreeWrapper::getMainFillState()
if (v.isValid())
return v;

setMainFill (Colours::black, 0, 0, 0);
setMainFill (Colours::black, 0, 0, 0, 0);
return getMainFillState();
}

@@ -85075,32 +85107,34 @@ ValueTree DrawablePath::ValueTreeWrapper::getStrokeFillState()
if (v.isValid())
return v;

setStrokeFill (Colours::black, 0, 0, 0);
setStrokeFill (Colours::black, 0, 0, 0, 0);
return getStrokeFillState();
}

const FillType DrawablePath::ValueTreeWrapper::getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const
const FillType DrawablePath::ValueTreeWrapper::getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const
{
return readFillType (state.getChildWithName (fill), 0, 0, nameFinder);
return readFillType (state.getChildWithName (fill), 0, 0, nameFinder, imageProvider);
}

void DrawablePath::ValueTreeWrapper::setMainFill (const FillType& newFill, const RelativePoint* gp1,
const RelativePoint* gp2, UndoManager* undoManager)
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
{
ValueTree v (state.getOrCreateChildWithName (fill, undoManager));
writeFillType (v, newFill, gp1, gp2, undoManager);
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
}

const FillType DrawablePath::ValueTreeWrapper::getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const
const FillType DrawablePath::ValueTreeWrapper::getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const
{
return readFillType (state.getChildWithName (stroke), 0, 0, nameFinder);
return readFillType (state.getChildWithName (stroke), 0, 0, nameFinder, imageProvider);
}

void DrawablePath::ValueTreeWrapper::setStrokeFill (const FillType& newFill, const RelativePoint* gp1,
const RelativePoint* gp2, UndoManager* undoManager)
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
{
ValueTree v (state.getOrCreateChildWithName (stroke, undoManager));
writeFillType (v, newFill, gp1, gp2, undoManager);
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
}

const PathStrokeType DrawablePath::ValueTreeWrapper::getStrokeType() const
@@ -85193,14 +85227,14 @@ const RelativePoint DrawablePath::ValueTreeWrapper::Element::getEndPoint() const
return RelativePoint();
}

const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree, ImageProvider*)
const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree, ImageProvider* imageProvider)
{
Rectangle<float> damageRect;
ValueTreeWrapper v (tree);
setName (v.getID());

bool needsRedraw = false;
const FillType newFill (v.getMainFill (parent));
const FillType newFill (v.getMainFill (parent, imageProvider));

if (mainFill != newFill)
{
@@ -85208,7 +85242,7 @@ const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree
mainFill = newFill;
}

const FillType newStrokeFill (v.getStrokeFill (parent));
const FillType newStrokeFill (v.getStrokeFill (parent, imageProvider));

if (strokeFill != newStrokeFill)
{
@@ -85242,14 +85276,14 @@ const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree
return damageRect;
}

const ValueTree DrawablePath::createValueTree (ImageProvider*) const
const ValueTree DrawablePath::createValueTree (ImageProvider* imageProvider) const
{
ValueTree tree (valueTreeType);
ValueTreeWrapper v (tree);

v.setID (getName(), 0);
v.setMainFill (mainFill, 0, 0, 0);
v.setStrokeFill (strokeFill, 0, 0, 0);
v.setMainFill (mainFill, 0, 0, imageProvider, 0);
v.setStrokeFill (strokeFill, 0, 0, imageProvider, 0);
v.setStrokeType (strokeType, 0);

if (relativePath != 0)
@@ -93288,6 +93322,17 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
return newImage;
}

const var Image::getTag() const
{
return image == 0 ? var::null : image->userTag;
}

void Image::setTag (const var& newTag)
{
if (image != 0)
image->userTag = newTag;
}

Image::BitmapData::BitmapData (Image& image, const int x, const int y, const int w, const int h, const bool /*makeWritable*/)
: data (image.image == 0 ? 0 : image.image->getPixelData (x, y)),
pixelFormat (image.getFormat()),
@@ -253550,10 +253595,10 @@ bool juce_setThreadPriority (void* handle, int priority)

int pri = ((maxp - minp) / 2) * (priority - 1) / 9;

if (param.__sched_priority >= (minp + (maxp - minp) / 2))
param.__sched_priority = minp + ((maxp - minp) / 2) + pri; // (realtime)
if (param.sched_priority >= (minp + (maxp - minp) / 2))
param.sched_priority = minp + ((maxp - minp) / 2) + pri; // (realtime)
else
param.__sched_priority = minp + pri; // (high)
param.sched_priority = minp + pri; // (high)

param.sched_priority = jlimit (1, 127, 1 + (priority * 126) / 11);
return pthread_setschedparam ((pthread_t) handle, policy, &param) == 0;
@@ -253620,13 +253665,13 @@ void Process::setPriority (ProcessPriority prior)
maxp = sched_get_priority_max (policy);

if (p < 2)
param.__sched_priority = 0;
param.sched_priority = 0;
else if (p == 2 )
// Set to middle of lower realtime priority range
param.__sched_priority = minp + (maxp - minp) / 4;
param.sched_priority = minp + (maxp - minp) / 4;
else
// Set to middle of higher realtime priority range
param.__sched_priority = minp + (3 * (maxp - minp) / 4);
param.sched_priority = minp + (3 * (maxp - minp) / 4);

pthread_setschedparam (pthread_self(), policy, &param);
}


+ 48
- 14
juce_amalgamated.h View File

@@ -64,7 +64,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 10
#define JUCE_BUILDNUMBER 11

/** Current Juce version number.

@@ -24182,6 +24182,9 @@ public:
/** True if the image's format is RGB. */
bool isRGB() const throw() { return getFormat() == RGB; }

/** True if the image's format is a single-channel alpha map. */
bool isSingleChannel() const throw() { return getFormat() == SingleChannel; }

/** True if the image contains an alpha-channel. */
bool hasAlphaChannel() const throw() { return getFormat() != RGB; }

@@ -24219,6 +24222,8 @@ public:

Call this if you want to draw onto the image, but want to make sure that this doesn't
affect any other code that may be sharing the same data.

@see getReferenceCount
*/
void duplicateIfShared();

@@ -24348,12 +24353,37 @@ public:
void createSolidAreaMask (RectangleList& result,
float alphaThreshold = 0.5f) const;

/** Returns a user-specified data item that was set with setTag().
setTag() and getTag() allow you to attach an arbitrary identifier value to an
image. The value is shared between all Image object that are referring to the
same underlying image data object.
*/
const var getTag() const;

/** Attaches a user-specified data item to this image, which can be retrieved using getTag().
setTag() and getTag() allow you to attach an arbitrary identifier value to an
image. The value is shared between all Image object that are referring to the
same underlying image data object.

Note that if this Image is null, this method will fail to store the data.
*/
void setTag (const var& newTag);

/** Creates a context suitable for drawing onto this image.
Don't call this method directly! It's used internally by the Graphics class.
*/
LowLevelGraphicsContext* createLowLevelContext() const;

/**
/** Returns the number of Image objects which are currently referring to the same internal
shared image data.

@see duplicateIfShared
*/
int getReferenceCount() const throw() { return image == 0 ? 0 : image->getReferenceCount(); }

/** This is a base class for task-specific types of image.

Don't use this class directly! It's used internally by the Image class.
*/
class SharedImage : public ReferenceCountedObject
{
@@ -24375,6 +24405,7 @@ public:
const int width, height;
int pixelStride, lineStride;
uint8* imageData;
var userTag;

uint8* getPixelData (int x, int y) const throw();

@@ -24384,13 +24415,9 @@ public:

/** @internal */
SharedImage* getSharedImage() const throw() { return image; }

/** @internal */
explicit Image (SharedImage* instance);

/** @internal */
int getReferenceCount() const throw() { return image->getReferenceCount(); }

juce_UseDebuggingNewOperator

private:
@@ -42844,14 +42871,16 @@ public:
static const Identifier idProperty;

static const FillType readFillType (const ValueTree& v, RelativePoint* gradientPoint1, RelativePoint* gradientPoint2,
RelativeCoordinate::NamedCoordinateFinder* nameFinder);
RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider);

static void writeFillType (ValueTree& v, const FillType& fillType,
const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider,
UndoManager* undoManager);

ValueTree state;
static const Identifier type, gradientPoint1, gradientPoint2, colour, radial, colours;
static const Identifier type, gradientPoint1, gradientPoint2, colour, radial, colours, imageId, imageOpacity;
};

juce_UseDebuggingNewOperator
@@ -58532,12 +58561,15 @@ public:

const var getImageIdentifier() const;
void setImageIdentifier (const var& newIdentifier, UndoManager* undoManager);
Value getImageIdentifierValue (UndoManager* undoManager);

float getOpacity() const;
void setOpacity (float newOpacity, UndoManager* undoManager);
Value getOpacityValue (UndoManager* undoManager);

const Colour getOverlayColour() const;
void setOverlayColour (const Colour& newColour, UndoManager* undoManager);
Value getOverlayColourValue (UndoManager* undoManager);

const RelativePoint getTargetPositionForTopLeft() const;
void setTargetPositionForTopLeft (const RelativePoint& newPoint, UndoManager* undoManager);
@@ -58667,15 +58699,17 @@ public:
public:
ValueTreeWrapper (const ValueTree& state);

const FillType getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const;
const FillType getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const;
ValueTree getMainFillState();
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1,
const RelativePoint* gradientPoint2, UndoManager* undoManager);
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider, UndoManager* undoManager);

const FillType getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const;
const FillType getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const;
ValueTree getStrokeFillState();
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1,
const RelativePoint* gradientPoint2, UndoManager* undoManager);
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider, UndoManager* undoManager);

const PathStrokeType getStrokeType() const;
void setStrokeType (const PathStrokeType& newStrokeType, UndoManager* undoManager);


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 10
#define JUCE_BUILDNUMBER 11
/** Current Juce version number.


+ 23
- 9
src/gui/graphics/drawables/juce_Drawable.cpp View File

@@ -171,6 +171,8 @@ const Identifier Drawable::ValueTreeWrapperBase::gradientPoint2 ("point2");
const Identifier Drawable::ValueTreeWrapperBase::colour ("colour");
const Identifier Drawable::ValueTreeWrapperBase::radial ("radial");
const Identifier Drawable::ValueTreeWrapperBase::colours ("colours");
const Identifier Drawable::ValueTreeWrapperBase::imageId ("imageId");
const Identifier Drawable::ValueTreeWrapperBase::imageOpacity ("imageOpacity");
Drawable::ValueTreeWrapperBase::ValueTreeWrapperBase (const ValueTree& state_)
: state (state_)
@@ -186,7 +188,7 @@ const String Drawable::ValueTreeWrapperBase::getID() const
return state [idProperty];
}
void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* undoManager)
void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* const undoManager)
{
if (newID.isEmpty())
state.removeProperty (idProperty, undoManager);
@@ -194,8 +196,8 @@ void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* un
state.setProperty (idProperty, newID, undoManager);
}
const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* gp1, RelativePoint* gp2,
RelativeCoordinate::NamedCoordinateFinder* nameFinder)
const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* const gp1, RelativePoint* const gp2,
RelativeCoordinate::NamedCoordinateFinder* const nameFinder, ImageProvider* imageProvider)
{
const String newType (v[type].toString());
@@ -231,7 +233,13 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
}
else if (newType == "image")
{
jassertfalse; //xxx todo
Image im;
if (imageProvider != 0)
im = imageProvider->getImageForIdentifier (v[imageId]);
FillType f (im, AffineTransform::identity);
f.setOpacity ((float) v.getProperty (imageOpacity, 1.0f));
return f;
}
jassertfalse;
@@ -239,8 +247,8 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
}
void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType& fillType,
const RelativePoint* gp1, const RelativePoint* gp2,
UndoManager* const undoManager)
const RelativePoint* const gp1, const RelativePoint* const gp2,
ImageProvider* imageProvider, UndoManager* const undoManager)
{
if (fillType.isColour())
{
@@ -256,8 +264,8 @@ void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType
String s;
for (int i = 0; i < fillType.gradient->getNumColours(); ++i)
s << " " << fillType.gradient->getColourPosition (i)
<< " " << String::toHexString ((int) fillType.gradient->getColour(i).getARGB());
s << ' ' << fillType.gradient->getColourPosition (i)
<< ' ' << String::toHexString ((int) fillType.gradient->getColour(i).getARGB());
v.setProperty (colours, s.trimStart(), undoManager);
}
@@ -265,7 +273,13 @@ void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType
{
v.setProperty (type, "image", undoManager);
jassertfalse; //xxx todo
if (imageProvider != 0)
v.setProperty (imageId, imageProvider->getIdentifierForImage (fillType.image), undoManager);
if (fillType.getOpacity() < 1.0f)
v.setProperty (imageOpacity, fillType.getOpacity(), undoManager);
else
v.removeProperty (imageOpacity, undoManager);
}
else
{


+ 4
- 2
src/gui/graphics/drawables/juce_Drawable.h View File

@@ -249,14 +249,16 @@ public:
static const Identifier idProperty;
static const FillType readFillType (const ValueTree& v, RelativePoint* gradientPoint1, RelativePoint* gradientPoint2,
RelativeCoordinate::NamedCoordinateFinder* nameFinder);
RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider);
static void writeFillType (ValueTree& v, const FillType& fillType,
const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider,
UndoManager* undoManager);
ValueTree state;
static const Identifier type, gradientPoint1, gradientPoint2, colour, radial, colours;
static const Identifier type, gradientPoint1, gradientPoint2, colour, radial, colours, imageId, imageOpacity;
};
//==============================================================================


+ 18
- 0
src/gui/graphics/drawables/juce_DrawableImage.cpp View File

@@ -199,6 +199,11 @@ const var DrawableImage::ValueTreeWrapper::getImageIdentifier() const
return state [image];
}
Value DrawableImage::ValueTreeWrapper::getImageIdentifierValue (UndoManager* undoManager)
{
return state.getPropertyAsValue (image, undoManager);
}
void DrawableImage::ValueTreeWrapper::setImageIdentifier (const var& newIdentifier, UndoManager* undoManager)
{
state.setProperty (image, newIdentifier, undoManager);
@@ -209,6 +214,14 @@ float DrawableImage::ValueTreeWrapper::getOpacity() const
return (float) state.getProperty (opacity, 1.0);
}
Value DrawableImage::ValueTreeWrapper::getOpacityValue (UndoManager* undoManager)
{
if (! state.hasProperty (opacity))
state.setProperty (opacity, 1.0, undoManager);
return state.getPropertyAsValue (opacity, undoManager);
}
void DrawableImage::ValueTreeWrapper::setOpacity (float newOpacity, UndoManager* undoManager)
{
state.setProperty (opacity, newOpacity, undoManager);
@@ -227,6 +240,11 @@ void DrawableImage::ValueTreeWrapper::setOverlayColour (const Colour& newColour,
state.setProperty (overlay, String::toHexString ((int) newColour.getARGB()), undoManager);
}
Value DrawableImage::ValueTreeWrapper::getOverlayColourValue (UndoManager* undoManager)
{
return state.getPropertyAsValue (overlay, undoManager);
}
const RelativePoint DrawableImage::ValueTreeWrapper::getTargetPositionForTopLeft() const
{
const String pos (state [topLeft].toString());


+ 3
- 0
src/gui/graphics/drawables/juce_DrawableImage.h View File

@@ -134,12 +134,15 @@ public:
const var getImageIdentifier() const;
void setImageIdentifier (const var& newIdentifier, UndoManager* undoManager);
Value getImageIdentifierValue (UndoManager* undoManager);
float getOpacity() const;
void setOpacity (float newOpacity, UndoManager* undoManager);
Value getOpacityValue (UndoManager* undoManager);
const Colour getOverlayColour() const;
void setOverlayColour (const Colour& newColour, UndoManager* undoManager);
Value getOverlayColourValue (UndoManager* undoManager);
const RelativePoint getTargetPositionForTopLeft() const;
void setTargetPositionForTopLeft (const RelativePoint& newPoint, UndoManager* undoManager);


+ 19
- 16
src/gui/graphics/drawables/juce_DrawablePath.cpp View File

@@ -212,7 +212,7 @@ ValueTree DrawablePath::ValueTreeWrapper::getMainFillState()
if (v.isValid())
return v;
setMainFill (Colours::black, 0, 0, 0);
setMainFill (Colours::black, 0, 0, 0, 0);
return getMainFillState();
}
@@ -222,32 +222,34 @@ ValueTree DrawablePath::ValueTreeWrapper::getStrokeFillState()
if (v.isValid())
return v;
setStrokeFill (Colours::black, 0, 0, 0);
setStrokeFill (Colours::black, 0, 0, 0, 0);
return getStrokeFillState();
}
const FillType DrawablePath::ValueTreeWrapper::getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const
const FillType DrawablePath::ValueTreeWrapper::getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const
{
return readFillType (state.getChildWithName (fill), 0, 0, nameFinder);
return readFillType (state.getChildWithName (fill), 0, 0, nameFinder, imageProvider);
}
void DrawablePath::ValueTreeWrapper::setMainFill (const FillType& newFill, const RelativePoint* gp1,
const RelativePoint* gp2, UndoManager* undoManager)
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
{
ValueTree v (state.getOrCreateChildWithName (fill, undoManager));
writeFillType (v, newFill, gp1, gp2, undoManager);
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
}
const FillType DrawablePath::ValueTreeWrapper::getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const
const FillType DrawablePath::ValueTreeWrapper::getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const
{
return readFillType (state.getChildWithName (stroke), 0, 0, nameFinder);
return readFillType (state.getChildWithName (stroke), 0, 0, nameFinder, imageProvider);
}
void DrawablePath::ValueTreeWrapper::setStrokeFill (const FillType& newFill, const RelativePoint* gp1,
const RelativePoint* gp2, UndoManager* undoManager)
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
{
ValueTree v (state.getOrCreateChildWithName (stroke, undoManager));
writeFillType (v, newFill, gp1, gp2, undoManager);
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
}
const PathStrokeType DrawablePath::ValueTreeWrapper::getStrokeType() const
@@ -283,6 +285,7 @@ void DrawablePath::ValueTreeWrapper::setUsesNonZeroWinding (bool b, UndoManager*
state.setProperty (nonZeroWinding, b, undoManager);
}
//==============================================================================
const Identifier DrawablePath::ValueTreeWrapper::Element::startSubPathElement ("Move");
const Identifier DrawablePath::ValueTreeWrapper::Element::closeSubPathElement ("Close");
const Identifier DrawablePath::ValueTreeWrapper::Element::lineToElement ("Line");
@@ -342,14 +345,14 @@ const RelativePoint DrawablePath::ValueTreeWrapper::Element::getEndPoint() const
//==============================================================================
const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree, ImageProvider*)
const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree, ImageProvider* imageProvider)
{
Rectangle<float> damageRect;
ValueTreeWrapper v (tree);
setName (v.getID());
bool needsRedraw = false;
const FillType newFill (v.getMainFill (parent));
const FillType newFill (v.getMainFill (parent, imageProvider));
if (mainFill != newFill)
{
@@ -357,7 +360,7 @@ const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree
mainFill = newFill;
}
const FillType newStrokeFill (v.getStrokeFill (parent));
const FillType newStrokeFill (v.getStrokeFill (parent, imageProvider));
if (strokeFill != newStrokeFill)
{
@@ -391,14 +394,14 @@ const Rectangle<float> DrawablePath::refreshFromValueTree (const ValueTree& tree
return damageRect;
}
const ValueTree DrawablePath::createValueTree (ImageProvider*) const
const ValueTree DrawablePath::createValueTree (ImageProvider* imageProvider) const
{
ValueTree tree (valueTreeType);
ValueTreeWrapper v (tree);
v.setID (getName(), 0);
v.setMainFill (mainFill, 0, 0, 0);
v.setStrokeFill (strokeFill, 0, 0, 0);
v.setMainFill (mainFill, 0, 0, imageProvider, 0);
v.setStrokeFill (strokeFill, 0, 0, imageProvider, 0);
v.setStrokeType (strokeType, 0);
if (relativePath != 0)


+ 8
- 6
src/gui/graphics/drawables/juce_DrawablePath.h View File

@@ -129,15 +129,17 @@ public:
public:
ValueTreeWrapper (const ValueTree& state);
const FillType getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const;
const FillType getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const;
ValueTree getMainFillState();
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1,
const RelativePoint* gradientPoint2, UndoManager* undoManager);
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider, UndoManager* undoManager);
const FillType getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder) const;
const FillType getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
ImageProvider* imageProvider) const;
ValueTree getStrokeFillState();
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1,
const RelativePoint* gradientPoint2, UndoManager* undoManager);
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
ImageProvider* imageProvider, UndoManager* undoManager);
const PathStrokeType getStrokeType() const;
void setStrokeType (const PathStrokeType& newStrokeType, UndoManager* undoManager);


+ 10
- 0
src/gui/graphics/imaging/juce_Image.cpp View File

@@ -198,6 +198,16 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
return newImage;
}
const var Image::getTag() const
{
return image == 0 ? var::null : image->userTag;
}
void Image::setTag (const var& newTag)
{
if (image != 0)
image->userTag = newTag;
}
//==============================================================================
Image::BitmapData::BitmapData (Image& image, const int x, const int y, const int w, const int h, const bool /*makeWritable*/)


+ 36
- 6
src/gui/graphics/imaging/juce_Image.h View File

@@ -28,6 +28,7 @@
#include "../colour/juce_Colour.h"
#include "../contexts/juce_Graphics.h"
#include "../../../containers/juce_Variant.h"
//==============================================================================
@@ -159,6 +160,9 @@ public:
/** True if the image's format is RGB. */
bool isRGB() const throw() { return getFormat() == RGB; }
/** True if the image's format is a single-channel alpha map. */
bool isSingleChannel() const throw() { return getFormat() == SingleChannel; }
/** True if the image contains an alpha-channel. */
bool hasAlphaChannel() const throw() { return getFormat() != RGB; }
@@ -197,6 +201,8 @@ public:
Call this if you want to draw onto the image, but want to make sure that this doesn't
affect any other code that may be sharing the same data.
@see getReferenceCount
*/
void duplicateIfShared();
@@ -328,13 +334,40 @@ public:
void createSolidAreaMask (RectangleList& result,
float alphaThreshold = 0.5f) const;
//==============================================================================
/** Returns a user-specified data item that was set with setTag().
setTag() and getTag() allow you to attach an arbitrary identifier value to an
image. The value is shared between all Image object that are referring to the
same underlying image data object.
*/
const var getTag() const;
/** Attaches a user-specified data item to this image, which can be retrieved using getTag().
setTag() and getTag() allow you to attach an arbitrary identifier value to an
image. The value is shared between all Image object that are referring to the
same underlying image data object.
Note that if this Image is null, this method will fail to store the data.
*/
void setTag (const var& newTag);
//==============================================================================
/** Creates a context suitable for drawing onto this image.
Don't call this method directly! It's used internally by the Graphics class.
*/
LowLevelGraphicsContext* createLowLevelContext() const;
/** Returns the number of Image objects which are currently referring to the same internal
shared image data.
@see duplicateIfShared
*/
int getReferenceCount() const throw() { return image == 0 ? 0 : image->getReferenceCount(); }
//==============================================================================
/**
/** This is a base class for task-specific types of image.
Don't use this class directly! It's used internally by the Image class.
*/
class SharedImage : public ReferenceCountedObject
{
@@ -356,6 +389,7 @@ public:
const int width, height;
int pixelStride, lineStride;
uint8* imageData;
var userTag;
uint8* getPixelData (int x, int y) const throw();
@@ -364,14 +398,10 @@ public:
};
/** @internal */
SharedImage* getSharedImage() const throw() { return image; }
SharedImage* getSharedImage() const throw() { return image; }
/** @internal */
explicit Image (SharedImage* instance);
/** @internal */
int getReferenceCount() const throw() { return image->getReferenceCount(); }
//==============================================================================
juce_UseDebuggingNewOperator


+ 6
- 6
src/native/linux/juce_linux_Threads.cpp View File

@@ -100,10 +100,10 @@ bool juce_setThreadPriority (void* handle, int priority)
int pri = ((maxp - minp) / 2) * (priority - 1) / 9;
if (param.__sched_priority >= (minp + (maxp - minp) / 2))
param.__sched_priority = minp + ((maxp - minp) / 2) + pri; // (realtime)
if (param.sched_priority >= (minp + (maxp - minp) / 2))
param.sched_priority = minp + ((maxp - minp) / 2) + pri; // (realtime)
else
param.__sched_priority = minp + pri; // (high)
param.sched_priority = minp + pri; // (high)
param.sched_priority = jlimit (1, 127, 1 + (priority * 126) / 11);
return pthread_setschedparam ((pthread_t) handle, policy, &param) == 0;
@@ -172,13 +172,13 @@ void Process::setPriority (ProcessPriority prior)
maxp = sched_get_priority_max (policy);
if (p < 2)
param.__sched_priority = 0;
param.sched_priority = 0;
else if (p == 2 )
// Set to middle of lower realtime priority range
param.__sched_priority = minp + (maxp - minp) / 4;
param.sched_priority = minp + (maxp - minp) / 4;
else
// Set to middle of higher realtime priority range
param.__sched_priority = minp + (3 * (maxp - minp) / 4);
param.sched_priority = minp + (3 * (maxp - minp) / 4);
pthread_setschedparam (pthread_self(), policy, &param);
}


Loading…
Cancel
Save