Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lime/_internal/graphics/ImageCanvasUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ImageCanvasUtil
buffer.__srcCanvas.setAttribute("moz-opaque", "true");
}

buffer.__srcContext = buffer.__srcCanvas.getContext("2d", {alpha: image.transparent});
buffer.__srcContext = buffer.__srcCanvas.getContext("2d", {alpha: image.transparent, willReadFrequently: image.willReadFrequently});
}
#end
}
Expand Down
12 changes: 12 additions & 0 deletions src/lime/graphics/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ class Image
**/
public var width:Int;

#if (js && html5)
/**
Whether this image should be rendered on the CPU. This is slower, but speeds up operations
like `copyPixels()` that read from the image. Always set this value immediately after
constructing the image, before calling `ImageCanvasUtil.convertToCanvas()`.

To use this with `openfl.display.BitmapData`, create an instance with `fillColor` set to 0,
then immediately set `bitmapData.image.willReadFrequently = true`.
**/
@:noCompletion public var willReadFrequently:Bool = false;
#end

/**
A convenience property, unused internally, which may be helpful for different renderer
implementations
Expand Down