mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Generalized image decoding and resizing logic
Summary: public Standardises the image decoding logic for all image sources, meaning we get the benefits of efficient downscaling of images from all sources, not just ALAssets. Reviewed By: javache Differential Revision: D2647083 fb-gh-sync-id: e41456f838e4c6ab709b1c1523f651a86ff6e623
This commit is contained in:
committed by
facebook-github-bot-5
parent
9b87e6c860
commit
21fcbbc32c
@@ -46,19 +46,19 @@ RCTAssertEqualSizes(a.size, b.size); \
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {100, 20}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleToFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeStretch);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {100, 10}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFit);
|
||||
CGRect expected = {{0, 5}, {100, 10}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeContain);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {{-50, 0}, {200, 20}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeCover);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
}
|
||||
@@ -70,19 +70,19 @@ RCTAssertEqualSizes(a.size, b.size); \
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {100, 20}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleToFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeStretch);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {2, 20}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFit);
|
||||
CGRect expected = {{49, 0}, {2, 20}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeContain);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {{0, -490}, {100, 1000}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeCover);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
}
|
||||
@@ -94,19 +94,19 @@ RCTAssertEqualSizes(a.size, b.size); \
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {20, 50}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleToFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeStretch);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {CGPointZero, {5, 50}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFit);
|
||||
CGRect expected = {{7,0}, {5, 50}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeContain);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
{
|
||||
CGRect expected = {{0, -75}, {20, 200}};
|
||||
CGRect result = RCTTargetRect(content, target, 2, UIViewContentModeScaleAspectFill);
|
||||
CGRect result = RCTTargetRect(content, target, 2, RCTResizeModeCover);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ RCTAssertEqualSizes(a.size, b.size); \
|
||||
|
||||
{
|
||||
CGRect expected = {{0, -75}, {20, 200}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleAspectFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeCover);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ RCTAssertEqualSizes(a.size, b.size); \
|
||||
CGSize target = {3, 3};
|
||||
|
||||
CGRect expected = {CGPointZero, {3, 3}};
|
||||
CGRect result = RCTTargetRect(content, target, 1, UIViewContentModeScaleToFill);
|
||||
CGRect result = RCTTargetRect(content, target, 1, RCTResizeModeStretch);
|
||||
RCTAssertEqualRects(expected, result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user