| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "gpu/ipc/common/gpu_messages.h" | 7 #include "gpu/ipc/common/gpu_messages.h" |
| 8 #include "gpu/ipc/service/gpu_channel.h" | 8 #include "gpu/ipc/service/gpu_channel.h" |
| 9 #include "gpu/ipc/service/gpu_channel_test_common.h" | 9 #include "gpu/ipc/service/gpu_channel_test_common.h" |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 init_params.active_url = GURL(); | 134 init_params.active_url = GURL(); |
| 135 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 135 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
| 136 init_params, kRouteId2, GetSharedHandle(), &result, | 136 init_params, kRouteId2, GetSharedHandle(), &result, |
| 137 &capabilities)); | 137 &capabilities)); |
| 138 EXPECT_FALSE(result); | 138 EXPECT_FALSE(result); |
| 139 | 139 |
| 140 stub = channel->LookupCommandBuffer(kRouteId2); | 140 stub = channel->LookupCommandBuffer(kRouteId2); |
| 141 EXPECT_FALSE(stub); | 141 EXPECT_FALSE(stub); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) { | 144 TEST_F(GpuChannelTest, HighPriorityStreamsDisallowed) { |
| 145 int32_t kClientId = 1; | 145 int32_t kClientId = 1; |
| 146 bool is_gpu_host = false; | 146 bool is_gpu_host = false; |
| 147 GpuChannel* channel = CreateChannel(kClientId, is_gpu_host); | 147 GpuChannel* channel = CreateChannel(kClientId, is_gpu_host); |
| 148 ASSERT_TRUE(channel); | 148 ASSERT_TRUE(channel); |
| 149 | 149 |
| 150 // Create first context. | 150 // REAL_TIME priority is disallowed. |
| 151 int32_t kRouteId = 1; | 151 int32_t kRouteId = 1; |
| 152 int32_t kStreamId = 1; | 152 int32_t kStreamId = 1; |
| 153 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; | |
| 154 GPUCreateCommandBufferConfig init_params; | 153 GPUCreateCommandBufferConfig init_params; |
| 155 init_params.surface_handle = kNullSurfaceHandle; | 154 init_params.surface_handle = kNullSurfaceHandle; |
| 156 init_params.share_group_id = MSG_ROUTING_NONE; | 155 init_params.share_group_id = MSG_ROUTING_NONE; |
| 157 init_params.stream_id = kStreamId; | 156 init_params.stream_id = kStreamId; |
| 158 init_params.stream_priority = kStreamPriority; | 157 init_params.stream_priority = GpuStreamPriority::REAL_TIME; |
| 159 init_params.attribs = gles2::ContextCreationAttribHelper(); | 158 init_params.attribs = gles2::ContextCreationAttribHelper(); |
| 160 init_params.active_url = GURL(); | 159 init_params.active_url = GURL(); |
| 161 bool result = false; | 160 bool result = false; |
| 162 gpu::Capabilities capabilities; | 161 gpu::Capabilities capabilities; |
| 163 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 162 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
| 164 init_params, kRouteId, GetSharedHandle(), &result, | 163 init_params, kRouteId, GetSharedHandle(), &result, |
| 165 &capabilities)); | 164 &capabilities)); |
| 166 EXPECT_FALSE(result); | 165 EXPECT_FALSE(result); |
| 166 EXPECT_FALSE(channel->LookupCommandBuffer(kRouteId)); |
| 167 | 167 |
| 168 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 168 // HIGH priority is also disallowed. |
| 169 EXPECT_FALSE(stub); | 169 init_params.stream_priority = GpuStreamPriority::HIGH; |
| 170 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
| 171 init_params, kRouteId, GetSharedHandle(), &result, |
| 172 &capabilities)); |
| 173 EXPECT_FALSE(result); |
| 174 EXPECT_FALSE(channel->LookupCommandBuffer(kRouteId)); |
| 170 } | 175 } |
| 171 | 176 |
| 172 TEST_F(GpuChannelTest, RealTimeStreamsAllowed) { | 177 TEST_F(GpuChannelTest, HighPriorityStreamsAllowed) { |
| 173 int32_t kClientId = 1; | 178 int32_t kClientId = 1; |
| 174 bool is_gpu_host = true; | 179 bool is_gpu_host = true; |
| 175 GpuChannel* channel = CreateChannel(kClientId, is_gpu_host); | 180 GpuChannel* channel = CreateChannel(kClientId, is_gpu_host); |
| 176 ASSERT_TRUE(channel); | 181 ASSERT_TRUE(channel); |
| 177 | 182 |
| 178 // Create first context. | 183 // REAL_TIME priority is allowed. |
| 179 int32_t kRouteId = 1; | 184 int32_t kRouteId1 = 1; |
| 180 int32_t kStreamId = 1; | |
| 181 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; | |
| 182 GPUCreateCommandBufferConfig init_params; | 185 GPUCreateCommandBufferConfig init_params; |
| 183 init_params.surface_handle = kNullSurfaceHandle; | 186 init_params.surface_handle = kNullSurfaceHandle; |
| 184 init_params.share_group_id = MSG_ROUTING_NONE; | 187 init_params.share_group_id = MSG_ROUTING_NONE; |
| 185 init_params.stream_id = kStreamId; | 188 init_params.stream_id = 1; |
| 186 init_params.stream_priority = kStreamPriority; | 189 init_params.stream_priority = GpuStreamPriority::REAL_TIME; |
| 187 init_params.attribs = gles2::ContextCreationAttribHelper(); | 190 init_params.attribs = gles2::ContextCreationAttribHelper(); |
| 188 init_params.active_url = GURL(); | 191 init_params.active_url = GURL(); |
| 189 bool result = false; | 192 bool result = false; |
| 190 gpu::Capabilities capabilities; | 193 gpu::Capabilities capabilities; |
| 191 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 194 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
| 192 init_params, kRouteId, GetSharedHandle(), &result, | 195 init_params, kRouteId1, GetSharedHandle(), &result, |
| 193 &capabilities)); | 196 &capabilities)); |
| 194 EXPECT_TRUE(result); | 197 EXPECT_TRUE(result); |
| 198 EXPECT_TRUE(channel->LookupCommandBuffer(kRouteId1)); |
| 195 | 199 |
| 196 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 200 // HIGH priority is allowed. |
| 197 EXPECT_TRUE(stub); | 201 int32_t kRouteId2 = 2; |
| 202 init_params.stream_id = 2; |
| 203 init_params.stream_priority = GpuStreamPriority::HIGH; |
| 204 result = false; |
| 205 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
| 206 init_params, kRouteId2, GetSharedHandle(), &result, |
| 207 &capabilities)); |
| 208 EXPECT_TRUE(result); |
| 209 EXPECT_TRUE(channel->LookupCommandBuffer(kRouteId2)); |
| 198 } | 210 } |
| 199 | 211 |
| 200 TEST_F(GpuChannelTest, CreateFailsIfSharedContextIsLost) { | 212 TEST_F(GpuChannelTest, CreateFailsIfSharedContextIsLost) { |
| 201 int32_t kClientId = 1; | 213 int32_t kClientId = 1; |
| 202 GpuChannel* channel = CreateChannel(kClientId, false); | 214 GpuChannel* channel = CreateChannel(kClientId, false); |
| 203 ASSERT_TRUE(channel); | 215 ASSERT_TRUE(channel); |
| 204 | 216 |
| 205 // Create first context, we will share this one. | 217 // Create first context, we will share this one. |
| 206 int32_t kSharedRouteId = 1; | 218 int32_t kSharedRouteId = 1; |
| 207 { | 219 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); | 283 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); |
| 272 | 284 |
| 273 // Destroy the command buffers we initialized before destoying GL. | 285 // Destroy the command buffers we initialized before destoying GL. |
| 274 HandleMessage(channel, | 286 HandleMessage(channel, |
| 275 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId)); | 287 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId)); |
| 276 HandleMessage(channel, | 288 HandleMessage(channel, |
| 277 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId)); | 289 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId)); |
| 278 } | 290 } |
| 279 | 291 |
| 280 } // namespace gpu | 292 } // namespace gpu |
| OLD | NEW |