Skip to content

Commit

Permalink
Initial file moves and renames
Browse files Browse the repository at this point in the history
Diffs=
25d423274 Initial file moves and renames (#7951)

Co-authored-by: rivessamr <[email protected]>
  • Loading branch information
rivessamr and rivessamr committed Aug 27, 2024
1 parent 5737f90 commit 1b24bf9
Show file tree
Hide file tree
Showing 137 changed files with 1,391 additions and 1,383 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
69cffe900faeb0241d20ea8ece3f5cfc5f1563a5
25d423274ff8e2894c874093b2d5ca86fc2895c2
44 changes: 0 additions & 44 deletions pls/renderer/pls_factory.cpp

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions pls/README.md → renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

The Rive Renderer is a vector and raster graphics renderer custom-built for Rive content, for animation, and for runtime.

This folder contains the renderer code and an example for how to interface with it directly. It contains the best in class concrete implementation of Rive's rendering abstraction layer, which we call the Rive Renderer.
This directory contains the renderer code and an example for how to interface with it directly. It contains the best in class concrete implementation of Rive's rendering abstraction layer, which we call the Rive Renderer.

## Clone the rive-runtime repo

```
git clone https://github.com/rive-app/rive-runtime.git
cd rive-runtime/pls
cd rive-runtime/renderer
```

## Build GLFW
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#pragma once

#include "rive/pls/pls.hpp"
#include "rive/renderer/gpu.hpp"

namespace rive::pls
namespace rive::gpu
{
// API-agnostic implementation of an abstract buffer ring. We use rings to ensure the GPU can render
// one frame in parallel while the CPU prepares the next frame.
Expand Down Expand Up @@ -86,4 +86,4 @@ class HeapBufferRing : public BufferRing
void* onMapBuffer(int bufferIdx, size_t mapSizeInBytes) override { return shadowBuffer(); }
void onUnmapAndSubmitBuffer(int bufferIdx, size_t mapSizeInBytes) override {}
};
} // namespace rive::pls
} // namespace rive::gpu
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#pragma once

#include "rive/pls/d3d/d3d11.hpp"
#include "rive/pls/pls_render_context_helper_impl.hpp"
#include "rive/renderer/d3d/d3d11.hpp"
#include "rive/renderer/render_context_helper_impl.hpp"
#include <map>
#include <string>

namespace rive::pls
namespace rive::gpu
{
class PLSRenderContextD3DImpl;

Expand Down Expand Up @@ -119,7 +119,7 @@ class PLSRenderContextD3DImpl : public PLSRenderContextHelperImpl

std::unique_ptr<BufferRing> makeUniformBufferRing(size_t capacityInBytes) override;
std::unique_ptr<BufferRing> makeStorageBufferRing(size_t capacityInBytes,
pls::StorageBufferStructure) override;
gpu::StorageBufferStructure) override;
std::unique_ptr<BufferRing> makeVertexBufferRing(size_t capacityInBytes) override;
std::unique_ptr<BufferRing> makeTextureTransferBufferRing(size_t capacityInBytes) override;

Expand All @@ -134,9 +134,9 @@ class PLSRenderContextD3DImpl : public PLSRenderContextHelperImpl
UINT firstHighLevelStruct);

void setPipelineLayoutAndShaders(DrawType,
pls::ShaderFeatures,
pls::InterlockMode,
pls::ShaderMiscFlags pixelShaderMiscFlags);
gpu::ShaderFeatures,
gpu::InterlockMode,
gpu::ShaderMiscFlags pixelShaderMiscFlags);

const D3DCapabilities m_d3dCapabilities;

Expand Down Expand Up @@ -175,7 +175,7 @@ class PLSRenderContextD3DImpl : public PLSRenderContextHelperImpl
ComPtr<ID3D11Buffer> m_patchVertexBuffer;
ComPtr<ID3D11Buffer> m_patchIndexBuffer;

// Vertex/index buffers for drawing image rects. (pls::InterlockMode::atomics only.)
// Vertex/index buffers for drawing image rects. (gpu::InterlockMode::atomics only.)
ComPtr<ID3D11Buffer> m_imageRectVertexBuffer;
ComPtr<ID3D11Buffer> m_imageRectIndexBuffer;

Expand All @@ -198,4 +198,4 @@ class PLSRenderContextD3DImpl : public PLSRenderContextHelperImpl

ComPtr<ID3D11BlendState> m_srcOverBlendState;
};
} // namespace rive::pls
} // namespace rive::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

#include "rive/math/raw_path.hpp"
#include "rive/math/wangs_formula.hpp"
#include "rive/pls/pls.hpp"
#include "rive/pls/pls_render_context.hpp"
#include "rive/pls/fixed_queue.hpp"
#include "rive/renderer/gpu.hpp"
#include "rive/renderer/render_context.hpp"
#include "rive/renderer/fixed_queue.hpp"
#include "rive/shapes/paint/stroke_cap.hpp"
#include "rive/shapes/paint/stroke_join.hpp"
#include "rive/refcnt.hpp"

namespace rive::pls
namespace rive::gpu
{
class PLSDraw;
class PLSPath;
class PLSPaint;
class RiveRenderPath;
class RiveRenderPaint;
class PLSRenderContext;
class PLSGradient;

Expand Down Expand Up @@ -47,28 +47,28 @@ class PLSDraw
const Mat2D& matrix() const { return m_matrix; }
BlendMode blendMode() const { return m_blendMode; }
Type type() const { return m_type; }
pls::DrawContents drawContents() const { return m_drawContents; }
bool isStroked() const { return m_drawContents & pls::DrawContents::stroke; }
bool isEvenOddFill() const { return m_drawContents & pls::DrawContents::evenOddFill; }
bool isOpaque() const { return m_drawContents & pls::DrawContents::opaquePaint; }
gpu::DrawContents drawContents() const { return m_drawContents; }
bool isStroked() const { return m_drawContents & gpu::DrawContents::stroke; }
bool isEvenOddFill() const { return m_drawContents & gpu::DrawContents::evenOddFill; }
bool isOpaque() const { return m_drawContents & gpu::DrawContents::opaquePaint; }
uint32_t clipID() const { return m_clipID; }
bool hasClipRect() const { return m_clipRectInverseMatrix != nullptr; }
const pls::ClipRectInverseMatrix* clipRectInverseMatrix() const
const gpu::ClipRectInverseMatrix* clipRectInverseMatrix() const
{
return m_clipRectInverseMatrix;
}
pls::SimplePaintValue simplePaintValue() const { return m_simplePaintValue; }
gpu::SimplePaintValue simplePaintValue() const { return m_simplePaintValue; }
const PLSGradient* gradient() const { return m_gradientRef; }

// Clipping setup.
void setClipID(uint32_t clipID);
void setClipRect(const pls::ClipRectInverseMatrix* m) { m_clipRectInverseMatrix = m; }
void setClipRect(const gpu::ClipRectInverseMatrix* m) { m_clipRectInverseMatrix = m; }

// Used to allocate GPU resources for a collection of draws.
using ResourceCounters = PLSRenderContext::LogicalFlush::ResourceCounters;
const ResourceCounters& resourceCounts() const { return m_resourceCounts; }

// Linked list of all PLSDraws within a pls::DrawBatch.
// Linked list of all PLSDraws within a gpu::DrawBatch.
void setBatchInternalNeighbor(const PLSDraw* neighbor)
{
assert(m_batchInternalNeighbor == nullptr);
Expand Down Expand Up @@ -97,77 +97,78 @@ class PLSDraw
const Type m_type;

uint32_t m_clipID = 0;
const pls::ClipRectInverseMatrix* m_clipRectInverseMatrix = nullptr;
const gpu::ClipRectInverseMatrix* m_clipRectInverseMatrix = nullptr;

pls::DrawContents m_drawContents = pls::DrawContents::none;
gpu::DrawContents m_drawContents = gpu::DrawContents::none;

// Filled in by the subclass constructor.
ResourceCounters m_resourceCounts;

// Gradient data used by some draws. Stored in the base class so allocateGradientIfNeeded()
// doesn't have to be virtual.
const PLSGradient* m_gradientRef = nullptr;
pls::SimplePaintValue m_simplePaintValue;
gpu::SimplePaintValue m_simplePaintValue;

// Linked list of all PLSDraws within a pls::DrawBatch.
// Linked list of all PLSDraws within a gpu::DrawBatch.
const PLSDraw* m_batchInternalNeighbor = nullptr;
};

// Implement PLSDrawReleaseRefs (defined in pls_render_context.hpp) now that PLSDraw is defined.
inline void PLSDrawReleaseRefs::operator()(PLSDraw* draw) { draw->releaseRefs(); }

// High level abstraction of a single path to be drawn (midpoint fan or interior triangulation).
class PLSPathDraw : public PLSDraw
class RiveRenderPathDraw : public PLSDraw
{
public:
// Creates either a normal path draw or an interior triangulation if the path is large enough.
static PLSDrawUniquePtr Make(PLSRenderContext*,
const Mat2D&,
rcp<const PLSPath>,
rcp<const RiveRenderPath>,
FillRule,
const PLSPaint*,
const RiveRenderPaint*,
RawPath* scratchPath);

FillRule fillRule() const { return m_fillRule; }
pls::PaintType paintType() const { return m_paintType; }
gpu::PaintType paintType() const { return m_paintType; }
float strokeRadius() const { return m_strokeRadius; }
pls::ContourDirections contourDirections() const { return m_contourDirections; }
gpu::ContourDirections contourDirections() const { return m_contourDirections; }

void pushToRenderContext(PLSRenderContext::LogicalFlush*) final;

void releaseRefs() override;

public:
PLSPathDraw(IAABB pathBounds,
const Mat2D&,
rcp<const PLSPath>,
FillRule,
const PLSPaint*,
Type,
pls::InterlockMode);
RiveRenderPathDraw(IAABB pathBounds,
const Mat2D&,
rcp<const RiveRenderPath>,
FillRule,
const RiveRenderPaint*,
Type,
gpu::InterlockMode);

virtual void onPushToRenderContext(PLSRenderContext::LogicalFlush*) = 0;

const PLSPath* const m_pathRef;
const FillRule m_fillRule; // Bc PLSPath fillRule can mutate during the artboard draw process.
const pls::PaintType m_paintType;
const RiveRenderPath* const m_pathRef;
const FillRule
m_fillRule; // Bc RiveRenderPath fillRule can mutate during the artboard draw process.
const gpu::PaintType m_paintType;
float m_strokeRadius = 0;
pls::ContourDirections m_contourDirections;
gpu::ContourDirections m_contourDirections;

// Used to guarantee m_pathRef doesn't change for the entire time we hold it.
RIVE_DEBUG_CODE(uint64_t m_rawPathMutationID;)
};

// Draws a path by fanning tessellation patches around the midpoint of each contour.
class MidpointFanPathDraw : public PLSPathDraw
class MidpointFanPathDraw : public RiveRenderPathDraw
{
public:
MidpointFanPathDraw(PLSRenderContext*,
IAABB pixelBounds,
const Mat2D&,
rcp<const PLSPath>,
rcp<const RiveRenderPath>,
FillRule,
const PLSPaint*);
const RiveRenderPaint*);

protected:
void onPushToRenderContext(PLSRenderContext::LogicalFlush*) override;
Expand Down Expand Up @@ -219,7 +220,7 @@ class MidpointFanPathDraw : public PLSPathDraw

// Draws a path by triangulating the interior into non-overlapping triangles and tessellating the
// outer curves.
class InteriorTriangulationDraw : public PLSPathDraw
class InteriorTriangulationDraw : public RiveRenderPathDraw
{
public:
enum class TriangulatorAxis
Expand All @@ -232,9 +233,9 @@ class InteriorTriangulationDraw : public PLSPathDraw
InteriorTriangulationDraw(PLSRenderContext*,
IAABB pixelBounds,
const Mat2D&,
rcp<const PLSPath>,
rcp<const RiveRenderPath>,
FillRule,
const PLSPaint*,
const RiveRenderPaint*,
RawPath* scratchPath,
TriangulatorAxis);

Expand Down Expand Up @@ -353,4 +354,4 @@ class StencilClipReset : public PLSDraw
protected:
const uint32_t m_previousClipID;
};
} // namespace rive::pls
} // namespace rive::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#pragma once

#include "rive/pls/trivial_block_allocator.hpp"
#include "rive/renderer/trivial_block_allocator.hpp"

namespace rive::pls
namespace rive::gpu
{
// Fast, simple queue that operates on a block-allocated array. push_back() may only be called up to
// m_capacity times before the queue must be rewound.
Expand Down Expand Up @@ -69,4 +69,4 @@ template <typename T> class FixedQueue
T* m_end = nullptr;
RIVE_DEBUG_CODE(size_t m_capacity = 0;)
};
} // namespace rive::pls
} // namespace rive::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#pragma once

#include "rive/pls/gl/gles3.hpp"
#include "rive/renderer/gl/gles3.hpp"
#include "rive/refcnt.hpp"
#include "rive/shapes/paint/blend_mode.hpp"

namespace rive::pls
namespace rive::gpu
{
// Lightweight wrapper around common GL state.
class GLState : public RefCnt<GLState>
Expand Down Expand Up @@ -57,4 +57,4 @@ class GLState : public RefCnt<GLState>
bool boundPixelUnpackBufferID : 1;
} m_validState;
};
} // namespace rive::pls
} // namespace rive::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "rive/pls/gl/gles3.hpp"
#include "rive/renderer/gl/gles3.hpp"
#include "rive/math/aabb.hpp"
#include <cstddef>
#include <utility>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#pragma once

#include "rive/pls/pls.hpp"
#include "rive/renderer/gpu.hpp"
#include "rive/enum_bitset.hpp"
#include <iostream>

namespace rive::pls
namespace rive::gpu
{
// When using EXT_shader_pixel_local_storage, we have to emulate the render pass load/store actions
// using a shader. These bits define specific actions that can be turned on or off in that shader.
Expand All @@ -25,9 +25,9 @@ RIVE_MAKE_ENUM_BITSET(LoadStoreActionsEXT)

// Determines the specific load actions that need to be emulated for the given render pass, and
// unpacks the clear color, if required.
LoadStoreActionsEXT BuildLoadActionsEXT(const pls::FlushDescriptor&,
LoadStoreActionsEXT BuildLoadActionsEXT(const gpu::FlushDescriptor&,
std::array<float, 4>* clearColor4f);

// Appends pls_load_store_ext.glsl to the stream, with the appropriate #defines prepended.
// Appends load_store_ext.glsl to the stream, with the appropriate #defines prepended.
std::ostream& BuildLoadStoreEXTGLSL(std::ostream&, LoadStoreActionsEXT);
} // namespace rive::pls
} // namespace rive::gpu
Loading

0 comments on commit 1b24bf9

Please sign in to comment.