Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
copi143 committed Jan 28, 2025
1 parent 4f2553a commit 40fd75f
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 85 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<img id="logo" src="https://plos-logo.copi143.workers.dev" width="200" height="200" align="right">
</div>

A simple OS used to study made by several students。
A simple OS used to study made by several students.

<p style="font-size: x-large;">
Happy New Year!<br>
新年快乐!
</p>

<p style="font-size: x-large;">今年是 <img src="https://www.python.org/static/favicon.ico" alt="" style="height: 1em;" /> 年!</p>

![Static Badge](https://img.shields.io/badge/License-MIT-blue)
![Static Badge](https://img.shields.io/badge/Language-3-orange)
Expand Down
1 change: 0 additions & 1 deletion cmake/disable-warning
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif()
add_compile_flag("-Wno-address-of-packed-member")
add_compile_flag("-Wno-attributes")
add_compile_flag("-Wno-explicit-specialization-storage-class")

# add_compile_flag("-w") # 如果你不想编译器输出 warning
add_link_flag("-w") # 可恶的链接器警告
9 changes: 9 additions & 0 deletions doc/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ title: 主页

# Welcome to the Plant-OS Document / 欢迎来到 Plant-OS 文档页

Plant-OS is a simple OS used to study made by several students.

<p style="font-size: x-large;">
Happy New Year!<br>
新年快乐!
</p>

<p style="font-size: x-large;">今年是 <img src="https://www.python.org/static/favicon.ico" alt="" style="height: 1em;" /> 年!</p>

[The history / Plant-OS 史书](history.md)

## 其它自制 OS 项目
Expand Down
2 changes: 0 additions & 2 deletions include/pl2d/pixel/mix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ auto BasePixelT::mix(const BasePixelT &c1, const BasePixelT &c2) -> BasePixelT {
// 假如源和目标都有透明度
template <BasePixelTemplate>
void BasePixelT::mix(const BasePixelT &s) {
if (a == T_MAX) return mix_opaque(s);
T2 _a = (T2)T_MAX * (a + s.a) - a * s.a;
T2 sw = (T2)T_MAX * s.a;
T2 dw = a * ((T2)T_MAX - s.a);
Expand All @@ -115,7 +114,6 @@ void BasePixelT::mix(const BasePixelT &s) {
// 假如源和目标都有透明度
template <BasePixelTemplate>
auto BasePixelT::mix(const BasePixelT &c1, const BasePixelT &c2) -> BasePixelT {
if (c1.a == T_MAX) return mix_opaque(c1, c2);
T2 _a = (T2)T_MAX * (c1.a + c2.a) - c1.a * c2.a;
T2 w1 = (T2)T_MAX * c1.a;
T2 w2 = (T2)T_MAX * c2.a;
Expand Down
8 changes: 5 additions & 3 deletions include/pl2d/texture/paste.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace pl2d {

template <typename T>
template <typename T2>
auto BaseTexture<T>::paste_from(const BaseTexture<T2> &tex, i32 dx, i32 dy) -> BaseTexture & {
FLATTEN auto BaseTexture<T>::paste_from(const BaseTexture<T2> &tex, i32 dx, i32 dy)
-> BaseTexture & {
Rect rect = {(i32)tex.width, (i32)tex.height};
rect.trunc(-dx, -dy, (i32)width - dx - 1, (i32)height - dy - 1);
#if USE_ITERATOR
Expand All @@ -24,7 +25,8 @@ auto BaseTexture<T>::paste_from(const BaseTexture<T2> &tex, i32 dx, i32 dy) -> B

template <typename T>
template <typename T2>
auto BaseTexture<T>::paste_from_mix(const BaseTexture<T2> &tex, i32 dx, i32 dy) -> BaseTexture & {
FLATTEN auto BaseTexture<T>::paste_from_mix(const BaseTexture<T2> &tex, i32 dx, i32 dy)
-> BaseTexture & {
Rect rect = {(i32)tex.width, (i32)tex.height};
rect.trunc(-dx, -dy, (i32)width - dx - 1, (i32)height - dy - 1);
#if USE_ITERATOR
Expand All @@ -43,7 +45,7 @@ auto BaseTexture<T>::paste_from_mix(const BaseTexture<T2> &tex, i32 dx, i32 dy)

template <typename T>
template <typename T2>
auto BaseTexture<T>::paste_from_opaque(const BaseTexture<T2> &tex, i32 dx, i32 dy)
FLATTEN auto BaseTexture<T>::paste_from_opaque(const BaseTexture<T2> &tex, i32 dx, i32 dy)
-> BaseTexture & {
Rect rect = {(i32)tex.width, (i32)tex.height};
rect.trunc(-dx, -dy, (i32)width - dx - 1, (i32)height - dy - 1);
Expand Down
32 changes: 14 additions & 18 deletions src/pl2d/fb/flush-bgr.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#pragma once
#include "private.hpp"

namespace pl2d::framebuffer {
namespace {

template <>
finline void fb_flush_pix<PixFmt::BGR>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::BGR>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->b;
fb_p[1] = tex_p->g;
fb_p[2] = tex_p->r;
}
template <>
finline void fb_flush_pix<PixFmt::BGR>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::BGR>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->b * 255.f;
fb_p[1] = tex_p->g * 255.f;
fb_p[2] = tex_p->r * 255.f;
}
template <>
finline void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x, u32 y) {
INLINE void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->b = fb_p[0];
Expand All @@ -29,7 +29,7 @@ finline void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureB &
tex_p->a = 255;
}
template <>
finline void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x, u32 y) {
INLINE void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->b = fb_p[0] / 255.f;
Expand All @@ -39,7 +39,7 @@ finline void fb_copy_to_pix<PixFmt::BGR>(const FrameBuffer &fb, pl2d::TextureF &
}

template <>
finline void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->b;
Expand All @@ -48,7 +48,7 @@ finline void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureB &t
fb_p[3] = tex_p->a;
}
template <>
finline void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->b * 255.f;
Expand All @@ -57,8 +57,7 @@ finline void fb_flush_pix<PixFmt::BGRA>(FrameBuffer &fb, const pl2d::TextureF &t
fb_p[3] = tex_p->a * 255.f;
}
template <>
finline void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x,
u32 y) {
INLINE void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->b = fb_p[0];
Expand All @@ -67,8 +66,7 @@ finline void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureB
tex_p->a = fb_p[3];
}
template <>
finline void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x,
u32 y) {
INLINE void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->b = fb_p[0] / 255.f;
Expand All @@ -78,7 +76,7 @@ finline void fb_copy_to_pix<PixFmt::BGRA>(const FrameBuffer &fb, pl2d::TextureF
}

template <>
finline void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->a;
Expand All @@ -87,7 +85,7 @@ finline void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureB &t
fb_p[3] = tex_p->r;
}
template <>
finline void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
INLINE void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
fb_p[0] = tex_p->a * 255.f;
Expand All @@ -96,8 +94,7 @@ finline void fb_flush_pix<PixFmt::ABGR>(FrameBuffer &fb, const pl2d::TextureF &t
fb_p[3] = tex_p->r * 255.f;
}
template <>
finline void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x,
u32 y) {
INLINE void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureB &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->a = fb_p[0];
Expand All @@ -106,8 +103,7 @@ finline void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureB
tex_p->r = fb_p[3];
}
template <>
finline void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x,
u32 y) {
INLINE void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureF &tex, u32 x, u32 y) {
byte *_rest fb_p = &fb.pix8[0][y * fb.pitch + x * fb.padding];
auto *_rest tex_p = &tex.pixels[y * tex.pitch + x];
tex_p->a = fb_p[0] / 255.f;
Expand All @@ -116,4 +112,4 @@ finline void fb_copy_to_pix<PixFmt::ABGR>(const FrameBuffer &fb, pl2d::TextureF
tex_p->r = fb_p[3] / 255.f;
}

} // namespace pl2d::framebuffer
} // namespace
4 changes: 2 additions & 2 deletions src/pl2d/fb/flush-cases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace pl2d {
} while (0)

#define CASE(_name_) \
case PixFmt::_name_: framebuffer::fb_flush<PixFmt::_name_>(*this, tex, rect); break
case PixFmt::_name_: ::fb_flush<PixFmt::_name_>(*this, tex, rect); break
auto FrameBuffer::flush(const pl2d::TextureB &tex, const pl2d::Rect &rect) -> int {
RUN;
}
Expand All @@ -30,7 +30,7 @@ auto FrameBuffer::flush(const pl2d::TextureF &tex, const pl2d::Rect &rect) -> in
#undef CASE

#define CASE(_name_) \
case PixFmt::_name_: framebuffer::fb_copy_to<PixFmt::_name_>(*this, tex, rect); break
case PixFmt::_name_: ::fb_copy_to<PixFmt::_name_>(*this, tex, rect); break
auto FrameBuffer::copy_to(pl2d::TextureB &tex, const pl2d::Rect &rect) const -> int {
RUN;
}
Expand Down
20 changes: 10 additions & 10 deletions src/pl2d/fb/flush-loop.hpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
#pragma once
#include "private.hpp"

namespace pl2d::framebuffer {
namespace {

template <PixFmt fmt>
static vectorize FLATTEN void fb_flush(FrameBuffer &fb, const pl2d::TextureB &tex,
const pl2d::Rect &rect) {
vectorize FLATTEN void fb_flush(FrameBuffer &fb, const pl2d::TextureB &tex,
const pl2d::Rect &rect) {
for (u32 y = rect.y1; y <= rect.y2; y++) {
for (u32 x = rect.x1; x <= rect.x2; x++) {
fb_flush_pix<fmt>(fb, tex, x, y);
}
}
}
template <PixFmt fmt>
static vectorize FLATTEN void fb_flush(FrameBuffer &fb, const pl2d::TextureF &tex,
const pl2d::Rect &rect) {
vectorize FLATTEN void fb_flush(FrameBuffer &fb, const pl2d::TextureF &tex,
const pl2d::Rect &rect) {
for (u32 y = rect.y1; y <= rect.y2; y++) {
for (u32 x = rect.x1; x <= rect.x2; x++) {
fb_flush_pix<fmt>(fb, tex, x, y);
}
}
}
template <PixFmt fmt>
static vectorize FLATTEN void fb_copy_to(const FrameBuffer &fb, pl2d::TextureB &tex,
const pl2d::Rect &rect) {
vectorize FLATTEN void fb_copy_to(const FrameBuffer &fb, pl2d::TextureB &tex,
const pl2d::Rect &rect) {
for (u32 y = rect.y1; y <= rect.y2; y++) {
for (u32 x = rect.x1; x <= rect.x2; x++) {
fb_copy_to_pix<fmt>(fb, tex, x, y);
}
}
}
template <PixFmt fmt>
static vectorize FLATTEN void fb_copy_to(const FrameBuffer &fb, pl2d::TextureF &tex,
const pl2d::Rect &rect) {
vectorize FLATTEN void fb_copy_to(const FrameBuffer &fb, pl2d::TextureF &tex,
const pl2d::Rect &rect) {
for (u32 y = rect.y1; y <= rect.y2; y++) {
for (u32 x = rect.x1; x <= rect.x2; x++) {
fb_copy_to_pix<fmt>(fb, tex, x, y);
}
}
}

} // namespace pl2d::framebuffer
} // namespace
Loading

0 comments on commit 40fd75f

Please sign in to comment.