Skip to content

Commit

Permalink
#154 webglパッケージをv2へ移行
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Aug 20, 2024
1 parent 241eb60 commit 17521e0
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const execute = <P extends DisplayObjectContainer>(
}

render_queue.push(child.placeId, child.clipDepth);

switch (true) {

case child.isContainerEnabled: // 0x00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,36 @@ export const execute = (shape: Shape, character: IShapeCharacter): void =>
graphics.yMin = character.bounds.yMin;
graphics.yMax = character.bounds.yMax;

if (character.recodes) {

switch (true) {

// todo

default:
if (!character.recodeBuffer) {
character.recodeBuffer = new Float32Array(
graphicsToNumberArrayService(width, height, character.recodes)
);
$poolArray(character.recodes);
character.recodes = null;
}
graphics.buffer = character.recodeBuffer.slice(0);
break;

}
} else {
// todo
switch (true) {

case character.bitmapId > 0:
break;

case character.inBitmap:
break;

default:
switch (true) {

// todo

default:
if (character.recodes) {
character.recodeBuffer = new Float32Array(
graphicsToNumberArrayService(width, height, character.recodes)
);
$poolArray(character.recodes);
character.recodes = null;
}

if (!character.recodeBuffer) {
break;
}

graphics.buffer = character.recodeBuffer.slice(0);
break;

}
break;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const execute = (
): void => {

render_queue.push($RENDERER_SHAPE_TYPE);

if (!shape.visible) {
render_queue.push(0);
return ;
Expand Down Expand Up @@ -203,8 +202,8 @@ export const execute = (
const cacheKey = shape.cacheKey;

render_queue.push(cacheKey);
const cachePosition = $cacheStore.get(shape.uniqueKey, `${cacheKey}`);
if (!cachePosition) {
const cache = $cacheStore.get(shape.uniqueKey, `${cacheKey}`);
if (!cache) {
render_queue.push(0);

const buffer = graphics.buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ export const execute = (render_queue: Float32Array): void =>

$context.drawArraysInstanced();
$context.transferMainCanvas();
// $context.debug();
};
4 changes: 4 additions & 0 deletions packages/renderer/src/Shape/service/ShapeCommandService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,22 @@ export const execute = (commands: Float32Array, has_grid: boolean): void =>
break;

case GRADIENT_FILL:
console.log("GRADIENT_FILL");
// todo
break;

case GRADIENT_STROKE:
console.log("GRADIENT_STROKE");
// todo
break;

case BITMAP_FILL:
console.log("BITMAP_FILL");
// todo
break;

case BITMAP_STROKE:
console.log("BITMAP_STROKE");
// todo
break;

Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/src/Shape/usecase/ShapeRenderUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export const execute = (render_queue: Float32Array, index: number): number =>
const height = Math.ceil(Math.abs(yMax - yMin) * yScale);

node = $context.createNode(width, height);

$cacheStore.set(uniqueKey, `${cacheKey}`, node);

// 初期化して、描画範囲とmatrix設定
$context.reset();
$context.beginNodeRendering(node);
Expand Down Expand Up @@ -111,7 +112,6 @@ export const execute = (render_queue: Float32Array, index: number): number =>
if (!node) {
return index;
}

}

const radianX = Math.atan2(matrix[1], matrix[0]);
Expand Down
6 changes: 6 additions & 0 deletions packages/webgl/src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { execute as blnedDrawArraysInstancedUseCase } from "./Blend/usecase/Blne
import { execute as vertexArrayObjectBootUseCase } from "./VertexArrayObject/usecase/VertexArrayObjectBootUseCase";
import { execute as frameBufferManagerTransferMainCanvasService } from "./FrameBufferManager/service/FrameBufferManagerTransferMainCanvasService";
import { execute as blendEnableUseCase } from "./Blend/usecase/BlendEnableUseCase";
import { execute as contextDebugService } from "./Context/service/ContextDebugService";
import { $getAtlasAttachmentObject } from "./AtlasManager";
import {
$setReadFrameBuffer,
Expand Down Expand Up @@ -702,4 +703,9 @@ export class Context
{
frameBufferManagerTransferMainCanvasService();
}

debug (): void
{
contextDebugService();
}
}
36 changes: 36 additions & 0 deletions packages/webgl/src/Context/service/ContextDebugService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { $drawFrameBuffer } from "../../FrameBufferManager";
import { $context, $gl } from "../../WebGLUtil";

export const execute = (): void =>
{
const currentAttachmentObject = $context.currentAttachmentObject;
$context.bind($context.atlasAttachmentObject);

const width = $context.$mainAttachmentObject?.width;
const height = $context.$mainAttachmentObject?.height;

// use main Framebuffer
$gl.bindFramebuffer(
$gl.DRAW_FRAMEBUFFER,
null
);

// execute
$gl.blitFramebuffer(
0, 0, $context.atlasAttachmentObject?.width, $context.atlasAttachmentObject?.height,
0, 0, width, height,
$gl.COLOR_BUFFER_BIT,
$gl.NEAREST
);

// reset
$gl.bindFramebuffer(
$gl.DRAW_FRAMEBUFFER,
$drawFrameBuffer
);

if (currentAttachmentObject) {
$context.bind(currentAttachmentObject);
}

};

0 comments on commit 17521e0

Please sign in to comment.