OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
9 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 9 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
10 #include "content/common/gpu/client/context_provider_command_buffer.h" | 10 #include "content/common/gpu/client/context_provider_command_buffer.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Step 2: verify that holding onto the provider's GrContext will | 230 // Step 2: verify that holding onto the provider's GrContext will |
231 // retain the host after provider is destroyed. | 231 // retain the host after provider is destroyed. |
232 scoped_refptr<ContextProviderCommandBuffer> provider = | 232 scoped_refptr<ContextProviderCommandBuffer> provider = |
233 ContextProviderCommandBuffer::Create(CreateContext(GetGpuChannel()), | 233 ContextProviderCommandBuffer::Create(CreateContext(GetGpuChannel()), |
234 OFFSCREEN_CONTEXT_FOR_TESTING); | 234 OFFSCREEN_CONTEXT_FOR_TESTING); |
235 EXPECT_TRUE(provider->BindToCurrentThread()); | 235 EXPECT_TRUE(provider->BindToCurrentThread()); |
236 | 236 |
237 skia::RefPtr<GrContext> gr_context = skia::SharePtr(provider->GrContext()); | 237 skia::RefPtr<GrContext> gr_context = skia::SharePtr(provider->GrContext()); |
238 | 238 |
239 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 239 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
240 skia::RefPtr<SkSurface> surface = skia::AdoptRef(SkSurface::NewRenderTarget( | 240 sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget( |
241 gr_context.get(), SkBudgeted::kNo, info)); | 241 gr_context.get(), SkBudgeted::kNo, info); |
242 EXPECT_TRUE(surface); | 242 EXPECT_TRUE(surface); |
243 | 243 |
244 // Destroy the GL context after we made a surface. | 244 // Destroy the GL context after we made a surface. |
245 provider = nullptr; | 245 provider = nullptr; |
246 | 246 |
247 // New surfaces will fail to create now. | 247 // New surfaces will fail to create now. |
248 skia::RefPtr<SkSurface> surface2 = skia::AdoptRef( | 248 sk_sp<SkSurface> surface2 = |
249 SkSurface::NewRenderTarget(gr_context.get(), SkBudgeted::kNo, info)); | 249 SkSurface::MakeRenderTarget(gr_context.get(), SkBudgeted::kNo, info); |
250 EXPECT_FALSE(surface2); | 250 EXPECT_FALSE(surface2); |
251 | 251 |
252 // Drop our reference to the gr_context also. | 252 // Drop our reference to the gr_context also. |
253 gr_context = nullptr; | 253 gr_context = nullptr; |
254 | 254 |
255 // After the context provider is destroyed, the surface no longer has access | 255 // After the context provider is destroyed, the surface no longer has access |
256 // to the GrContext, even though it's alive. Use the canvas after the provider | 256 // to the GrContext, even though it's alive. Use the canvas after the provider |
257 // and GrContext have been locally unref'ed. This should work fine as the | 257 // and GrContext have been locally unref'ed. This should work fine as the |
258 // GrContext has been abandoned when the GL context provider was destroyed | 258 // GrContext has been abandoned when the GL context provider was destroyed |
259 // above. | 259 // above. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 shim->SimulateCrash(); | 292 shim->SimulateCrash(); |
293 run_loop.Run(); | 293 run_loop.Run(); |
294 | 294 |
295 EXPECT_EQ(1, counter); | 295 EXPECT_EQ(1, counter); |
296 EXPECT_FALSE(IsChannelEstablished()); | 296 EXPECT_FALSE(IsChannelEstablished()); |
297 EstablishAndWait(); | 297 EstablishAndWait(); |
298 EXPECT_TRUE(IsChannelEstablished()); | 298 EXPECT_TRUE(IsChannelEstablished()); |
299 } | 299 } |
300 | 300 |
301 } // namespace content | 301 } // namespace content |
OLD | NEW |