Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: gpu/ipc/service/direct_composition_surface_win_unittest.cc

Issue 2849743002: Allow binding multiple textures to one DC Layer overlay. (Closed)
Patch Set: put texture id array in ScheduleDCLayer Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | ui/gl/dc_renderer_layer_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/ipc/service/direct_composition_surface_win.h" 5 #include "gpu/ipc/service/direct_composition_surface_win.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/win/scoped_gdi_object.h" 10 #include "base/win/scoped_gdi_object.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 gl::QueryD3D11DeviceObjectFromANGLE(); 302 gl::QueryD3D11DeviceObjectFromANGLE();
303 303
304 gfx::Size texture_size(50, 50); 304 gfx::Size texture_size(50, 50);
305 base::win::ScopedComPtr<ID3D11Texture2D> texture = 305 base::win::ScopedComPtr<ID3D11Texture2D> texture =
306 CreateNV12Texture(d3d11_device, texture_size); 306 CreateNV12Texture(d3d11_device, texture_size);
307 307
308 scoped_refptr<gl::GLImageDXGI> image_dxgi( 308 scoped_refptr<gl::GLImageDXGI> image_dxgi(
309 new gl::GLImageDXGI(texture_size, nullptr)); 309 new gl::GLImageDXGI(texture_size, nullptr));
310 image_dxgi->SetTexture(texture, 0); 310 image_dxgi->SetTexture(texture, 0);
311 311
312 ui::DCRendererLayerParams params(false, gfx::Rect(), 1, gfx::Transform(), 312 ui::DCRendererLayerParams params(
313 image_dxgi.get(), 313 false, gfx::Rect(), 1, gfx::Transform(),
314 gfx::RectF(gfx::Rect(texture_size)), 314 std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
315 gfx::Rect(window_size), 0, 0, 1.0, 0); 315 gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0,
316 0);
316 surface->ScheduleDCLayer(params); 317 surface->ScheduleDCLayer(params);
317 318
318 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain = 319 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain =
319 surface->GetLayerSwapChainForTesting(1); 320 surface->GetLayerSwapChainForTesting(1);
320 ASSERT_FALSE(swap_chain); 321 ASSERT_FALSE(swap_chain);
321 322
322 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); 323 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers());
323 324
324 swap_chain = surface->GetLayerSwapChainForTesting(1); 325 swap_chain = surface->GetLayerSwapChainForTesting(1);
325 ASSERT_TRUE(swap_chain); 326 ASSERT_TRUE(swap_chain);
(...skipping 10 matching lines...) Expand all
336 337
337 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain2 = 338 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain2 =
338 surface->GetLayerSwapChainForTesting(1); 339 surface->GetLayerSwapChainForTesting(1);
339 EXPECT_EQ(swap_chain2, swap_chain); 340 EXPECT_EQ(swap_chain2, swap_chain);
340 341
341 // It's the same image, so it should have the same swapchain. 342 // It's the same image, so it should have the same swapchain.
342 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count))); 343 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count)));
343 EXPECT_EQ(2u, last_present_count); 344 EXPECT_EQ(2u, last_present_count);
344 345
345 // The size of the swapchain changed, so it should be recreated. 346 // The size of the swapchain changed, so it should be recreated.
346 ui::DCRendererLayerParams params2(false, gfx::Rect(), 1, gfx::Transform(), 347 ui::DCRendererLayerParams params2(
347 image_dxgi.get(), 348 false, gfx::Rect(), 1, gfx::Transform(),
348 gfx::RectF(gfx::Rect(texture_size)), 349 std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
349 gfx::Rect(0, 0, 25, 25), 0, 0, 1.0, 0); 350 gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(0, 0, 25, 25), 0, 0, 1.0,
351 0);
350 surface->ScheduleDCLayer(params2); 352 surface->ScheduleDCLayer(params2);
351 353
352 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); 354 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers());
353 355
354 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain3 = 356 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain3 =
355 surface->GetLayerSwapChainForTesting(1); 357 surface->GetLayerSwapChainForTesting(1);
356 EXPECT_NE(swap_chain2, swap_chain3); 358 EXPECT_NE(swap_chain2, swap_chain3);
357 359
358 context = nullptr; 360 context = nullptr;
359 DestroySurface(std::move(surface)); 361 DestroySurface(std::move(surface));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 gl::QueryD3D11DeviceObjectFromANGLE(); 478 gl::QueryD3D11DeviceObjectFromANGLE();
477 479
478 gfx::Size texture_size(50, 50); 480 gfx::Size texture_size(50, 50);
479 base::win::ScopedComPtr<ID3D11Texture2D> texture = 481 base::win::ScopedComPtr<ID3D11Texture2D> texture =
480 CreateNV12Texture(d3d11_device, texture_size); 482 CreateNV12Texture(d3d11_device, texture_size);
481 483
482 scoped_refptr<gl::GLImageDXGI> image_dxgi( 484 scoped_refptr<gl::GLImageDXGI> image_dxgi(
483 new gl::GLImageDXGI(texture_size, nullptr)); 485 new gl::GLImageDXGI(texture_size, nullptr));
484 image_dxgi->SetTexture(texture, 0); 486 image_dxgi->SetTexture(texture, 0);
485 487
486 ui::DCRendererLayerParams params(false, gfx::Rect(), 1, gfx::Transform(), 488 ui::DCRendererLayerParams params(
487 image_dxgi.get(), 489 false, gfx::Rect(), 1, gfx::Transform(),
488 gfx::RectF(gfx::Rect(texture_size)), 490 std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
489 gfx::Rect(window_size), 0, 0, 1.0, 0); 491 gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0,
492 0);
490 surface_->ScheduleDCLayer(params); 493 surface_->ScheduleDCLayer(params);
491 494
492 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers()); 495 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers());
493 Sleep(1000); 496 Sleep(1000);
494 497
495 SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff); 498 SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff);
496 SkColor actual_color = 499 SkColor actual_color =
497 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75)); 500 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75));
498 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) 501 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color))
499 << std::hex << "Expected " << expected_color << " Actual " 502 << std::hex << "Expected " << expected_color << " Actual "
500 << actual_color; 503 << actual_color;
501 504
502 context = nullptr; 505 context = nullptr;
503 DestroySurface(std::move(surface_)); 506 DestroySurface(std::move(surface_));
504 } 507 }
505 508
506 } // namespace 509 } // namespace
507 } // namespace gpu 510 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | ui/gl/dc_renderer_layer_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698