Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Impl copyTexImage2D and copyTexSubImage2D
Implement copyTexImage2D and copyTexSubImage2D for
WebGLRenderingContext.
  • Loading branch information
dlrobertson committed May 24, 2016
1 parent f1efeb0 commit 867cd9b
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 130 deletions.
322 changes: 227 additions & 95 deletions components/script/dom/webglrenderingcontext.rs

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions components/script/dom/webgltexture.rs
Expand Up @@ -309,7 +309,7 @@ impl WebGLTexture {
true
}

fn image_info_at_face(&self, face: u8, level: u32) -> ImageInfo {
pub fn image_info_at_face(&self, face: u8, level: u32) -> ImageInfo {
let pos = (level * self.face_count.get() as u32) + face as u32;
self.image_info_array.borrow()[pos as usize]
}
Expand Down Expand Up @@ -340,7 +340,7 @@ impl Drop for WebGLTexture {
}

#[derive(Clone, Copy, PartialEq, Debug, JSTraceable, HeapSizeOf)]
struct ImageInfo {
pub struct ImageInfo {
width: u32,
height: u32,
depth: u32,
Expand All @@ -359,6 +359,18 @@ impl ImageInfo {
}
}

pub fn width(&self) -> u32 {
self.width
}

pub fn height(&self) -> u32 {
self.height
}

pub fn internal_format(&self) -> Option<u32> {
self.internal_format
}

fn is_power_of_two(&self) -> bool {
self.width.is_power_of_two() && self.height.is_power_of_two() && self.depth.is_power_of_two()
}
Expand Down
12 changes: 7 additions & 5 deletions components/script/dom/webidls/WebGLRenderingContext.webidl
Expand Up @@ -523,11 +523,13 @@ interface WebGLRenderingContextBase
GLsizei width, GLsizei height, GLenum format,
object data);

//void copyTexImage2D(GLenum target, GLint level, GLenum internalformat,
// GLint x, GLint y, GLsizei width, GLsizei height,
// GLint border);
//void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLint x, GLint y, GLsizei width, GLsizei height);
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
void copyTexImage2D(GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height,
GLint border);
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height);

WebGLBuffer? createBuffer();
WebGLFramebuffer? createFramebuffer();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,5 +1,14 @@
[copy-tex-image-2d-formats.html]
type: testharness
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
expected: FAIL
[WebGL test #6: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
expected: FAIL
[WebGL test #9: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
expected: FAIL
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
expected: FAIL
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
expected: FAIL
[WebGL test #16: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

@@ -1,10 +1,5 @@
[texture-npot.html]
type: testharness
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

[WebGL test #4: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

[WebGL test #4: at (0, 0) expected: 0,0,0,255 was 192,0,128,64]
expected: FAIL
Expand All @@ -15,6 +10,110 @@
[WebGL test #7: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #9: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
[WebGL test #9: getError expected: INVALID_VALUE. Was INVALID_ENUM : copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.]
expected: FAIL

[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #14: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
expected: FAIL

[WebGL test #17: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #19: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #20: at (0, 0) expected: 192,0,128,255 was 0,0,0,255]
expected: FAIL

[WebGL test #21: getError expected: INVALID_VALUE. Was INVALID_ENUM : copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.]
expected: FAIL

[WebGL test #24: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #26: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
expected: FAIL

[WebGL test #29: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #31: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #32: at (0, 0) expected: 192,192,192,255 was 0,0,0,255]
expected: FAIL

[WebGL test #33: getError expected: INVALID_VALUE. Was INVALID_ENUM : copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.]
expected: FAIL

[WebGL test #36: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #38: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
expected: FAIL

[WebGL test #41: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #43: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #44: at (0, 0) expected: 0,0,0,64 was 0,0,0,255]
expected: FAIL

[WebGL test #45: getError expected: INVALID_VALUE. Was INVALID_ENUM : copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.]
expected: FAIL

[WebGL test #48: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #50: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
expected: FAIL

[WebGL test #53: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #55: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #56: at (0, 0) expected: 192,192,192,64 was 0,0,0,255]
expected: FAIL

[WebGL test #57: getError expected: INVALID_VALUE. Was INVALID_ENUM : copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.]
expected: FAIL

[WebGL test #60: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #64: at (0, 0) expected: 0,0,0,255 was 0,192,128,255]
expected: FAIL

[WebGL test #65: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from draw.]
expected: FAIL

[WebGL test #67: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #69: getError expected: NO_ERROR. Was INVALID_ENUM : gl.texImage2D with POT texture at level 0 should succeed]
expected: FAIL

[WebGL test #71: getError expected: NO_ERROR. Was INVALID_ENUM : gl.generateMipmap with POT texture should return succeed]
expected: FAIL

[WebGL test #76: at (0, 0) expected: 0,0,0,255 was 0,192,128,255]
expected: FAIL

[WebGL test #77: getError returned INVALID_ENUM. Possibly Chromium bug where texture unit is set to 0 instead of GL_TEXTURE0.]
expected: FAIL

[WebGL test #79: getError expected: NO_ERROR. Was INVALID_ENUM : Should be no errors from setup.]
expected: FAIL

[WebGL test #81: getError expected: NO_ERROR. Was INVALID_ENUM : gl.texImage2D with POT texture at level 0 should succeed]
expected: FAIL

[WebGL test #83: getError expected: NO_ERROR. Was INVALID_ENUM : gl.generateMipmap with POT texture should return succeed]
expected: FAIL

0 comments on commit 867cd9b

Please sign in to comment.