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

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

Issue 2849963003: Allow putting NV12 software GMBs into overlays on windows (Closed)
Patch Set: post-review changes 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
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/ref_counted_memory.h"
6 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
7 #include "base/run_loop.h" 8 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/win/scoped_gdi_object.h" 11 #include "base/win/scoped_gdi_object.h"
11 #include "base/win/scoped_hdc.h" 12 #include "base/win/scoped_hdc.h"
12 #include "base/win/scoped_select_object.h" 13 #include "base/win/scoped_select_object.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/base/win/hidden_window.h" 15 #include "ui/base/win/hidden_window.h"
16 #include "ui/gfx/buffer_format_util.h"
15 #include "ui/gfx/gdi_util.h" 17 #include "ui/gfx/gdi_util.h"
16 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
17 #include "ui/gl/dc_renderer_layer_params.h" 19 #include "ui/gl/dc_renderer_layer_params.h"
18 #include "ui/gl/gl_angle_util_win.h" 20 #include "ui/gl/gl_angle_util_win.h"
19 #include "ui/gl/gl_context.h" 21 #include "ui/gl/gl_context.h"
20 #include "ui/gl/gl_image_dxgi.h" 22 #include "ui/gl/gl_image_dxgi.h"
23 #include "ui/gl/gl_image_ref_counted_memory.h"
21 #include "ui/gl/init/gl_factory.h" 24 #include "ui/gl/init/gl_factory.h"
22 #include "ui/platform_window/platform_window_delegate.h" 25 #include "ui/platform_window/platform_window_delegate.h"
23 #include "ui/platform_window/win/win_window.h" 26 #include "ui/platform_window/win/win_window.h"
24 27
25 namespace gpu { 28 namespace gpu {
26 namespace { 29 namespace {
27 30
28 bool CheckIfDCSupported() { 31 bool CheckIfDCSupported() {
29 if (!gl::QueryDirectCompositionDevice( 32 if (!gl::QueryDirectCompositionDevice(
30 gl::QueryD3D11DeviceObjectFromANGLE())) { 33 gl::QueryD3D11DeviceObjectFromANGLE())) {
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 SkColor actual_color = 502 SkColor actual_color =
500 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75)); 503 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75));
501 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) 504 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color))
502 << std::hex << "Expected " << expected_color << " Actual " 505 << std::hex << "Expected " << expected_color << " Actual "
503 << actual_color; 506 << actual_color;
504 507
505 context = nullptr; 508 context = nullptr;
506 DestroySurface(std::move(surface_)); 509 DestroySurface(std::move(surface_));
507 } 510 }
508 511
512 TEST_F(DirectCompositionPixelTest, SoftwareVideoSwapchain) {
513 if (!CheckIfDCSupported())
514 return;
515 InitializeSurface();
516 surface_->SetEnableDCLayers(true);
517 gfx::Size window_size(100, 100);
518
519 scoped_refptr<gl::GLContext> context = gl::init::CreateGLContext(
520 nullptr, surface_.get(), gl::GLContextAttribs());
521 EXPECT_TRUE(surface_->Resize(window_size, 1.0, true));
522
523 base::win::ScopedComPtr<ID3D11Device> d3d11_device =
524 gl::QueryD3D11DeviceObjectFromANGLE();
525
526 gfx::Size y_size(50, 50);
527 gfx::Size uv_size(25, 25);
528 size_t y_stride =
529 gfx::RowSizeForBufferFormat(y_size.width(), gfx::BufferFormat::R_8, 0);
530 size_t uv_stride =
531 gfx::RowSizeForBufferFormat(uv_size.width(), gfx::BufferFormat::RG_88, 0);
532 std::vector<uint8_t> y_data(y_stride * y_size.height(), 0xff);
533 std::vector<uint8_t> uv_data(uv_stride * uv_size.height(), 0xff);
534 scoped_refptr<gl::GLImageRefCountedMemory> y_image(
535 new gl::GLImageRefCountedMemory(y_size, GL_BGRA_EXT));
536
537 y_image->Initialize(new base::RefCountedBytes(y_data),
538 gfx::BufferFormat::R_8);
539 scoped_refptr<gl::GLImageRefCountedMemory> uv_image(
540 new gl::GLImageRefCountedMemory(uv_size, GL_BGRA_EXT));
541 uv_image->Initialize(new base::RefCountedBytes(uv_data),
542 gfx::BufferFormat::RG_88);
543
544 ui::DCRendererLayerParams params(
545 false, gfx::Rect(), 1, gfx::Transform(),
546 std::vector<scoped_refptr<gl::GLImage>>{y_image, uv_image},
547 gfx::RectF(gfx::Rect(y_size)), gfx::Rect(window_size), 0, 0, 1.0, 0);
548 surface_->ScheduleDCLayer(params);
549
550 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers());
551 Sleep(1000);
552
553 SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff);
554 SkColor actual_color =
555 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75));
556 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color))
557 << std::hex << "Expected " << expected_color << " Actual "
558 << actual_color;
559
560 context = nullptr;
561 DestroySurface(std::move(surface_));
562 }
509 } // namespace 563 } // namespace
510 } // namespace gpu 564 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698