child_window_win.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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
  3. // found in the LICENSE file.
  4. #ifndef UI_GL_CHILD_WINDOW_WIN_H_
  5. #define UI_GL_CHILD_WINDOW_WIN_H_
  6. #include "base/memory/weak_ptr.h"
  7. #include "base/task/task_runner.h"
  8. #include "base/threading/thread.h"
  9. #include "ui/gl/gl_export.h"
  10. #include <windows.h>
  11. namespace gl {
  12. // The window DirectComposition renders into needs to be owned by the process
  13. // that's currently doing the rendering. The class creates and owns a window
  14. // which is reparented by the browser to be a child of its window.
  15. class GL_EXPORT ChildWindowWin {
  16. public:
  17. explicit ChildWindowWin(HWND parent_window);
  18. ChildWindowWin(const ChildWindowWin&) = delete;
  19. ChildWindowWin& operator=(const ChildWindowWin&) = delete;
  20. ~ChildWindowWin();
  21. void Initialize();
  22. HWND window() const { return window_; }
  23. scoped_refptr<base::TaskRunner> GetTaskRunnerForTesting();
  24. private:
  25. // The window owner thread.
  26. std::unique_ptr<base::Thread> thread_;
  27. // The eventual parent of the window living in the browser process.
  28. const HWND parent_window_;
  29. HWND window_ = nullptr;
  30. // The window is initially created with this parent window. We need to keep it
  31. // around so that we can destroy it at the end.
  32. HWND initial_parent_window_ = nullptr;
  33. };
  34. } // namespace gl
  35. #endif // UI_GL_CHILD_WINDOW_WIN_H_