alexpana / wxWidgets

Read-only mirror of the wxWidgets SVN repo (automatically updated). Report issues here: http://trac.wxwidgets.org/
http://www.wxwidgets.org/
3 stars 0 forks source link

Clipping to wxRegion #13

Closed alexpana closed 10 years ago

alexpana commented 10 years ago

Direct2D allows for clipping based on axis aligned rectangles [1] and geometries [2]. However, the wxRegion object allows the use of bitmaps.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/dd756673%28v=vs.85%29.aspx [2] http://msdn.microsoft.com/en-us/library/windows/desktop/dd756675%28v=vs.85%29.aspx

vadz commented 10 years ago

It looks like this could be achieved by using a layer with geometric mask?

alexpana commented 10 years ago

It could, but the wxRegion allows the use of bitmap masks [1], making the region effectively raster.

[1] http://docs.wxwidgets.org/trunk/classwx_region.html#a9b8729b4d3acf9e77188f92ebdfaf168

csomor commented 10 years ago

Hi

Direct2D allows for clipping based on axis aligned rectangles [1] and geometries [2]. However, the wxRegion object allows the use of bitmaps.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/dd756673%28v=vs.85%29.aspx [2] http://msdn.microsoft.com/en-us/library/windows/desktop/dd756675%28v=vs.85%29.aspx

look at src/osx/carbon/region.cpp there I call a borrowed scanline algorithm to retrieve the geometry, so IMHO just support geometries, don't worry about natively supporting bitmap regions

Best,

Stefan

alexpana commented 10 years ago

look at src/osx/carbon/region.cpp there I call a borrowed scanline algorithm to retrieve the geometry, so IMHO just support geometries, don't worry about natively supporting bitmap regions

I was thinking about implementing a similar algorithm, but wasn't sure if it was worth the time. Thanks for this.

csomor commented 10 years ago

just as a reference: for arriving at the geometry from a wxRegion the other useful class is the wxRegionIterator, it iterates through all the wxRects from which the region is made up

alexpana commented 10 years ago

I just took a closer look at the rgncmn.cpp source file. I found out regions are only composed out of rectangles and the DoRegionUnion(...) handles the decomposition of the bitmap into rectangles. Does this mean using the wxRegionIterator will cover areas clipped by the bitmaps?

csomor commented 10 years ago

yes, however the wxRegion was created - whether it was by a native HRN or some wxBitmap, the region iterator gives you one rect after the other.

alexpana commented 10 years ago

This is implemented in f65c8c55ba1b5c3452eea55f7c923c5f84c55926