Skip to content

Commit

Permalink
Rename to remove unneeded pls in variable names
Browse files Browse the repository at this point in the history
Diffs=
57a94aff0 Rename to remove unneeded pls in variable names (#7992)

Co-authored-by: rivessamr <suki@rive.app>
  • Loading branch information
rivessamr and rivessamr committed Aug 29, 2024
1 parent 26d42ff commit 9132fc2
Show file tree
Hide file tree
Showing 30 changed files with 237 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cc903ee0236a43b850488e029f270e5da23625b7
57a94aff03ab42d68b04c32ecbaeb4fadb752fec
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class RenderContextGLImpl : public RenderContextHelperImpl
DrawShader(const DrawShader&) = delete;
DrawShader& operator=(const DrawShader&) = delete;

DrawShader(RenderContextGLImpl* plsContextImpl,
DrawShader(RenderContextGLImpl* renderContextImpl,
GLenum shaderType,
gpu::DrawType drawType,
ShaderFeatures shaderFeatures,
Expand Down
2 changes: 1 addition & 1 deletion renderer/include/rive/renderer/render_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class RenderContext : public RiveRenderFactory

// High-level draw list. These get built into a low-level list of gpu::DrawBatch objects
// during writeResources().
std::vector<DrawUniquePtr> m_plsDraws;
std::vector<DrawUniquePtr> m_draws;
IAABB m_combinedDrawBounds;

// Layout state.
Expand Down
43 changes: 43 additions & 0 deletions renderer/include/rive/renderer/rive_render_image.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 Rive
*/

#pragma once

#include "rive/renderer/texture.hpp"

namespace rive
{
class RiveRenderImage : public lite_rtti_override<RenderImage, RiveRenderImage>
{
public:
RiveRenderImage(rcp<gpu::Texture> texture) :
RiveRenderImage(texture->width(), texture->height())
{
resetTexture(std::move(texture));
}

rcp<gpu::Texture> refTexture() const { return m_texture; }
const gpu::Texture* getTexture() const { return m_texture.get(); }

protected:
RiveRenderImage(int width, int height)
{
m_Width = width;
m_Height = height;
}

void resetTexture(rcp<gpu::Texture> texture = nullptr)
{
assert(texture == nullptr || texture->width() == m_Width);
assert(texture == nullptr || texture->height() == m_Height);
m_texture = std::move(texture);
}

// Used by the android runtime to send m_texture off to the worker thread to be deleted.
gpu::Texture* releaseTexture() { return m_texture.release(); }

private:
rcp<gpu::Texture> m_texture;
};
} // namespace rive
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,4 @@ class Texture : public RefCnt<Texture>
uint64_t m_bindlessTextureHandle = 0;
};

class Image : public lite_rtti_override<RenderImage, Image>
{
public:
Image(rcp<Texture> texture) : Image(texture->width(), texture->height())
{
resetTexture(std::move(texture));
}

rcp<Texture> refTexture() const { return m_texture; }
const Texture* getTexture() const { return m_texture.get(); }

protected:
Image(int width, int height)
{
m_Width = width;
m_Height = height;
}

void resetTexture(rcp<Texture> texture = nullptr)
{
assert(texture == nullptr || texture->width() == m_Width);
assert(texture == nullptr || texture->height() == m_Height);
m_texture = std::move(texture);
}

// Used by the android runtime to send m_texture off to the worker thread to be deleted.
Texture* releaseTexture() { return m_texture.release(); }

private:
rcp<Texture> m_texture;
};
} // namespace rive::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class RenderContextVulkanImpl : public RenderContextImpl
// its allocated descriptor sets.
// The vkutil::RenderingResource base ensures this class stays alive until its
// command buffer finishes, at which point we free the allocated descriptor
// sets and return the VkDescriptor to the plsContext.
// sets and return the VkDescriptor to the renderContext.
class DescriptorSetPool final : public vkutil::RenderingResource
{
public:
Expand All @@ -170,11 +170,11 @@ class RenderContextVulkanImpl : public RenderContextImpl
void freeDescriptorSets();

private:
// Recycles this instance in the plsContext's m_descriptorSetPoolPool, if
// the plsContext still exists.
// Recycles this instance in the renderContext's m_descriptorSetPoolPool, if
// the renderContext still exists.
void onRefCntReachedZero() const;

RenderContextVulkanImpl* const m_plsImplVulkan;
RenderContextVulkanImpl* const m_renderContextImpl;
VkDescriptorPool m_vkDescriptorPool;
std::vector<VkDescriptorSet> m_descriptorSets;
};
Expand Down
4 changes: 2 additions & 2 deletions renderer/path_fiddle/fiddle_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class FiddleContext
virtual ~FiddleContext() {}
virtual float dpiScale(GLFWwindow*) const = 0;
virtual rive::Factory* factory() = 0;
virtual rive::gpu::RenderContext* plsContextOrNull() = 0;
virtual rive::gpu::RenderTarget* plsRenderTargetOrNull() = 0;
virtual rive::gpu::RenderContext* renderContextOrNull() = 0;
virtual rive::gpu::RenderTarget* renderTargetOrNull() = 0;
virtual void onSizeChanged(GLFWwindow*, int width, int height, uint32_t sampleCount) {}
virtual void toggleZoomWindow() = 0;
virtual std::unique_ptr<rive::Renderer> makeRenderer(int width, int height) = 0;
Expand Down
20 changes: 10 additions & 10 deletions renderer/path_fiddle/fiddle_context_d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class FiddleContextD3DPLS : public FiddleContext
m_d3dFactory(std::move(d3dFactory)),
m_gpu(std::move(gpu)),
m_gpuContext(std::move(gpuContext)),
m_plsContext(RenderContextD3DImpl::MakeContext(m_gpu, m_gpuContext, contextOptions))
m_renderContext(RenderContextD3DImpl::MakeContext(m_gpu, m_gpuContext, contextOptions))
{}

float dpiScale(GLFWwindow*) const override { return 1; }

rive::Factory* factory() override { return m_plsContext.get(); }
rive::Factory* factory() override { return m_renderContext.get(); }

rive::gpu::RenderContext* plsContextOrNull() override { return m_plsContext.get(); }
rive::gpu::RenderContext* renderContextOrNull() override { return m_renderContext.get(); }

rive::gpu::RenderTarget* plsRenderTargetOrNull() override { return m_renderTarget.get(); }
rive::gpu::RenderTarget* renderTargetOrNull() override { return m_renderTarget.get(); }

void onSizeChanged(GLFWwindow* window, int width, int height, uint32_t sampleCount) override
{
Expand All @@ -60,21 +60,21 @@ class FiddleContextD3DPLS : public FiddleContext
NULL,
m_swapchain.ReleaseAndGetAddressOf()));

auto plsContextImpl = m_plsContext->static_impl_cast<RenderContextD3DImpl>();
m_renderTarget = plsContextImpl->makeRenderTarget(width, height);
auto renderContextImpl = m_renderContext->static_impl_cast<RenderContextD3DImpl>();
m_renderTarget = renderContextImpl->makeRenderTarget(width, height);
m_readbackTexture = nullptr;
}

void toggleZoomWindow() override {}

std::unique_ptr<Renderer> makeRenderer(int width, int height) override
{
return std::make_unique<RiveRenderer>(m_plsContext.get());
return std::make_unique<RiveRenderer>(m_renderContext.get());
}

void begin(const rive::gpu::RenderContext::FrameDescriptor& frameDescriptor) override
{
m_plsContext->beginFrame(frameDescriptor);
m_renderContext->beginFrame(frameDescriptor);
}

void flushPLSContext() final
Expand All @@ -88,7 +88,7 @@ class FiddleContextD3DPLS : public FiddleContext
reinterpret_cast<void**>(backbuffer.ReleaseAndGetAddressOf())));
m_renderTarget->setTargetTexture(backbuffer);
}
m_plsContext->flush({.renderTarget = m_renderTarget.get()});
m_renderContext->flush({.renderTarget = m_renderTarget.get()});
}

void end(GLFWwindow*, std::vector<uint8_t>* pixelData = nullptr) override
Expand Down Expand Up @@ -138,7 +138,7 @@ class FiddleContextD3DPLS : public FiddleContext
ComPtr<ID3D11DeviceContext> m_gpuContext;
ComPtr<IDXGISwapChain1> m_swapchain;
ComPtr<ID3D11Texture2D> m_readbackTexture;
std::unique_ptr<RenderContext> m_plsContext;
std::unique_ptr<RenderContext> m_renderContext;
rcp<RenderTargetD3D> m_renderTarget;
};

Expand Down
18 changes: 9 additions & 9 deletions renderer/path_fiddle/fiddle_context_dawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class FiddleContextDawnPLS : public FiddleContext
backendProcs.deviceSetLoggingCallback(m_backendDevice, device_log_callback, nullptr);
m_device = wgpu::Device::Acquire(m_backendDevice);
m_queue = m_device.GetQueue();
m_plsContext =
m_renderContext =
RenderContextWebGPUImpl::MakeContext(m_device,
m_queue,
RenderContextWebGPUImpl::ContextOptions());
Expand All @@ -171,11 +171,11 @@ class FiddleContextDawnPLS : public FiddleContext
return GetDawnWindowBackingScaleFactor(window, m_options.retinaDisplay);
}

Factory* factory() override { return m_plsContext.get(); }
Factory* factory() override { return m_renderContext.get(); }

rive::gpu::RenderContext* plsContextOrNull() override { return m_plsContext.get(); }
rive::gpu::RenderContext* renderContextOrNull() override { return m_renderContext.get(); }

rive::gpu::RenderTarget* plsRenderTargetOrNull() override { return m_renderTarget.get(); }
rive::gpu::RenderTarget* renderTargetOrNull() override { return m_renderTarget.get(); }

void onSizeChanged(GLFWwindow* window, int width, int height, uint32_t sampleCount) override
{
Expand Down Expand Up @@ -205,7 +205,7 @@ class FiddleContextDawnPLS : public FiddleContext
backendProcs.deviceCreateSwapChain(m_backendDevice, surface, &swapChainDesc);
m_swapchain = wgpu::SwapChain::Acquire(backendSwapChain);

m_renderTarget = m_plsContext->static_impl_cast<RenderContextWebGPUImpl>()
m_renderTarget = m_renderContext->static_impl_cast<RenderContextWebGPUImpl>()
->makeRenderTarget(wgpu::TextureFormat::BGRA8Unorm, width, height);
m_pixelReadBuff = {};
}
Expand All @@ -214,18 +214,18 @@ class FiddleContextDawnPLS : public FiddleContext

std::unique_ptr<Renderer> makeRenderer(int width, int height) override
{
return std::make_unique<RiveRenderer>(m_plsContext.get());
return std::make_unique<RiveRenderer>(m_renderContext.get());
}

void begin(const RenderContext::FrameDescriptor& frameDescriptor) override
{
assert(m_swapchain.GetCurrentTexture().GetWidth() == m_renderTarget->width());
assert(m_swapchain.GetCurrentTexture().GetHeight() == m_renderTarget->height());
m_renderTarget->setTargetTextureView(m_swapchain.GetCurrentTextureView());
m_plsContext->beginFrame(std::move(frameDescriptor));
m_renderContext->beginFrame(std::move(frameDescriptor));
}

void flushPLSContext() final { m_plsContext->flush({.renderTarget = m_renderTarget.get()}); }
void flushPLSContext() final { m_renderContext->flush({.renderTarget = m_renderTarget.get()}); }

void end(GLFWwindow* window, std::vector<uint8_t>* pixelData) final
{
Expand Down Expand Up @@ -327,7 +327,7 @@ class FiddleContextDawnPLS : public FiddleContext
wgpu::Queue m_queue = {};
wgpu::SwapChain m_swapchain = {};
std::unique_ptr<dawn::native::Instance> m_instance;
std::unique_ptr<RenderContext> m_plsContext;
std::unique_ptr<RenderContext> m_renderContext;
rcp<RenderTargetWebGPU> m_renderTarget;
wgpu::Buffer m_pixelReadBuff;
};
Expand Down
27 changes: 15 additions & 12 deletions renderer/path_fiddle/fiddle_context_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,18 @@ class FiddleContextGLPLS : public FiddleContextGL
public:
FiddleContextGLPLS()
{
if (!m_plsContext)
if (!m_renderContext)
{
fprintf(stderr, "Failed to create a PLS renderer.\n");
abort();
}
}

rive::Factory* factory() override { return m_plsContext.get(); }
rive::Factory* factory() override { return m_renderContext.get(); }

rive::gpu::RenderContext* plsContextOrNull() override { return m_plsContext.get(); }
rive::gpu::RenderContext* renderContextOrNull() override { return m_renderContext.get(); }

rive::gpu::RenderTarget* plsRenderTargetOrNull() override { return m_renderTarget.get(); }
rive::gpu::RenderTarget* renderTargetOrNull() override { return m_renderTarget.get(); }

void onSizeChanged(GLFWwindow* window, int width, int height, uint32_t sampleCount) override
{
Expand All @@ -222,25 +222,28 @@ class FiddleContextGLPLS : public FiddleContextGL

std::unique_ptr<Renderer> makeRenderer(int width, int height) override
{
return std::make_unique<RiveRenderer>(m_plsContext.get());
return std::make_unique<RiveRenderer>(m_renderContext.get());
}

void begin(const RenderContext::FrameDescriptor& frameDescriptor) override
{
m_plsContext->static_impl_cast<RenderContextGLImpl>()->invalidateGLState();
m_plsContext->beginFrame(frameDescriptor);
m_renderContext->static_impl_cast<RenderContextGLImpl>()->invalidateGLState();
m_renderContext->beginFrame(frameDescriptor);
}

void onEnd() override
{
flushPLSContext();
m_plsContext->static_impl_cast<RenderContextGLImpl>()->unbindGLInternalResources();
m_renderContext->static_impl_cast<RenderContextGLImpl>()->unbindGLInternalResources();
}

void flushPLSContext() override { m_plsContext->flush({.renderTarget = m_renderTarget.get()}); }
void flushPLSContext() override
{
m_renderContext->flush({.renderTarget = m_renderTarget.get()});
}

private:
std::unique_ptr<RenderContext> m_plsContext =
std::unique_ptr<RenderContext> m_renderContext =
RenderContextGLImpl::MakeContext(RenderContextGLImpl::ContextOptions());
rcp<RenderTargetGL> m_renderTarget;
};
Expand Down Expand Up @@ -288,9 +291,9 @@ class FiddleContextGLSkia : public FiddleContextGL

rive::Factory* factory() override { return &m_factory; }

rive::gpu::RenderContext* plsContextOrNull() override { return nullptr; }
rive::gpu::RenderContext* renderContextOrNull() override { return nullptr; }

rive::gpu::RenderTarget* plsRenderTargetOrNull() override { return nullptr; }
rive::gpu::RenderTarget* renderTargetOrNull() override { return nullptr; }

std::unique_ptr<Renderer> makeRenderer(int width, int height) override
{
Expand Down
Loading

0 comments on commit 9132fc2

Please sign in to comment.