OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 EXPECT_EQ(2, width); | 1924 EXPECT_EQ(2, width); |
1925 EXPECT_EQ(4, height); | 1925 EXPECT_EQ(4, height); |
1926 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); | 1926 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
1927 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 1927 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
1928 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 1928 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
1929 | 1929 |
1930 // Service ID is restored. | 1930 // Service ID is restored. |
1931 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 1931 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
1932 } | 1932 } |
1933 | 1933 |
| 1934 TEST_P(GLES2DecoderTest, ProduceAndConsumeDirectTextureCHROMIUM) { |
| 1935 Mailbox mailbox = Mailbox::Generate(); |
| 1936 |
| 1937 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1938 DoTexImage2D( |
| 1939 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1940 DoTexImage2D( |
| 1941 GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1942 TextureRef* texture_ref = |
| 1943 group().texture_manager()->GetTexture(client_texture_id_); |
| 1944 ASSERT_TRUE(texture_ref != NULL); |
| 1945 Texture* texture = texture_ref->texture(); |
| 1946 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1947 |
| 1948 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = |
| 1949 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); |
| 1950 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); |
| 1951 EXPECT_EQ(error::kNoError, |
| 1952 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); |
| 1953 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1954 |
| 1955 // Texture didn't change. |
| 1956 GLsizei width; |
| 1957 GLsizei height; |
| 1958 GLenum type; |
| 1959 GLenum internal_format; |
| 1960 |
| 1961 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 1962 EXPECT_EQ(3, width); |
| 1963 EXPECT_EQ(1, height); |
| 1964 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 1965 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1966 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1967 |
| 1968 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 1969 EXPECT_EQ(2, width); |
| 1970 EXPECT_EQ(4, height); |
| 1971 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 1972 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1973 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1974 |
| 1975 // Service ID has not changed. |
| 1976 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1977 |
| 1978 // Consume the texture into a new client ID. |
| 1979 GLuint new_texture_id = kNewClientId; |
| 1980 CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd = |
| 1981 *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>(); |
| 1982 consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); |
| 1983 EXPECT_EQ(error::kNoError, |
| 1984 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); |
| 1985 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1986 |
| 1987 // Make sure the new client ID is associated with the produced service ID. |
| 1988 texture_ref = group().texture_manager()->GetTexture(new_texture_id); |
| 1989 ASSERT_TRUE(texture_ref != NULL); |
| 1990 texture = texture_ref->texture(); |
| 1991 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1992 |
| 1993 DoBindTexture(GL_TEXTURE_2D, kNewClientId, kServiceTextureId); |
| 1994 |
| 1995 // Texture is redefined. |
| 1996 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 1997 EXPECT_EQ(3, width); |
| 1998 EXPECT_EQ(1, height); |
| 1999 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 2000 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 2001 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 2002 |
| 2003 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 2004 EXPECT_EQ(2, width); |
| 2005 EXPECT_EQ(4, height); |
| 2006 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 2007 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 2008 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 2009 } |
| 2010 |
| 2011 TEST_P(GLES2DecoderTest, ProduceTextureCHROMIUMInvalidTarget) { |
| 2012 Mailbox mailbox = Mailbox::Generate(); |
| 2013 |
| 2014 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
| 2015 DoTexImage2D( |
| 2016 GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 1, 0, GL_RGBA, |
| 2017 GL_UNSIGNED_BYTE, 0, 0); |
| 2018 TextureRef* texture_ref = |
| 2019 group().texture_manager()->GetTexture(client_texture_id_); |
| 2020 ASSERT_TRUE(texture_ref != NULL); |
| 2021 Texture* texture = texture_ref->texture(); |
| 2022 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 2023 |
| 2024 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = |
| 2025 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); |
| 2026 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); |
| 2027 EXPECT_EQ(error::kNoError, |
| 2028 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); |
| 2029 |
| 2030 // ProduceTexture should fail it the texture and produce targets don't match. |
| 2031 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2032 } |
| 2033 |
1934 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { | 2034 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { |
1935 InitState init; | 2035 InitState init; |
1936 init.extensions = "GL_ANGLE_depth_texture"; | 2036 init.extensions = "GL_ANGLE_depth_texture"; |
1937 init.gl_version = "opengl es 2.0"; | 2037 init.gl_version = "opengl es 2.0"; |
1938 init.has_depth = true; | 2038 init.has_depth = true; |
1939 init.has_stencil = true; | 2039 init.has_stencil = true; |
1940 init.request_depth = true; | 2040 init.request_depth = true; |
1941 init.request_stencil = true; | 2041 init.request_stencil = true; |
1942 init.bind_generates_resource = true; | 2042 init.bind_generates_resource = true; |
1943 InitDecoder(init); | 2043 InitDecoder(init); |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 // TODO(gman): CompressedTexSubImage2DImmediate | 2822 // TODO(gman): CompressedTexSubImage2DImmediate |
2723 | 2823 |
2724 // TODO(gman): TexImage2D | 2824 // TODO(gman): TexImage2D |
2725 | 2825 |
2726 // TODO(gman): TexImage2DImmediate | 2826 // TODO(gman): TexImage2DImmediate |
2727 | 2827 |
2728 // TODO(gman): TexSubImage2DImmediate | 2828 // TODO(gman): TexSubImage2DImmediate |
2729 | 2829 |
2730 } // namespace gles2 | 2830 } // namespace gles2 |
2731 } // namespace gpu | 2831 } // namespace gpu |
OLD | NEW |