-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an internal API to return the last DecodingOptions of an image
https://bugs.webkit.org/show_bug.cgi?id=271355 rdar://125133851 Reviewed by Simon Fraser. This will help ensuing the decoding mode heuristics are working as expected. The layout test is expected to fail. It will be unskipped by the fix of bug 270330. * LayoutTests/TestExpectations: * LayoutTests/fast/images/async-image-intersect-different-size-for-drawing-expected.txt: Added. * LayoutTests/fast/images/async-image-intersect-different-size-for-drawing.html: Added. * Source/WebCore/platform/graphics/BitmapImage.cpp: (WebCore::BitmapImage::draw): (WebCore::BitmapImage::lastDecodingOptionsForTesting const): * Source/WebCore/platform/graphics/BitmapImage.h: * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::imageLastDecodingOptions): * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.idl: Canonical link: https://commits.webkit.org/276451@main
- Loading branch information
Showing
8 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
LayoutTests/fast/images/async-image-intersect-different-size-for-drawing-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Ensures a renderer will decode its image synchronously if it intersects with another renderer with a different sizeForDrawing. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS decodingOptions is "{ decodingMode : Asynchronous, sizeForDrawing : { 500, 500 } }" | ||
PASS decodingOptions is "{ decodingMode : Synchronous, sizeForDrawing : { 1000, 1000 } }" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
105 changes: 105 additions & 0 deletions
105
LayoutTests/fast/images/async-image-intersect-different-size-for-drawing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<script src="../../resources/js-test.js"></script> | ||
<style> | ||
.container { | ||
width: 500px; | ||
height: 500px; | ||
border: 1px solid black; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
.intial-box { | ||
width: 100%; | ||
height: 100%; | ||
top: 0; | ||
left: 0; | ||
position: absolute; | ||
will-change: transform; | ||
display: none; | ||
} | ||
.final-box { | ||
left: -50%; | ||
top: -50%; | ||
width: 200%; | ||
height: 200%; | ||
position: absolute; | ||
transform: scale(0.5); | ||
will-change: transform; | ||
display: none; | ||
background-color: red; | ||
} | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
display: block; | ||
} | ||
</style> | ||
<body> | ||
<div class="container"> | ||
<div class="intial-box"></div> | ||
<div class="final-box"></div> | ||
</div> | ||
<script> | ||
description("Ensures a renderer will decode its image synchronously if it intersects with another renderer with a different sizeForDrawing."); | ||
window.jsTestIsAsync = true; | ||
|
||
function loadImageAndDraw(box, image, src) { | ||
return new Promise((resolve) => { | ||
image.onload = (() => { | ||
if (!window.internals) { | ||
box.style.display = "block"; | ||
resolve(); | ||
return; | ||
} | ||
|
||
box.style.display = "block"; | ||
|
||
// Force layout and display so the image gets drawn. | ||
document.body.offsetHeight; | ||
testRunner.display(); | ||
|
||
image.addEventListener("webkitImageFrameReady", function() { | ||
resolve(); | ||
}, false); | ||
}); | ||
|
||
image.src = src; | ||
}); | ||
} | ||
|
||
if (window.internals && window.testRunner) { | ||
internals.clearMemoryCache(); | ||
internals.settings.setWebkitImageReadyEventEnabled(true); | ||
internals.settings.setLargeImageAsyncDecodingEnabled(true); | ||
} | ||
|
||
let intialBox = document.querySelector(".intial-box"); | ||
let finalBox = document.querySelector(".final-box"); | ||
|
||
let image1 = new Image; | ||
intialBox.appendChild(image1); | ||
|
||
loadImageAndDraw(intialBox, image1, "resources/green-400x400.png").then(() => { | ||
requestAnimationFrame(() => { | ||
decodingOptions = internals.imageLastDecodingOptions(image1); | ||
shouldBeEqualToString("decodingOptions", "{ decodingMode : Asynchronous, sizeForDrawing : { 500, 500 } }"); | ||
|
||
finalBox.appendChild(image1.cloneNode(true)); | ||
finalBox.style.display = "block"; | ||
|
||
// Force layout and display so the image gets drawn. | ||
document.body.offsetHeight; | ||
if (window.testRunner) | ||
testRunner.display(); | ||
|
||
requestAnimationFrame(() => { | ||
decodingOptions = internals.imageLastDecodingOptions(image1); | ||
shouldBeEqualToString("decodingOptions", "{ decodingMode : Synchronous, sizeForDrawing : { 1000, 1000 } }"); | ||
finishJSTest(); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters