Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pzaino committed Feb 29, 2024
1 parent 5e5076e commit e1858dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/cpp/fb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

#include "fb.hpp"
#include "layer.hpp" // Ensure this is included if not already included in fb.hpp
#include "layer.hpp"

// Constructor
FrameBuffer::FrameBuffer(unsigned int width, unsigned int height, std::shared_ptr<RenderStrategy> strategy)
Expand All @@ -28,7 +28,6 @@ FrameBuffer::FrameBuffer(unsigned int width, unsigned int height, std::shared_pt
// Add a layer to the framebuffer
void FrameBuffer::addLayer(const Layer& layer) {
layers.push_back(layer);
// Assuming Layer copy constructor or assignment operator handles the strategy correctly
}

// Remove a layer from the framebuffer by index
Expand Down Expand Up @@ -58,7 +57,6 @@ void FrameBuffer::setRenderStrategy(std::shared_ptr<RenderStrategy> strategy) {

// Placeholder for the actual implementation of merging all layers
void FrameBuffer::mergeLayers() {
// Implementation depends on how you want to combine the layers
// This could involve blending pixels from each layer based on their opacity,
// and visibility, or simply stacking them in order.
// For simplicity, we're not providing a specific implementation here.
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/layer
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Layer::Layer(pixel_t width, pixel_t height, std::shared_ptr<RenderStrategy> stra

// Destructor implementation
Layer::~Layer() {
// No manual resource management needed here due to use of smart pointers and vectors
// Not much for now
}

// Clear the layer with a specific color
Expand All @@ -41,12 +41,12 @@ void Layer::setPixel(pixel_t x, pixel_t y, color_t color) {
currentRenderStrategy->setPixel(pixels, x, y, color); // Use the render strategy to set the pixel
}

// Draw a line (placeholder for actual line drawing algorithm, e.g., Bresenham's)
// Draw a line
void Layer::drawLine(pixel_t x1, pixel_t y1, pixel_t x2, pixel_t y2, color_t color) {
currentRenderStrategy->drawLine(pixels, x1, y1, x2, y2, color); // Use the render strategy to draw the line
}

// Draw a rectangle (simple example)
// Draw a rectangle
void Layer::drawRect(pixel_t x, pixel_t y, pixel_t w, pixel_t h, color_t color) {
currentRenderStrategy->drawRect(pixels, x, y, w, h, color); // Use the render strategy to draw the rectangle
}
Expand Down

0 comments on commit e1858dd

Please sign in to comment.