forked from floraachy/ImageKnife
!48 替换entry中所有使用到的过时ArkWorker.Worker为worker.ThreadWorker
Merge pull request !48 from 李艺为/master
This commit is contained in:
commit
f764b6e02a
|
@ -3,8 +3,6 @@
|
||||||
"buildOption": {
|
"buildOption": {
|
||||||
"sourceOption": {
|
"sourceOption": {
|
||||||
"workers": [
|
"workers": [
|
||||||
"./src/main/ets/pages/workers/worker1.js",
|
|
||||||
"./src/main/ets/pages/workers/gifParseWorker.ts",
|
|
||||||
'./src/main/ets/workers/GifLoadWorker.ts',
|
'./src/main/ets/workers/GifLoadWorker.ts',
|
||||||
'./src/main/ets/workers/PngLoadWorker.ts',
|
'./src/main/ets/workers/PngLoadWorker.ts',
|
||||||
'./src/main/ets/workers/MyWorker.ts'
|
'./src/main/ets/workers/MyWorker.ts'
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
import {GIFParseImpl} from '@ohos/imageknife'
|
import {GIFParseImpl} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker';
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct gifTestCasePage {
|
struct gifTestCasePage {
|
||||||
|
@ -51,7 +52,7 @@ struct gifTestCasePage {
|
||||||
globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.gifSample_single_frame').id)
|
globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.gifSample_single_frame').id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('basicTestFileIOPage - 本地加载资源 解析后数据data length = ' + data.byteLength)
|
console.log('basicTestFileIOPage - 本地加载资源 解析后数据data length = ' + data.byteLength)
|
||||||
let worker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
let local_worker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
@ -64,7 +65,7 @@ struct gifTestCasePage {
|
||||||
console.log('加载gif图片自带worker suc,长度='+data.length)
|
console.log('加载gif图片自带worker suc,长度='+data.length)
|
||||||
this.pixels = data[0]['drawPixelMap']
|
this.pixels = data[0]['drawPixelMap']
|
||||||
}
|
}
|
||||||
},worker)
|
},local_worker)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err));
|
console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err));
|
||||||
|
@ -111,7 +112,7 @@ struct gifTestCasePage {
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
console.log("aboutToAppear()")
|
console.log("aboutToAppear()")
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,6 +18,7 @@ import resourceManager from '@ohos.resourceManager';
|
||||||
import { FileUtils } from '@ohos/imageknife'
|
import { FileUtils } from '@ohos/imageknife'
|
||||||
import featureability from '@ohos.ability.featureAbility'
|
import featureability from '@ohos.ability.featureAbility'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
|
@ -109,11 +110,11 @@ struct PngjTestCasePage {
|
||||||
if (!this.pngdecodeRun2) {
|
if (!this.pngdecodeRun2) {
|
||||||
this.pngdecodeRun2 = true;
|
this.pngdecodeRun2 = true;
|
||||||
let pngj = new Pngj();
|
let pngj = new Pngj();
|
||||||
let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', {
|
let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'readPngImageAsync'
|
name: 'readPngImageAsync'
|
||||||
})
|
})
|
||||||
pngj.readPngImageAsync(worker, this.pngSource1, (sender, value) => {
|
pngj.readPngImageAsync(png_worker, this.pngSource1, (sender, value) => {
|
||||||
this.pngSource1 = sender
|
this.pngSource1 = sender
|
||||||
this.hint2 = 'img with=' + value.width + ' img height=' + value.height
|
this.hint2 = 'img with=' + value.width + ' img height=' + value.height
|
||||||
+ ' img depth=' + value.depth + ' img ctype=' + value.ctype
|
+ ' img depth=' + value.depth + ' img ctype=' + value.ctype
|
||||||
|
@ -154,11 +155,11 @@ struct PngjTestCasePage {
|
||||||
if (!this.pngdecodeRun3) {
|
if (!this.pngdecodeRun3) {
|
||||||
this.pngdecodeRun3 = true;
|
this.pngdecodeRun3 = true;
|
||||||
let pngj = new Pngj();
|
let pngj = new Pngj();
|
||||||
let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', {
|
let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'writePngWithStringAsync'
|
name: 'writePngWithStringAsync'
|
||||||
})
|
})
|
||||||
pngj.writePngWithStringAsync(worker, 'hello world', this.pngSource3, (sender, value) => {
|
pngj.writePngWithStringAsync(png_worker, 'hello world', this.pngSource3, (sender, value) => {
|
||||||
this.pngSource3 = sender
|
this.pngSource3 = sender
|
||||||
FileUtils.getInstance().createFileProcess(
|
FileUtils.getInstance().createFileProcess(
|
||||||
this.rootFolder + '/pngj',
|
this.rootFolder + '/pngj',
|
||||||
|
@ -199,16 +200,15 @@ struct PngjTestCasePage {
|
||||||
})
|
})
|
||||||
Button('writePng')
|
Button('writePng')
|
||||||
.onClick(()=>{
|
.onClick(()=>{
|
||||||
|
|
||||||
if (this.pngSource4) {
|
if (this.pngSource4) {
|
||||||
if (!this.pngdecodeRun4) {
|
if (!this.pngdecodeRun4) {
|
||||||
this.pngdecodeRun4 = true;
|
this.pngdecodeRun4 = true;
|
||||||
let pngj = new Pngj();
|
let pngj = new Pngj();
|
||||||
let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', {
|
let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'writePngAsync'
|
name: 'writePngAsync'
|
||||||
})
|
})
|
||||||
pngj.writePngAsync(worker, this.pngSource4, (sender, value) => {
|
pngj.writePngAsync(png_worker, this.pngSource4, (sender, value) => {
|
||||||
this.pngSource4 = sender
|
this.pngSource4 = sender
|
||||||
FileUtils.getInstance().createFileProcess(
|
FileUtils.getInstance().createFileProcess(
|
||||||
this.rootFolder + '/pngj',
|
this.rootFolder + '/pngj',
|
||||||
|
@ -224,8 +224,8 @@ struct PngjTestCasePage {
|
||||||
} else {
|
} else {
|
||||||
this.hint10 = '请先点击此处获取buffer'
|
this.hint10 = '请先点击此处获取buffer'
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}).margin({ top: 5, left: 10 })
|
.margin({ top: 5, left: 10 })
|
||||||
}.width('100%')
|
}.width('100%')
|
||||||
.height(60).backgroundColor(Color.Pink)
|
.height(60).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
ScaleType
|
ScaleType
|
||||||
} from '@ohos/imageknife'
|
} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker';
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct tempUrlTestPage {
|
struct tempUrlTestPage {
|
||||||
|
@ -84,7 +85,7 @@ struct tempUrlTestPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker'
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestGifDontAnimatePage {
|
struct TestGifDontAnimatePage {
|
||||||
|
@ -85,7 +86,7 @@ struct TestGifDontAnimatePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker'
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestImageKnifeOptionChangedPage {
|
struct TestImageKnifeOptionChangedPage {
|
||||||
|
@ -185,7 +186,7 @@ struct TestImageKnifeOptionChangedPage {
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
console.log("aboutToAppear()")
|
console.log("aboutToAppear()")
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {RotateImageTransformation} from '@ohos/imageknife'
|
||||||
import {GrayscaleTransformation} from '@ohos/imageknife'
|
import {GrayscaleTransformation} from '@ohos/imageknife'
|
||||||
import {SketchFilterTransformation} from '@ohos/imageknife'
|
import {SketchFilterTransformation} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker'
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestImageKnifeOptionChangedPage3 {
|
struct TestImageKnifeOptionChangedPage3 {
|
||||||
|
@ -198,7 +199,7 @@ struct TestImageKnifeOptionChangedPage3 {
|
||||||
}
|
}
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
console.log("aboutToAppear()")
|
console.log("aboutToAppear()")
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
ScaleType
|
ScaleType
|
||||||
} from '@ohos/imageknife'
|
} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker';
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestImageKnifeOptionChangedPage4 {
|
struct TestImageKnifeOptionChangedPage4 {
|
||||||
|
@ -113,7 +114,7 @@ struct TestImageKnifeOptionChangedPage4 {
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
console.log("aboutToAppear()")
|
console.log("aboutToAppear()")
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
ImageKnifeDrawFactory
|
ImageKnifeDrawFactory
|
||||||
} from '@ohos/imageknife'
|
} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker';
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestImageKnifeOptionChangedPage5 {
|
struct TestImageKnifeOptionChangedPage5 {
|
||||||
|
@ -95,7 +96,7 @@ struct TestImageKnifeOptionChangedPage5 {
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
console.log("aboutToAppear()")
|
console.log("aboutToAppear()")
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||||
import {RequestOption} from '@ohos/imageknife'
|
import {RequestOption} from '@ohos/imageknife'
|
||||||
import ArkWorker from '@ohos.worker'
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import worker from '@ohos.worker'
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
|
@ -614,7 +615,7 @@ struct TestPreloadPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', {
|
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||||
type: 'classic',
|
type: 'classic',
|
||||||
name: 'ImageKnifeParseGIF'
|
name: 'ImageKnifeParseGIF'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
import arkWorker from '@ohos.worker';
|
|
||||||
import { gifHandler } from '@ohos/imageknife/GifWorker'
|
|
||||||
|
|
||||||
arkWorker.parentPort.onmessage = gifHandler;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
import arkWorker from '@ohos.worker';
|
|
||||||
|
|
||||||
import {handler} from '@ohos/imageknife/PngWork'
|
|
||||||
|
|
||||||
arkWorker.parentPort.onmessage = handler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue