Skip to content

Commit e69a95c

Browse files
committed
refactor: artboard不再单独申请texture
1 parent 4f233e8 commit e69a95c

File tree

4 files changed

+49
-15
lines changed

4 files changed

+49
-15
lines changed

src/refresh/struct.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ function renderWebglNoTile(
832832
cy = H * 0.5;
833833
const programs = root.programs;
834834
// 初始化工作
835-
const artBoardIndex: ArtBoard[] = [];
836835
let pageTexture = root.pageTexture || createTexture(gl, 0, undefined, W, H);
837836
let artBoardTexture: WebGLTexture | undefined; // 画布的背景色单独渲染,会干扰mbm的透明判断
838837
let resTexture = pageTexture;
@@ -844,6 +843,7 @@ function renderWebglNoTile(
844843
const program = programs.program;
845844
gl.useProgram(programs.program);
846845
// artboard的裁剪,以及记录artboard的画布rect来判断节点是否超出范围外
846+
const artBoardIndex: ArtBoard[] = [];
847847
let x1 = -1, y1 = -1, x2 = 1, y2 = 1;
848848
let abRect = new Float64Array([0, 0, W, H]);
849849
// 循环收集数据,同一个纹理内的一次性给出,只1次DrawCall
@@ -874,7 +874,7 @@ function renderWebglNoTile(
874874
abRect[3] = H;
875875
x1 = y1 = -1;
876876
x2 = y2 = 1;
877-
resTexture = drawArtBoard2Page(gl, program, cx, cy, W, H, pageTexture, resTexture);
877+
// resTexture = drawArtBoard2Page(gl, program, cx, cy, W, H, pageTexture, resTexture);
878878
}
879879
continue;
880880
}
@@ -921,15 +921,15 @@ function renderWebglNoTile(
921921
y1 = (ab.y1 - cy) / cy;
922922
x2 = (ab.x3 - cx) / cx;
923923
y2 = (ab.y3 - cy) / cy;
924-
artBoardTexture = createTexture(gl, 0, undefined, W, H);
925-
gl.framebufferTexture2D(
926-
gl.FRAMEBUFFER,
927-
gl.COLOR_ATTACHMENT0,
928-
gl.TEXTURE_2D,
929-
artBoardTexture,
930-
0,
931-
);
932-
resTexture = artBoardTexture;
924+
// artBoardTexture = createTexture(gl, 0, undefined, W, H);
925+
// gl.framebufferTexture2D(
926+
// gl.FRAMEBUFFER,
927+
// gl.COLOR_ATTACHMENT0,
928+
// gl.TEXTURE_2D,
929+
// artBoardTexture,
930+
// 0,
931+
// );
932+
// resTexture = artBoardTexture;
933933
}
934934
}
935935
// 检查画布内节点是否在画布范围内,否则可以跳过
@@ -941,7 +941,7 @@ function renderWebglNoTile(
941941
isInScreen = checkInRect(
942942
node._filterBbox || node.filterBbox, // 检测用原始的渲染用取整的
943943
matrix,
944-
abRect[0], abRect[1], abRect[2] - abRect[0], abRect[3] - abRect[1]
944+
abRect[0], abRect[1], abRect[2] - abRect[0], abRect[3] - abRect[1],
945945
);
946946
}
947947
}
@@ -985,11 +985,11 @@ function renderWebglNoTile(
985985
h: H,
986986
t: resTexture,
987987
});
988-
const isPagTex = resTexture === pageTexture;
988+
const isPageTex = resTexture === pageTexture;
989989
genBgBlur(gl, root, wrap, matrix, outline, blur, programs, scale, W, H);
990990
// blur过程会销毁掉原本的bg纹理,赋值要特别注意原本的page纹理
991991
resTexture = wrap.list[0].t!;
992-
if (isPagTex) {
992+
if (isPageTex) {
993993
pageTexture = resTexture;
994994
}
995995
gl.bindFramebuffer(gl.FRAMEBUFFER, resFrameBuffer);
@@ -1074,7 +1074,7 @@ function renderWebglNoTile(
10741074
abRect[3] = H;
10751075
x1 = y1 = -1;
10761076
x2 = y2 = 1;
1077-
resTexture = drawArtBoard2Page(gl, program, cx, cy, W, H, pageTexture, resTexture);
1077+
// resTexture = drawArtBoard2Page(gl, program, cx, cy, W, H, pageTexture, resTexture);
10781078
}
10791079
}
10801080
renderOverlay(gl, cx, cy, W, H, root, false);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8"/>
5+
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=0"/>
6+
<title>test</title>
7+
<style>
8+
canvas {
9+
display: block;
10+
width: 500px;
11+
height: 500px;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<canvas width="1000" height="1000"></canvas>
17+
<input id="base64" type="text" value=""/>
18+
<script src="../../../dist/index.js"></script>
19+
<script src="../../render.js"></script>
20+
</body>
21+
</html>
4.56 KB
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
module.exports = {
5+
'init': function(browser) {
6+
browser
7+
.url('file://' + path.join(__dirname, 'index.html'))
8+
.waitForElementVisible('body', 1000)
9+
.pause(20)
10+
.assert.value('input', '')
11+
.end();
12+
}
13+
};

0 commit comments

Comments
 (0)