添加LightGame报告,规范接口命名

This commit is contained in:
2026-07-04 19:07:53 +08:00
parent 10872fde82
commit 36cbaf18c4
24 changed files with 619 additions and 163 deletions
+21 -24
View File
@@ -1,4 +1,4 @@
#include "Display.h"
#include "IDisplay.h"
#include "DrawContext.h"
#include "FrameBuffer.h"
#include "Image.h"
@@ -16,7 +16,7 @@ namespace
class CaptureDisplay : public Platform::IDisplay
{
public:
const Core::FrameBuffer* framebuffer;
const Core::FrameBuffer *framebuffer;
CaptureDisplay()
: framebuffer(nullptr)
@@ -24,16 +24,16 @@ namespace
}
bool init(int, int) override { return true; }
void present(const Core::FrameBuffer* fb) override { framebuffer = fb; }
void poll_events(bool&) override {}
void present(const Core::FrameBuffer *fb) override { framebuffer = fb; }
void poll_events(bool &) override {}
void shutdown() override {}
};
const Core::FramePixel* PresentPixels(Core::DrawContext& ctx, CaptureDisplay& display)
const Core::FramePixel *PresentPixels(Core::DrawContext &ctx, CaptureDisplay &display)
{
ctx.present(&display);
assert(display.framebuffer != nullptr);
return static_cast<const Core::FramePixel*>(display.framebuffer->get_buffer());
return static_cast<const Core::FramePixel *>(display.framebuffer->get_buffer());
}
void TestFramePixelIsRgb565()
@@ -49,18 +49,18 @@ namespace
Core::FrameBuffer framebuffer(2, 1);
framebuffer.clear(RenderData::Color(255, 0, 0, 255));
const Core::FramePixel* pixels = static_cast<const Core::FramePixel*>(framebuffer.get_buffer());
const Core::FramePixel *pixels = static_cast<const Core::FramePixel *>(framebuffer.get_buffer());
assert(pixels[0] == 0xF800u);
assert(pixels[1] == 0xF800u);
}
void TestImageDefaultsToRgba5551AndReturnsRawPixels()
{
const uint16_t default_pixels[] = { 0xF801u, 0x0000u };
const uint16_t default_pixels[] = {0xF801u, 0x0000u};
RenderData::Image default_image(default_pixels, 1, 1);
assert(default_image.format == RenderData::PixelFormat::RGBA5551);
const uint16_t explicit_pixels[] = { 0x07C1u };
const uint16_t explicit_pixels[] = {0x07C1u};
RenderData::Image explicit_image(
explicit_pixels,
1,
@@ -73,8 +73,7 @@ namespace
{
const uint16_t sprite_pixels[] = {
0xF800u,
0x07C1u
};
0x07C1u};
Core::DrawContext ctx(2, 1);
ctx.clear_color(RenderData::Color(0, 0, 255, 255));
@@ -91,8 +90,8 @@ namespace
ctx.present(&display);
assert(display.framebuffer != nullptr);
const Core::FramePixel* pixels =
static_cast<const Core::FramePixel*>(display.framebuffer->get_buffer());
const Core::FramePixel *pixels =
static_cast<const Core::FramePixel *>(display.framebuffer->get_buffer());
assert(pixels[0] == 0x001Fu);
assert(pixels[1] == 0x07E0u);
}
@@ -101,8 +100,7 @@ namespace
{
const uint16_t atlas_pixels[] = {
0xF801u,
0x07C1u
};
0x07C1u};
RenderData::Image atlas(
atlas_pixels,
@@ -116,7 +114,7 @@ namespace
ctx.draw_sprite(0, 0, sprite);
CaptureDisplay display;
const Core::FramePixel* pixels = PresentPixels(ctx, display);
const Core::FramePixel *pixels = PresentPixels(ctx, display);
assert(pixels[0] == 0x07E0u);
}
@@ -127,8 +125,7 @@ namespace
0x0000u,
0xF801u,
0x07C1u,
0x003Fu
};
0x003Fu};
RenderData::Image original(
original_pixels,
@@ -155,7 +152,7 @@ namespace
void TestDrawTextUsesBitMaskAndColor()
{
const uint8_t glyph_mask[] = { 0x90u };
const uint8_t glyph_mask[] = {0x90u};
RenderData::BitmapFont font;
font.mask_bits = glyph_mask;
@@ -171,7 +168,7 @@ namespace
ctx.draw_text(font, 0, 0, RenderData::Color::Red(), "A");
CaptureDisplay display;
const Core::FramePixel* pixels = PresentPixels(ctx, display);
const Core::FramePixel *pixels = PresentPixels(ctx, display);
assert(pixels[0] == 0xF800u);
assert(pixels[1] == 0x0000u);
assert(pixels[2] == 0x0000u);
@@ -180,7 +177,7 @@ namespace
void TestDrawTextColorChangesPerCallAndBackgroundFill()
{
const uint8_t glyph_mask[] = { 0x90u };
const uint8_t glyph_mask[] = {0x90u};
RenderData::BitmapFont font;
font.mask_bits = glyph_mask;
@@ -197,7 +194,7 @@ namespace
ctx.draw_text(font, 2, 0, RenderData::Color::Green(), "A");
CaptureDisplay display;
const Core::FramePixel* pixels = PresentPixels(ctx, display);
const Core::FramePixel *pixels = PresentPixels(ctx, display);
assert(pixels[0] == 0xFFFFu);
assert(pixels[1] == 0x001Fu);
assert(pixels[2] == 0x07E0u);
@@ -210,7 +207,7 @@ namespace
void TestDrawTextClipsBitMaskToScreen()
{
const uint8_t glyph_mask[] = { 0x90u };
const uint8_t glyph_mask[] = {0x90u};
RenderData::BitmapFont font;
font.mask_bits = glyph_mask;
@@ -227,7 +224,7 @@ namespace
ctx.draw_text(font, 3, 3, RenderData::Color::Red(), "A");
CaptureDisplay display;
const Core::FramePixel* pixels = PresentPixels(ctx, display);
const Core::FramePixel *pixels = PresentPixels(ctx, display);
assert(pixels[0] == 0x07E0u);
assert(pixels[1] == 0x0000u);
assert(pixels[2] == 0x0000u);