Skip to content

Commit

Permalink
Add os::Surface::clipRegion() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Nov 27, 2024
1 parent e205538 commit 6c11553
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions gfx/region_skia.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ namespace gfx {
Region& operator&=(const Region& b) { return createIntersection(*this, b); }
Region& operator-=(const Region& b) { return createSubtraction(*this, b); }

const details::Region& skRegion() const { return m_region; }
details::Region& skRegion() { return m_region; }

private:
mutable details::Region m_region;
};
Expand Down
6 changes: 6 additions & 0 deletions os/skia/skia_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "base/file_handle.h"
#include "gfx/path.h"
#include "gfx/region.h"
#include "os/skia/skia_helpers.h"
#include "os/surface_format.h"
#include "os/system.h"
Expand Down Expand Up @@ -210,6 +211,11 @@ void SkiaSurface::clipPath(const gfx::Path& path)
m_canvas->clipPath(path.skPath());
}

void SkiaSurface::clipRegion(const gfx::Region& region)
{
m_canvas->clipRegion(region.skRegion());
}

void SkiaSurface::save()
{
m_canvas->save();
Expand Down
1 change: 1 addition & 0 deletions os/skia/skia_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SkiaSurface final : public Surface {
void restoreClip() override;
bool clipRect(const gfx::Rect& rc) override;
void clipPath(const gfx::Path& path) override;
void clipRegion(const gfx::Region& region) override;
void save() override;
void concat(const gfx::Matrix& matrix) override;
void setMatrix(const gfx::Matrix& matrix) override;
Expand Down
4 changes: 3 additions & 1 deletion os/surface.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// LAF OS Library
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2012-2018 David Capello
//
// This file is released under the terms of the MIT license.
Expand All @@ -25,6 +25,7 @@
namespace gfx {
class Matrix;
class Path;
class Region;
}

namespace os {
Expand Down Expand Up @@ -54,6 +55,7 @@ namespace os {
virtual void restoreClip() = 0;
virtual bool clipRect(const gfx::Rect& rc) = 0;
virtual void clipPath(const gfx::Path& path) = 0;
virtual void clipRegion(const gfx::Region& region) = 0;

virtual void save() = 0;
virtual void concat(const gfx::Matrix& matrix) = 0;
Expand Down

0 comments on commit 6c11553

Please sign in to comment.