Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawNode calls: replacing Color4F with Color4B (without the 'test' folder!) #2192

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/2d/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ void Label::updateContent()
_debugDrawNode->clear();
Vec2 vertices[4] = {Vec2::ZERO, Vec2(_contentSize.width, 0.0f), Vec2(_contentSize.width, _contentSize.height),
Vec2(0.0f, _contentSize.height)};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F::WHITE);
_debugDrawNode->drawPoly(vertices, 4, true, Color4B::WHITE);
#endif
}

Expand Down
3 changes: 1 addition & 2 deletions core/2d/LabelAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ THE SOFTWARE.
#include "renderer/TextureAtlas.h"
#include "platform/FileUtils.h"
#include "base/Director.h"
#include "base/UTF8.h"
#include "renderer/TextureCache.h"

#if AX_LABELATLAS_DEBUG_DRAW
Expand Down Expand Up @@ -278,7 +277,7 @@ void LabelAtlas::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
_debugDrawNode->clear();
auto size = getContentSize();
Vec2 vertices[4] = {Vec2::ZERO, Vec2(size.width, 0), Vec2(size.width, size.height), Vec2(0.0f, size.height)};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
_debugDrawNode->drawPoly(vertices, 4, true, Color4B::WHITE);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions core/2d/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,15 +1101,15 @@ void Sprite::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
// draw 3 lines
Vec3 from = verts[indices[i * 3]].vertices;
Vec3 to = verts[indices[i * 3 + 1]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::WHITE);
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE);

from = verts[indices[i * 3 + 1]].vertices;
to = verts[indices[i * 3 + 2]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::WHITE);
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE);

from = verts[indices[i * 3 + 2]].vertices;
to = verts[indices[i * 3]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4F::WHITE);
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x, to.y), Color4B::WHITE);
}
#endif // AX_SPRITE_DEBUG_DRAW
}
Expand Down
12 changes: 6 additions & 6 deletions core/physics/PhysicsWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ static void DrawCircle(cpVect p,
cpSpaceDebugColor fill,
cpDataPointer data)
{
const Color4F fillColor(fill.r, fill.g, fill.b, fill.a);
const Color4F outlineColor(outline.r, outline.g, outline.b, outline.a);
const Color4B fillColor(fill.r, fill.g, fill.b, fill.a);
const Color4B outlineColor(outline.r, outline.g, outline.b, outline.a);
DrawNode* drawNode = static_cast<DrawNode*>(data);
float radius = PhysicsHelper::cpfloat2float(r);
Vec2 centre = PhysicsHelper::cpv2vec2(p);
Expand All @@ -250,7 +250,7 @@ static void DrawFatSegment(cpVect a,
cpSpaceDebugColor /*fill*/,
cpDataPointer data)
{
const Color4F outlineColor(outline.r, outline.g, outline.b, outline.a);
const Color4B outlineColor(outline.r, outline.g, outline.b, outline.a);
DrawNode* drawNode = static_cast<DrawNode*>(data);
drawNode->drawSegment(PhysicsHelper::cpv2vec2(a), PhysicsHelper::cpv2vec2(b),
PhysicsHelper::cpfloat2float(r == 0 ? _debugDrawThickness : r), outlineColor);
Expand All @@ -268,8 +268,8 @@ static void DrawPolygon(int count,
cpSpaceDebugColor fill,
cpDataPointer data)
{
const Color4F fillColor(fill.r, fill.g, fill.b, fill.a);
const Color4F outlineColor(outline.r, outline.g, outline.b, outline.a);
const Color4B fillColor(fill.r, fill.g, fill.b, fill.a);
const Color4B outlineColor(outline.r, outline.g, outline.b, outline.a);
DrawNode* drawNode = static_cast<DrawNode*>(data);
int num = count;
Vec2* seg = new Vec2[num];
Expand All @@ -283,7 +283,7 @@ static void DrawPolygon(int count,

static void DrawDot(cpFloat /*size*/, cpVect pos, cpSpaceDebugColor color, cpDataPointer data)
{
const Color4F dotColor(color.r, color.g, color.b, color.a);
const Color4B dotColor(color.r, color.g, color.b, color.a);
DrawNode* drawNode = static_cast<DrawNode*>(data);
drawNode->drawDot(PhysicsHelper::cpv2vec2(pos), _debugDrawThickness, dotColor);
}
Expand Down
2 changes: 1 addition & 1 deletion core/ui/UILayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void Layout::setStencilClippingSize(const Vec2& /*size*/)
if (_clippingEnabled && _clippingType == ClippingType::STENCIL)
{
_clippingStencil->clear();
_clippingStencil->drawSolidRect(Vec2::ZERO, _contentSize, Color4F::GREEN); // Fix issue #1546
_clippingStencil->drawSolidRect(Vec2::ZERO, _contentSize, Color4B::GREEN); // Fix issue #1546
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/ui/UIMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void createMediaControlTexture()

auto DrawStop = [&](const Vec2& middle) -> void {
auto s = Vec2(middle.x - iconW / 2.f, middle.y + iconH / 2.f);
drawNode->drawSolidRect(s, s + Vec2(iconW, -iconH), Color4F::WHITE);
drawNode->drawSolidRect(s, s + Vec2(iconW, -iconH), Color4B::WHITE);
};

auto DrawPlay = [&](const Vec2& middle) -> void {
Expand Down Expand Up @@ -1142,7 +1142,7 @@ void MediaPlayer::draw(Renderer* renderer, const Mat4& transform, uint32_t flags
_debugDrawNode->clear();
auto size = getContentSize();
Point vertices[4] = {Point::ZERO, Point(size.width, 0), Point(size.width, size.height), Point(0, size.height)};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
_debugDrawNode->drawPoly(vertices, 4, true, Color4B::WHITE);
# endif
}

Expand Down
9 changes: 0 additions & 9 deletions core/ui/UIScale9Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,8 @@

#include "ui/UIScale9Sprite.h"
#include "2d/Sprite.h"
#include "2d/SpriteFrameCache.h"
#include "base/Vector.h"
#include "base/Director.h"
#include "base/UTF8.h"
#include "renderer/Shaders.h"
#include "platform/Image.h"
#include "base/NinePatchImageParser.h"
#include "2d/DrawNode.h"
#include "2d/Camera.h"
#include "renderer/Renderer.h"
#include "renderer/backend/ProgramStateRegistry.h"

using namespace ax::ui;

Expand Down
3 changes: 0 additions & 3 deletions core/ui/UIScale9Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@

#include "2d/Sprite.h"
#include "2d/SpriteFrame.h"
#include "2d/SpriteBatchNode.h"
#include "platform/PlatformMacros.h"
#include "ui/GUIExport.h"
#include "renderer/TrianglesCommand.h"

/**
* @addtogroup ui
Expand Down
6 changes: 3 additions & 3 deletions extensions/DragonBones/src/DragonBones/CCArmatureDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ void DBCCSprite::draw(ax::Renderer* renderer, const ax::Mat4& transform, uint32_
// draw 3 lines
auto from = verts[indices[i * 3]].vertices;
auto to = verts[indices[i * 3 + 1]].vertices;
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4F::WHITE);
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE);

from = verts[indices[i * 3 + 1]].vertices;
to = verts[indices[i * 3 + 2]].vertices;
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4F::WHITE);
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE);

from = verts[indices[i * 3 + 2]].vertices;
to = verts[indices[i * 3]].vertices;
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4F::WHITE);
_debugDrawNode->drawLine(ax::Vec2(from.x, from.y), ax::Vec2(to.x, to.y), ax::Color4B::WHITE);
}
#endif // AX_SPRITE_DEBUG_DRAW
}
Expand Down
20 changes: 10 additions & 10 deletions extensions/fairygui/src/fairygui/GGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NS_FGUI_BEGIN
using namespace ax;

static void drawVertRect(ax::DrawNode* shape, float x, float y, float width, float height, const ax::Color4F& color)
static void drawVertRect(ax::DrawNode* shape, float x, float y, float width, float height, const ax::Color4B& color)
{
float mx = x + width;
float my = y + height;
Expand All @@ -16,8 +16,8 @@ static void drawVertRect(ax::DrawNode* shape, float x, float y, float width, flo
GGraph::GGraph() : _shape(nullptr),
_type(0),
_lineSize(1),
_lineColor(Color4F::BLACK),
_fillColor(Color4F::WHITE),
_lineColor(Color4B::BLACK),
_fillColor(Color4B::WHITE),
_cornerRadius(nullptr),
_polygonPoints(nullptr),
_distances(nullptr)
Expand All @@ -40,7 +40,7 @@ void GGraph::handleInit()
_displayObject = _shape;
}

void GGraph::drawRect(float aWidth, float aHeight, int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor)
void GGraph::drawRect(float aWidth, float aHeight, int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor)
{
_type = 0; //avoid updateshape call in handleSizeChange
setSize(aWidth, aHeight);
Expand All @@ -51,7 +51,7 @@ void GGraph::drawRect(float aWidth, float aHeight, int lineSize, const ax::Color
updateShape();
}

void GGraph::drawEllipse(float aWidth, float aHeight, int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor)
void GGraph::drawEllipse(float aWidth, float aHeight, int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor)
{
_type = 0; //avoid updateshape call in handleSizeChange
setSize(aWidth, aHeight);
Expand All @@ -62,7 +62,7 @@ void GGraph::drawEllipse(float aWidth, float aHeight, int lineSize, const ax::Co
updateShape();
}

void GGraph::drawPolygon(int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor, const ax::Vec2* points, int count)
void GGraph::drawPolygon(int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor, const ax::Vec2* points, int count)
{
_type = 3;
_lineSize = lineSize;
Expand All @@ -83,7 +83,7 @@ void GGraph::drawPolygon(int lineSize, const ax::Color4F& lineColor, const ax::C
updateShape();
}

void GGraph::drawRegularPolygon(int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor,
void GGraph::drawRegularPolygon(int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor,
int sides, float startAngle, const float* distances, int count)
{
_type = 4;
Expand Down Expand Up @@ -189,7 +189,7 @@ ax::Color3B GGraph::getColor() const

void GGraph::setColor(const ax::Color3B& value)
{
_fillColor = Color4F(value, _fillColor.a);
_fillColor = Color4B(value, _fillColor.a);
updateShape();
}

Expand Down Expand Up @@ -247,8 +247,8 @@ void GGraph::setup_beforeAdd(ByteBuffer* buffer, int beginPos)
if (_type != 0)
{
_lineSize = buffer->readInt();
_lineColor = (Color4F)buffer->readColor();
_fillColor = (Color4F)buffer->readColor();
_lineColor = (Color4B)buffer->readColor();
_fillColor = (Color4B)buffer->readColor();
if (buffer->readBool())
{
_cornerRadius = new float[4];
Expand Down
12 changes: 6 additions & 6 deletions extensions/fairygui/src/fairygui/GGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class GGraph : public GObject

CREATE_FUNC(GGraph);

void drawRect(float aWidth, float aHeight, int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor);
void drawEllipse(float aWidth, float aHeight, int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor);
void drawPolygon(int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor, const ax::Vec2* points, int count);
void drawRegularPolygon(int lineSize, const ax::Color4F& lineColor, const ax::Color4F& fillColor, int sides, float startAngle = 0, const float* distances = nullptr, int distanceCount = 0);
void drawRect(float aWidth, float aHeight, int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor);
void drawEllipse(float aWidth, float aHeight, int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor);
void drawPolygon(int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor, const ax::Vec2* points, int count);
void drawRegularPolygon(int lineSize, const ax::Color4B& lineColor, const ax::Color4B& fillColor, int sides, float startAngle = 0, const float* distances = nullptr, int distanceCount = 0);
bool isEmpty() const { return _type == 0; }

ax::Color3B getColor() const;
Expand All @@ -36,8 +36,8 @@ class GGraph : public GObject
void updateShape();

int _type;
ax::Color4F _lineColor;
ax::Color4F _fillColor;
ax::Color4B _lineColor;
ax::Color4B _fillColor;
int _lineSize;
float* _cornerRadius;
std::vector<ax::Vec2>* _polygonPoints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ void PhysicsDebugNode::setSpace(cpSpace* space)
_spacePtr = space;
}

NS_AX_EXT_END
NS_AX_EXT_END
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ static const cpVect spring_verts[] = {
};
static const int spring_count = sizeof(spring_verts) / sizeof(cpVect);

static Color4F ColorForBody(cpBody* body)
static Color4B ColorForBody(cpBody* body)
{
if (CP_BODY_TYPE_STATIC == cpBodyGetType(body) || cpBodyIsSleeping(body))
{
return Color4F(0.5f, 0.5f, 0.5f, 0.5f);
return Color4B(127, 127, 127, 127);
}
else if (body->sleeping.idleTime > cpBodyGetSpace(body)->sleepTimeThreshold)
{
return Color4F(0.33f, 0.33f, 0.33f, 0.5f);
return Color4B(85, 85, 85, 127);
}
else
{
return Color4F(1.0f, 0.0f, 0.0f, 0.5f);
return Color4B(255, 0, 0, 127);
}
}

Expand All @@ -78,7 +78,7 @@ static Vec2 cpVert2Point(const cpVect& vert)
static void DrawShape(cpShape* shape, DrawNode* renderer)
{
cpBody* body = cpShapeGetBody(shape);
Color4F color = ColorForBody(body);
Color4B color = ColorForBody(body);

switch (shape->klass->type)
{
Expand All @@ -101,15 +101,15 @@ static void DrawShape(cpShape* shape, DrawNode* renderer)
case CP_POLY_SHAPE:
{
cpPolyShape* poly = (cpPolyShape*)shape;
Color4F line = color;
Color4B line = color;
line.a = cpflerp(color.a, 1.0, 0.5);
int num = poly->count;
Vec2* pPoints = new Vec2[num];
for (int i = 0; i < num; ++i)
pPoints[i] = cpVert2Point(poly->planes[i].v0);
if (cpfmax(poly->r, 1.0) > 1.0)
{
renderer->drawPolygon(pPoints, num, Color4F(0.5f, 0.5f, 0.5f, 0.0f), poly->r, color);
renderer->drawPolygon(pPoints, num, Color4B(127, 127, 127,0), poly->r, color);
}
else
{
Expand All @@ -124,7 +124,7 @@ static void DrawShape(cpShape* shape, DrawNode* renderer)
}
}

static Color4F CONSTRAINT_COLOR(0, 1, 0, 0.5);
static Color4B CONSTRAINT_COLOR(0, 255, 0, 127);

static void DrawConstraint(cpConstraint* constraint, DrawNode* renderer)
{
Expand Down Expand Up @@ -251,4 +251,4 @@ void PhysicsDebugNodeChipmunk2D::setSpace(cpSpace* space)
_spacePtr = space;
}

NS_AX_EXT_END
NS_AX_EXT_END
Loading