Crafter.Graphics/implementations/Crafter.Graphics-UiElementBufferBufferBase.cpp

88 lines
No EOL
3.2 KiB
C++

/*
Crafter®.Graphics
Copyright (C) 2025 Catcrafts®
catcrafts.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 3.0 as published by the Free Software Foundation;
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
module Crafter.Graphics:UiElementBufferBufferBase_impl;
import :UiElement;
import std;
using namespace Crafter;
UiElementBufferBufferBase::UiElementBufferBufferBase(std::uint_fast32_t width, std::uint_fast32_t height) : UiElementBuffer(width, height), buffer(width*height) {
}
void UiElementBufferBufferBase::Create(std::uint_fast32_t width, std::uint_fast32_t height) {
this->width = width;
this->height = height;
buffer.resize(width * height);
}
void UiElementBufferBufferBase::Resize(std::uint_fast32_t width, std::uint_fast32_t height) {
this->width = width;
this->height = height;
buffer.resize(width*height);
}
void UiElementBufferBufferBase::Resize(std::uint_fast32_t width, std::uint_fast32_t height, std::uint_fast32_t offsetX, std::uint_fast32_t offsetY) {
}
void UiElementBufferBufferBase::ResizeNearestNeighbour(std::uint_fast32_t width, std::uint_fast32_t height) {
}
void UiElementBufferBufferBase::ResizeBicubic(std::uint_fast32_t width, std::uint_fast32_t height) {
}
void UiElementBufferBufferBase::Destroy() {
buffer.clear();
width = 0;
height = 0;
}
void UiElementBufferBufferBase::Copy(Pixel_BU8_GU8_RU8_AU8* dst) const {
std::memcpy(dst, buffer.data(), width*height*sizeof(Pixel_BU8_GU8_RU8_AU8));
}
void UiElementBufferBufferBase::CopyNearestNeighbour(Pixel_BU8_GU8_RU8_AU8* dst, std::uint_fast32_t dstWidth, std::uint_fast32_t dstHeight) const {
for (std::uint_fast32_t y = 0; y < dstHeight; y++) {
std::uint_fast32_t srcY = y * height / dstHeight;
for (std::uint_fast32_t x = 0; x < dstWidth; x++) {
std::uint_fast32_t srcX = x * width / dstWidth;
dst[y * dstWidth + x] = buffer[srcY * width + srcX];
}
}
}
void UiElementBufferBufferBase::CopyBicubic(Pixel_BU8_GU8_RU8_AU8* dst, std::uint_fast32_t dstWidth, std::uint_fast32_t dstHeight) const {
}
void UiElementBufferBufferBase::Write(Pixel_BU8_GU8_RU8_AU8* pixels) {
std::memcpy(buffer.data(), pixels, width*height*sizeof(Pixel_BU8_GU8_RU8_AU8));
}
void UiElementBufferBufferBase::Write(std::uint_fast32_t x, std::uint_fast32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) {
buffer[y * width + x] = pixel;
}
Pixel_BU8_GU8_RU8_AU8 UiElementBufferBufferBase::Read(std::uint_fast32_t x, std::uint_fast32_t y) const {
return buffer[y * width + x];
}
const Pixel_BU8_GU8_RU8_AU8* UiElementBufferBufferBase::Read() const {
return buffer.data();
}
Pixel_BU8_GU8_RU8_AU8* UiElementBufferBufferBase::Get() {
return buffer.data();
}
void UiElementBufferBufferBase::Store() {
}