Add offscreen text rendering.
This commit is contained in:
parent
c63138c455
commit
076e32b1d6
17 changed files with 156 additions and 101 deletions
|
@ -6,6 +6,7 @@ add_library(test_utils STATIC
|
|||
TestCaseRunner.cpp
|
||||
TestUiApplication.h
|
||||
TestUiApplication.cpp
|
||||
TestRenderUtils.h
|
||||
)
|
||||
|
||||
target_include_directories(test_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
|
40
test/test_utils/TestRenderUtils.h
Normal file
40
test/test_utils/TestRenderUtils.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
|
||||
#include "DrawingSurface.h"
|
||||
#include "DrawingContext.h"
|
||||
#include "AbstractPainter.h"
|
||||
#include "Image.h"
|
||||
#include "PngWriter.h"
|
||||
#include "Scene.h"
|
||||
|
||||
class TestRenderer
|
||||
{
|
||||
public:
|
||||
TestRenderer(unsigned width = 1000, unsigned height = 1000)
|
||||
{
|
||||
mSurface = std::make_unique<DrawingSurface>();
|
||||
mSurface->setSize(width, height);
|
||||
|
||||
mDrawingContext = std::make_unique<DrawingContext>(mSurface.get());
|
||||
}
|
||||
|
||||
Scene* getScene() const
|
||||
{
|
||||
return mSurface->getScene();
|
||||
}
|
||||
|
||||
void write(const Path& path)
|
||||
{
|
||||
mDrawingContext->paint();
|
||||
|
||||
auto image = mSurface->getImage();
|
||||
|
||||
PngWriter writer;
|
||||
writer.setPath(path);
|
||||
writer.write(image);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<DrawingSurface> mSurface;
|
||||
std::unique_ptr<DrawingContext> mDrawingContext;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue