Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7bd871f

Browse files
committed
[[ RefactorGraphics ]] add MCGImageCreateWithRasterNoCopy function to libgraphics
1 parent 06eeddd commit 7bd871f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

libgraphics/include/graphics.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,15 @@ inline MCGPoint MCGPointMake(MCGFloat p_x, MCGFloat p_y)
175175

176176
////////////////////////////////////////////////////////////////////////////////
177177

178+
// Create new image with pixel data copied from raster
178179
bool MCGImageCreateWithRaster(const MCGRaster& raster, MCGImageRef& r_image);
180+
181+
// Create new image with pixel data provided by raster - raster retains ownership of pixel data
182+
bool MCGImageCreateWithRasterNoCopy(const MCGRaster &raster, MCGImageRef &r_image);
183+
184+
// Create new image with pixel data provided by raster - new image takes ownership of pixel data
179185
bool MCGImageCreateWithRasterAndRelease(const MCGRaster &raster, MCGImageRef &r_image);
186+
180187
bool MCGImageCreateWithData(const void *bytes, uindex_t byte_count, MCGImageRef& r_image);
181188
bool MCGImageCreateWithFilename(const char *filename, MCGImageRef& r_image);
182189

libgraphics/src/image.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ bool MCGImageCreateWithRasterAndRelease(const MCGRaster &p_raster, MCGImageRef &
5555
return __MCGImageCreateWithRaster(p_raster, r_image, kMCGPixelOwnershipTypeTake);
5656
}
5757

58+
bool MCGImageCreateWithRasterNoCopy(const MCGRaster& p_raster, MCGImageRef& r_image)
59+
{
60+
return __MCGImageCreateWithRaster(p_raster, r_image, kMCGPixelOwnershipTypeBorrow);
61+
}
62+
5863
bool MCGImageCreateWithRaster(const MCGRaster& p_raster, MCGImageRef& r_image)
5964
{
6065
return __MCGImageCreateWithRaster(p_raster, r_image, kMCGPixelOwnershipTypeCopy);

0 commit comments

Comments
 (0)