Skip to content

Commit

Permalink
fix: texImage2d & texImage3d using alt image types
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Mar 9, 2024
1 parent c71d6f7 commit f9d2afd
Show file tree
Hide file tree
Showing 69 changed files with 7,029 additions and 6,047 deletions.
11 changes: 0 additions & 11 deletions packages/canvas-polyfill/async/xhr/TNSXMLHttpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ export class TNSXMLHttpRequest {
password,
};
this._updateReadyStateChange(this.OPENED);
console.log(this._request);
}

setRequestHeader(header: string, value) {
Expand Down Expand Up @@ -668,7 +667,6 @@ export class TNSXMLHttpRequest {
url: this._request.url,
headers: this._headers,
onLoading: () => {
console.log('onLoading');
if (this.onloadstart) {
this.onloadstart();
}
Expand Down Expand Up @@ -699,7 +697,6 @@ export class TNSXMLHttpRequest {
this._updateReadyStateChange(this.LOADING);
},
onHeaders: (event) => {
console.log('onHeaders', event);
if (!isNaN(event.status)) {
this._status = event.status;
}
Expand Down Expand Up @@ -736,11 +733,8 @@ export class TNSXMLHttpRequest {

this._currentRequest = this._http.request(request);

console.log(this._currentRequest);

this._currentRequest
.then((res) => {
console.log(res);
if (!this._didUserSetResponseType) {
this._setResponseType();
}
Expand Down Expand Up @@ -854,16 +848,12 @@ export class TNSXMLHttpRequest {
const buffer = encoder.encode(res.content);
this._response = new Blob([buffer]);
} else {
console.log(res.content)
const buffer = (ArrayBuffer as any).from(res.content);
this._response = new Blob([buffer]);
}
}
}


console.log(this.responseType );

this._addToStringOnResponse();

if (this.onload) {
Expand All @@ -890,7 +880,6 @@ export class TNSXMLHttpRequest {
this._updateReadyStateChange(this.DONE);
})
.catch((error) => {
console.log('error', error);
const type: HttpError = error.type;
const method = this._request.method.toLowerCase();
switch (type) {
Expand Down
Binary file modified packages/canvas-polyfill/platforms/android/async-release.aar
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public class Async2 {
builder.readTimeout(options.timeout.toLong(), TimeUnit.MILLISECONDS)
builder.writeTimeout(options.timeout.toLong(), TimeUnit.MILLISECONDS)
}

if (options.username != null && options.password != null) {
builder.authenticator { route, response ->
if (response.request().header("Authorization") != null) {
Expand Down Expand Up @@ -236,8 +237,7 @@ public class Async2 {
e.printStackTrace()
}
if (value is JSONObject) {
var formBody: FormBody.Builder?
formBody = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val formBody = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
FormBody.Builder(StandardCharsets.UTF_8)
} else {
FormBody.Builder(Charset.forName("UTF-8"))
Expand Down Expand Up @@ -386,17 +386,35 @@ public class Async2 {
}
val source = responseBody.source()

stream = ByteBuffer
.allocateDirect(responseBody.contentLength().toInt())
.order(ByteOrder.nativeOrder())

val result = Result()
result.contentText = ""
result.url = response.request().url().toString()
result.headers = ArrayList()


var contentLength = responseBody.contentLength()


try {
source.read(stream!!)
stream?.rewind()

if (contentLength == -1L) {
val array = source.readByteArray()
stream = ByteBuffer
.allocateDirect(array.size)
.order(ByteOrder.nativeOrder())
stream?.put(array)
stream?.rewind()
} else {
stream = ByteBuffer
.allocateDirect(responseBody.contentLength().toInt())
.order(ByteOrder.nativeOrder())

source.read(stream!!)
stream?.rewind()
}



if (isTextType(returnType)) {
result.headers!!.add(KeyValuePair("Content-Type", returnType))
result.content = decodeBuffer(stream!!)
Expand Down Expand Up @@ -621,8 +639,7 @@ public class Async2 {

@Throws(IOException::class)
override fun writeTo(sink: BufferedSink) {
val bufferedSink: BufferedSink
bufferedSink = forwardingSink(sink).buffer()
val bufferedSink: BufferedSink = forwardingSink(sink).buffer()
body.writeTo(bufferedSink)
bufferedSink.close()
}
Expand Down
3 changes: 0 additions & 3 deletions packages/canvas/WebGL/WebGLRenderingContext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,7 @@ export class WebGLRenderingContextBase extends WebGLRenderingCommon {
}
}
} else if (border && typeof border.tagName === 'string' && border.tagName === 'CANVAS' && border._canvas instanceof Canvas) {

console.time('texImage2D');
this.native.texImage2D(target, level, internalformat, width, height, border._canvas.native);
console.timeEnd('texImage2D');
/*if (global.isAndroid) {
this.native.texImage2D(target, level, internalformat, width, height, border._canvas.native);
} else {
Expand Down
Binary file modified packages/canvas/platforms/android/canvas-release.aar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,18 @@ void canvas_native_webgl2_tex_image3d_asset(uint32_t target,
const struct ImageAsset *asset,
struct WebGLState *state);

void canvas_native_webgl2_tex_image3d_canvas2d(uint32_t target,
int32_t level,
int32_t internalformat,
int32_t _width,
int32_t _height,
int32_t depth,
int32_t border,
uint32_t format,
uint32_t type_,
struct CanvasRenderingContext2D *canvas,
struct WebGLState *state);

void canvas_native_webgl2_tex_image3d(uint32_t target,
int32_t level,
int32_t internalformat,
Expand Down Expand Up @@ -2631,6 +2643,19 @@ void canvas_native_webgl2_tex_sub_image3d_asset(uint32_t target,
const struct ImageAsset *asset,
struct WebGLState *state);

void canvas_native_webgl2_tex_sub_image3d_canvas2d(uint32_t target,
int32_t level,
int32_t xoffset,
int32_t yoffset,
int32_t zoffset,
int32_t width,
int32_t height,
int32_t depth,
uint32_t format,
uint32_t type_,
struct CanvasRenderingContext2D *canvas,
struct WebGLState *state);

void canvas_native_webgl2_tex_sub_image3d_offset(uint32_t target,
int32_t level,
int32_t xoffset,
Expand Down
Binary file not shown.
Loading

0 comments on commit f9d2afd

Please sign in to comment.