зеркало из https://github.com/mozilla/pjs.git
b=433235, drawImage of canvas onto self is incorrect; r=roc
This commit is contained in:
Родитель
e8265188f4
Коммит
106e4d689a
|
@ -2750,7 +2750,9 @@ nsCanvasRenderingContext2D::CairoSurfaceFromElement(nsIDOMElement *imgElt,
|
|||
if (!forceCopy && canvas->CountContexts() == 1) {
|
||||
nsICanvasRenderingContextInternal *srcCanvas = canvas->GetContextAtIndex(0);
|
||||
rv = srcCanvas->GetThebesSurface(getter_AddRefs(sourceSurface));
|
||||
if (NS_FAILED(rv))
|
||||
// force a copy if we couldn't get the surface, or if it's
|
||||
// the same as what we have
|
||||
if (sourceSurface == mThebesSurface || NS_FAILED(rv))
|
||||
sourceSurface = nsnull;
|
||||
}
|
||||
|
||||
|
|
|
@ -458,6 +458,7 @@ _TEST_FILES_D = \
|
|||
test_2d.drawImage.alpha.html \
|
||||
test_2d.drawImage.clip.html \
|
||||
test_2d.drawImage.composite.html \
|
||||
test_2d.drawImage.self.html \
|
||||
$(NULL)
|
||||
|
||||
_TEST_FILES_E = \
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Canvas test: 2d.drawImage.self</title>
|
||||
<script src="/MochiKit/MochiKit.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
<body>
|
||||
<canvas id="c" width="300" height="150"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
var _deferred = false;
|
||||
function isPixel(ctx, x,y, r,g,b,a, pos, colour, d, f) {
|
||||
var pixel = ctx.getImageData(x, y, 1, 1);
|
||||
var pr = pixel.data[0],
|
||||
pg = pixel.data[1],
|
||||
pb = pixel.data[2],
|
||||
pa = pixel.data[3];
|
||||
(f || ok)(r-d <= pr && pr <= r+d &&
|
||||
g-d <= pg && pg <= g+d &&
|
||||
b-d <= pb && pb <= b+d &&
|
||||
a-d <= pa && pa <= a+d,
|
||||
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
MochiKit.DOM.addLoadEvent(function () {
|
||||
|
||||
var canvas = document.getElementById('c');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'lime';
|
||||
ctx.fillRect(0, 0, 300, 150);
|
||||
ctx.fillStyle = 'red';
|
||||
ctx.fillRect(0, 0, 300, 1);
|
||||
// Here the canvas should be 1 row red, 149 rows lime
|
||||
ctx.drawImage(canvas, 0, 1);
|
||||
// Here the canvas should be 2 rows red, 148 rows lime
|
||||
ctx.fillStyle = 'lime';
|
||||
ctx.fillRect(0, 0, 300, 2);
|
||||
// Here the canvas should be 150 rows lime
|
||||
|
||||
isPixel(ctx, 150,100, 0,255,0,255, "150,100", "0,255,0,255", 0);
|
||||
|
||||
if (!_deferred) SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
|
Загрузка…
Ссылка в новой задаче