Merge pull request #15346 from Snuffleupagus/deprecated-imageLayer

[api-minor] Deprecate the `imageLayer` functionality
This commit is contained in:
Tim van der Meij 2022-08-27 13:16:31 +02:00 committed by GitHub
commit d715094383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
import {
deprecated,
getCurrentTransform,
getCurrentTransformInverse,
getRGB,
PixelsPerInch,
} from "./display_utils.js";
import { import {
FeatureTest, FeatureTest,
FONT_IDENTITY_MATRIX, FONT_IDENTITY_MATRIX,
@ -26,12 +33,6 @@ import {
Util, Util,
warn, warn,
} from "../shared/util.js"; } from "../shared/util.js";
import {
getCurrentTransform,
getCurrentTransformInverse,
getRGB,
PixelsPerInch,
} from "./display_utils.js";
import { import {
getShadingPattern, getShadingPattern,
PathType, PathType,
@ -1184,6 +1185,9 @@ class CanvasGraphics {
this.baseTransform = getCurrentTransform(this.ctx); this.baseTransform = getCurrentTransform(this.ctx);
if (this.imageLayer) { if (this.imageLayer) {
deprecated(
"The `imageLayer` functionality will be removed in the future."
);
this.imageLayer.beginLayout(); this.imageLayer.beginLayout();
} }
} }
@ -3067,11 +3071,14 @@ class CanvasGraphics {
); );
if (this.imageLayer) { if (this.imageLayer) {
const position = this.getCanvasPosition(0, -height); const [left, top] = Util.applyTransform(
[0, -height],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({ this.imageLayer.appendImage({
imgData, imgData,
left: position[0], left,
top: position[1], top,
width: rWidth, width: rWidth,
height: rHeight, height: rHeight,
}); });
@ -3109,11 +3116,14 @@ class CanvasGraphics {
1 1
); );
if (this.imageLayer) { if (this.imageLayer) {
const position = this.getCanvasPosition(entry.x, entry.y); const [left, top] = Util.applyTransform(
[entry.x, entry.y],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({ this.imageLayer.appendImage({
imgData, imgData,
left: position[0], left,
top: position[1], top,
width: w, width: w,
height: h, height: h,
}); });
@ -3309,14 +3319,6 @@ class CanvasGraphics {
} }
} }
getCanvasPosition(x, y) {
const transform = getCurrentTransform(this.ctx);
return [
transform[0] * x + transform[2] * y + transform[4],
transform[1] * x + transform[3] * y + transform[5],
];
}
isContentVisible() { isContentVisible() {
for (let i = this.markedContentStack.length - 1; i >= 0; i--) { for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
if (!this.markedContentStack[i].visible) { if (!this.markedContentStack[i].visible) {