Skip to content

Commit

Permalink
#147 feat: canvasのキャッシュキーの生成ロジックを変更
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Jul 16, 2024
1 parent 9e4ec8d commit 4c065eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Layer } from "@/core/domain/model/Layer";
import type { MovieClip } from "@/core/domain/model/MovieClip";
import { execute as movieClipRegisterEventUseCase } from "@/core/application/MovieClip/usecase/MovieClipRegisterEventUseCase";
import { execute as movieClipDisplayObjectComponent } from "../component/MovieClipDisplayObjectComponent";
import { $getCacheCanvas } from "@/cache/CacheUtil";
import { $getCacheCanvas, $setCacheCanvas } from "@/cache/CacheUtil";
import { execute as instanceUpdateBlendModeService } from "@/core/application/Instance/service/InstanceUpdateBlendModeService";
import { execute as screenAreaHierarchyAdjustmentService } from "@/screen/application/ScreenArea/service/ScreenAreaHierarchyAdjustmentService";
import { $getDeactivated, $getReDrawState } from "@/screen/application/ScreenArea/ScreenAreaUtil";
Expand Down Expand Up @@ -40,7 +40,7 @@ export const execute = async (
canvas = await instance.getHTMLElement();

// キャッシュに保存
// $setCacheCanvas(work_space_id, instance.id, cacheKey, canvas);
$setCacheCanvas(work_space_id, instance.id, cacheKey, canvas);
}

// ブレンドモードを設定
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Layer } from "@/core/domain/model/Layer";
import type { Shape } from "@/core/domain/model/Shape";
import { execute as shapeRegisterEventUseCase } from "@/core/application/Shape/usecase/ShapeRegisterEventUseCase";
import { execute as shapeDisplayObjectComponent } from "../component/ShapeDisplayObjectComponent";
import { $getCacheCanvas } from "@/cache/CacheUtil";
import { $getCacheCanvas, $setCacheCanvas } from "@/cache/CacheUtil";
import { execute as screenAreaHierarchyAdjustmentService } from "@/screen/application/ScreenArea/service/ScreenAreaHierarchyAdjustmentService";
import { execute as screenAreaReadOnlyElementService } from "@/screen/application/ScreenArea/service/ScreenAreaReadOnlyElementService";
import { execute as instanceUpdateBlendModeService } from "@/core/application/Instance/service/InstanceUpdateBlendModeService";
Expand Down Expand Up @@ -40,7 +40,7 @@ export const execute = async (
canvas = await instance.getHTMLElement(character);

// キャッシュに保存
// $setCacheCanvas(work_space_id, instance.id, cacheKey, canvas);
$setCacheCanvas(work_space_id, instance.id, cacheKey, canvas);
}

// ブレンドモードを設定
Expand Down
8 changes: 8 additions & 0 deletions src/js/core/domain/model/Character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { execute as characterCalcGetBoundsService } from "@/core/application/Cha
import { execute as characterCalcGetRectService } from "@/core/application/Character/service/CharacterCalcGetRectService";
import { PositionImpl } from "@/interface/PositionImpl";
import { $getCurrentWorkSpace } from "@/core/application/CoreUtil";
import { $BITMAP_TYPE } from "@/config/InstanceConfig";

/**
* @description DisplayObjectのユニークID
Expand Down Expand Up @@ -229,6 +230,13 @@ export class Character

}

const workSpace = $getCurrentWorkSpace();
const instance = workSpace.getLibrary(this._$libraryId);
if (instance && instance.type !== $BITMAP_TYPE) {
const scale = workSpace.scale;
cacheKey += `_${this.scaleX * scale}_${this.scaleY * scale}`;
}

// TODO filters

return cacheKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const execute = async (
}

// キャッシュに保存
// $setCacheCanvas(workSpace.id, instance.id, cacheKey, canvas);
$setCacheCanvas(workSpace.id, instance.id, cacheKey, canvas);
}

if (!canvas.dataset.base64) {
Expand Down

0 comments on commit 4c065eb

Please sign in to comment.