Skip to content

Commit

Permalink
修复 offscreen 模式下 clearview 不生效问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
bosscheng committed Nov 25, 2021
1 parent ec8291e commit 250b13f
Show file tree
Hide file tree
Showing 5 changed files with 36,393 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/public/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@


var showOperateBtns = true; // 是否显示按钮
var forceNoOffscreen = true; //
var forceNoOffscreen = false; //
var jessibuca = null;

function create() {
Expand Down
36,372 changes: 36,369 additions & 3 deletions demo/public/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/index.js.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import {$domToggle, $hideBtns, bufferStatus, checkFull, dataURLToFile, downloadImg, fpsStatus, now} from "../utils";
import {
$domToggle,
$hideBtns,
bufferStatus,
checkFull,
createEmptyImageBitmap,
dataURLToFile,
downloadImg,
fpsStatus,
now
} from "../utils";
import {EVEMTS, POST_MESSAGE, SCREENSHOT_TYPE} from "../constant";

export default (jessibuca) => {
Expand Down Expand Up @@ -114,6 +124,10 @@ export default (jessibuca) => {
jessibuca._clearView = () => {
if (jessibuca._contextGL) {
jessibuca._contextGL.clear(jessibuca._contextGL.COLOR_BUFFER_BIT);
} else if (jessibuca._bitmaprenderer) {
createEmptyImageBitmap(jessibuca.$canvasElement.width, jessibuca.$canvasElement.height).then((imageBitMap) => {
jessibuca._bitmaprenderer.transferFromImageBitmap(imageBitMap);
})
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,11 @@ export function bufferStatus(buffer, settingBuffer) {
result = BUFFER_STATUS.full;
}
return result;
}

export function createEmptyImageBitmap(width, height) {
const $canvasElement = document.createElement("canvas");
$canvasElement.width = width;
$canvasElement.height = height;
return createImageBitmap($canvasElement, 0, 0, width, height);
}

1 comment on commit 250b13f

@vercel
Copy link

@vercel vercel bot commented on 250b13f Nov 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.