| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 EXPECT_TRUE(d3d_renderer->d3d_device() != NULL); | 111 EXPECT_TRUE(d3d_renderer->d3d_device() != NULL); |
| 112 | 112 |
| 113 renderer->Destroy(); | 113 renderer->Destroy(); |
| 114 | 114 |
| 115 EXPECT_FALSE(d3d_renderer->d3d_device() != NULL); | 115 EXPECT_FALSE(d3d_renderer->d3d_device() != NULL); |
| 116 } | 116 } |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 // TODO: add InitAndDestroyGL and InitAndDestroyMock | 119 // TODO: add InitAndDestroyGL and InitAndDestroyMock |
| 120 TEST_F(RendererTest, Creates2DTextureFromBitmap) { | 120 TEST_F(RendererTest, Creates2DTextureFromBitmap) { |
| 121 Bitmap bitmap; | 121 Bitmap::Ref bitmap(new Bitmap(g_service_locator)); |
| 122 bitmap.Allocate(Texture::ARGB8, 16, 32, 2, false); | 122 bitmap->Allocate(Texture::ARGB8, 16, 32, 2, false); |
| 123 memset(bitmap.image_data(), 0x34, bitmap.GetTotalSize()); | 123 memset(bitmap->image_data(), 0x34, bitmap->GetTotalSize()); |
| 124 | 124 |
| 125 Client client(g_service_locator); | 125 Client client(g_service_locator); |
| 126 client.Init(); | 126 client.Init(); |
| 127 | 127 |
| 128 Texture::Ref texture = g_renderer->CreateTextureFromBitmap(&bitmap); | 128 Texture::Ref texture = g_renderer->CreateTextureFromBitmap(bitmap); |
| 129 ASSERT_TRUE(NULL != texture); | 129 ASSERT_TRUE(NULL != texture); |
| 130 EXPECT_EQ(Texture::ARGB8, texture->format()); | 130 EXPECT_EQ(Texture::ARGB8, texture->format()); |
| 131 EXPECT_EQ(2, texture->levels()); | 131 EXPECT_EQ(2, texture->levels()); |
| 132 | 132 |
| 133 Texture2D::Ref texture2D(down_cast<Texture2D*>(texture.Get())); | 133 Texture2D::Ref texture2D(down_cast<Texture2D*>(texture.Get())); |
| 134 ASSERT_TRUE(NULL != texture2D); | 134 ASSERT_TRUE(NULL != texture2D); |
| 135 EXPECT_EQ(16, texture2D->width()); | 135 EXPECT_EQ(16, texture2D->width()); |
| 136 EXPECT_EQ(32, texture2D->height()); | 136 EXPECT_EQ(32, texture2D->height()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST_F(RendererTest, CreatesCubeTextureFromBitmap) { | 139 TEST_F(RendererTest, CreatesCubeTextureFromBitmap) { |
| 140 Bitmap bitmap; | 140 Bitmap::Ref bitmap(new Bitmap(g_service_locator)); |
| 141 bitmap.Allocate(Texture::ARGB8, 16, 16, 2, true); | 141 bitmap->Allocate(Texture::ARGB8, 16, 16, 2, true); |
| 142 memset(bitmap.image_data(), 0x34, bitmap.GetTotalSize()); | 142 memset(bitmap->image_data(), 0x34, bitmap->GetTotalSize()); |
| 143 | 143 |
| 144 Client client(g_service_locator); | 144 Client client(g_service_locator); |
| 145 client.Init(); | 145 client.Init(); |
| 146 | 146 |
| 147 Texture::Ref texture = g_renderer->CreateTextureFromBitmap(&bitmap); | 147 Texture::Ref texture = g_renderer->CreateTextureFromBitmap(bitmap); |
| 148 ASSERT_TRUE(NULL != texture); | 148 ASSERT_TRUE(NULL != texture); |
| 149 EXPECT_EQ(Texture::ARGB8, texture->format()); | 149 EXPECT_EQ(Texture::ARGB8, texture->format()); |
| 150 EXPECT_EQ(2, texture->levels()); | 150 EXPECT_EQ(2, texture->levels()); |
| 151 | 151 |
| 152 TextureCUBE::Ref textureCube(down_cast<TextureCUBE*>(texture.Get())); | 152 TextureCUBE::Ref textureCube(down_cast<TextureCUBE*>(texture.Get())); |
| 153 ASSERT_TRUE(NULL != textureCube); | 153 ASSERT_TRUE(NULL != textureCube); |
| 154 EXPECT_EQ(16, textureCube->edge_length()); | 154 EXPECT_EQ(16, textureCube->edge_length()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Tests SetViewport | 157 // Tests SetViewport |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 g_renderer->SetViewport(Float4(-0.1f, 0.0f, 1.0f, 1.0f), Float2(0.0f, 1.0f)); | 203 g_renderer->SetViewport(Float4(-0.1f, 0.0f, 1.0f, 1.0f), Float2(0.0f, 1.0f)); |
| 204 EXPECT_FALSE(error_status.GetLastError().empty()); | 204 EXPECT_FALSE(error_status.GetLastError().empty()); |
| 205 | 205 |
| 206 // top off top | 206 // top off top |
| 207 error_status.ClearLastError(); | 207 error_status.ClearLastError(); |
| 208 g_renderer->SetViewport(Float4(0.0f, -0.1f, 1.0f, 1.0f), Float2(0.0f, 1.0f)); | 208 g_renderer->SetViewport(Float4(0.0f, -0.1f, 1.0f, 1.0f), Float2(0.0f, 1.0f)); |
| 209 EXPECT_FALSE(error_status.GetLastError().empty()); | 209 EXPECT_FALSE(error_status.GetLastError().empty()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace o3d | 212 } // namespace o3d |
| OLD | NEW |