Skip to content

Commit

Permalink
fixxes
Browse files Browse the repository at this point in the history
  • Loading branch information
msft-Jeyaram committed Nov 15, 2016
1 parent 46d8097 commit 81c6ff3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/unittests/CoreGraphics/CGBitmapContextTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void _TestPixelFormat(const CGRect bounds, const CGBitmapInfo info, DWORD expect
);
}

static void _expectArrayValues(BYTE* res, BYTE* source, int size) {
static void _expectArrayValues(const BYTE* res, const BYTE* source, int size) {
for (int i = 0; i < size; ++i) {
EXPECT_EQ(res[i], source[i]);
}
Expand Down Expand Up @@ -209,9 +209,9 @@ static void _expectArrayValues(BYTE* res, BYTE* source, int size) {
woc::unique_cf<CGImageRef> image(CGBitmapContextCreateImage(context.get()));
ASSERT_NE(image, nullptr);

NSData* dataProvider = static_cast<NSData*>(CGImageGetDataProvider(image.get()));
ASSERT_NE(dataProvider, nullptr);
woc::unique_cf<CFDataRef> rawData(CGDataProviderCopyData(CGImageGetDataProvider(image.get())));

This comment has been minimized.

Copy link
@DHowett-MSFT

DHowett-MSFT Nov 15, 2016

Sorry, what I meant to ask was:

If you get the data provider for a CGImage created from a CGBitmapContext on the reference platform, do you get direct (copying) access to its backing store/buffer?

This comment has been minimized.

Copy link
@msft-Jeyaram

msft-Jeyaram Nov 15, 2016

Author Contributor

The backing of the CGImage (obtained from CGBitmapcontext) is the copy of the CGBitmapContext Image data, on ref platform.

ASSERT_NE(rawData, nullptr);

NSData* ref = [[NSData dataWithBytesNoCopy:result length:4 freeWhenDone:NO] autorelease];
ASSERT_OBJCEQ(dataProvider, ref);
const BYTE* rData = static_cast<const BYTE*>(CFDataGetBytePtr(rawData.get()));
_expectArrayValues(result, rData, 4);
}

0 comments on commit 81c6ff3

Please sign in to comment.