| OLD | NEW |
| 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 #ifndef GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ | 5 #ifndef GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ |
| 6 #define GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ | 6 #define GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ |
| 7 | 7 |
| 8 #include <d3d11.h> | 8 #include <d3d11.h> |
| 9 #include <dcomp.h> | 9 #include <dcomp.h> |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 float scale_factor, | 42 float scale_factor, |
| 43 bool has_alpha) override; | 43 bool has_alpha) override; |
| 44 gfx::SwapResult SwapBuffers() override; | 44 gfx::SwapResult SwapBuffers() override; |
| 45 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 45 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 46 gfx::VSyncProvider* GetVSyncProvider() override; | 46 gfx::VSyncProvider* GetVSyncProvider() override; |
| 47 bool ScheduleOverlayPlane(int z_order, | 47 bool ScheduleOverlayPlane(int z_order, |
| 48 gfx::OverlayTransform transform, | 48 gfx::OverlayTransform transform, |
| 49 gl::GLImage* image, | 49 gl::GLImage* image, |
| 50 const gfx::Rect& bounds_rect, | 50 const gfx::Rect& bounds_rect, |
| 51 const gfx::RectF& crop_rect) override; | 51 const gfx::RectF& crop_rect) override; |
| 52 bool SetEnableDCLayers(bool enable) override; |
| 52 bool FlipsVertically() const override; | 53 bool FlipsVertically() const override; |
| 53 bool SupportsPostSubBuffer() override; | 54 bool SupportsPostSubBuffer() override; |
| 54 bool OnMakeCurrent(gl::GLContext* context) override; | 55 bool OnMakeCurrent(gl::GLContext* context) override; |
| 55 bool SupportsSetDrawRectangle() const override; | 56 bool SupportsDCLayers() const override; |
| 56 bool SetDrawRectangle(const gfx::Rect& rect) override; | 57 bool SetDrawRectangle(const gfx::Rect& rect) override; |
| 57 gfx::Vector2d GetDrawOffset() const override; | 58 gfx::Vector2d GetDrawOffset() const override; |
| 58 | 59 |
| 59 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider); | 60 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider); |
| 60 | 61 |
| 61 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting(); | 62 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting(); |
| 63 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain() const { |
| 64 return swap_chain_; |
| 65 } |
| 62 | 66 |
| 63 protected: | 67 protected: |
| 64 ~DirectCompositionSurfaceWin() override; | 68 ~DirectCompositionSurfaceWin() override; |
| 65 | 69 |
| 66 private: | 70 private: |
| 67 struct Overlay { | 71 struct Overlay { |
| 68 Overlay(int z_order, | 72 Overlay(int z_order, |
| 69 gfx::OverlayTransform transform, | 73 gfx::OverlayTransform transform, |
| 70 scoped_refptr<gl::GLImage> image, | 74 scoped_refptr<gl::GLImage> image, |
| 71 gfx::Rect bounds_rect, | 75 gfx::Rect bounds_rect, |
| 72 gfx::RectF crop_rect); | 76 gfx::RectF crop_rect); |
| 73 Overlay(const Overlay& overlay); | 77 Overlay(const Overlay& overlay); |
| 74 | 78 |
| 75 ~Overlay(); | 79 ~Overlay(); |
| 76 | 80 |
| 77 int z_order; | 81 int z_order; |
| 78 gfx::OverlayTransform transform; | 82 gfx::OverlayTransform transform; |
| 79 scoped_refptr<gl::GLImage> image; | 83 scoped_refptr<gl::GLImage> image; |
| 80 gfx::Rect bounds_rect; | 84 gfx::Rect bounds_rect; |
| 81 gfx::RectF crop_rect; | 85 gfx::RectF crop_rect; |
| 82 }; | 86 }; |
| 83 | 87 |
| 84 bool CommitAndClearPendingOverlays(); | 88 bool CommitAndClearPendingOverlays(); |
| 89 void ReleaseCurrentSurface(); |
| 85 void InitializeSurface(); | 90 void InitializeSurface(); |
| 86 void ReleaseDrawTexture(); | 91 // Release the texture that's currently being drawn to. If will_discard is |
| 92 // true then the surface should be discarded without swapping any contents |
| 93 // to it. |
| 94 void ReleaseDrawTexture(bool will_discard); |
| 87 | 95 |
| 88 ChildWindowWin child_window_; | 96 ChildWindowWin child_window_; |
| 89 | 97 |
| 90 HWND window_ = nullptr; | 98 HWND window_ = nullptr; |
| 91 // This is a placeholder surface used when not rendering to the | 99 // This is a placeholder surface used when not rendering to the |
| 92 // DirectComposition surface. | 100 // DirectComposition surface. |
| 93 EGLSurface default_surface_ = 0; | 101 EGLSurface default_surface_ = 0; |
| 94 | 102 |
| 95 // This is the real surface representing the backbuffer. It may be null | 103 // This is the real surface representing the backbuffer. It may be null |
| 96 // outside of a BeginDraw/EndDraw pair. | 104 // outside of a BeginDraw/EndDraw pair. |
| 97 EGLSurface real_surface_ = 0; | 105 EGLSurface real_surface_ = 0; |
| 98 gfx::Size size_ = gfx::Size(1, 1); | 106 gfx::Size size_ = gfx::Size(1, 1); |
| 99 bool first_swap_ = true; | 107 bool first_swap_ = true; |
| 108 bool enable_dc_layers_ = false; |
| 100 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; | 109 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; |
| 101 std::vector<Overlay> pending_overlays_; | 110 std::vector<Overlay> pending_overlays_; |
| 111 gfx::Rect swap_rect_; |
| 102 | 112 |
| 103 gfx::Vector2d draw_offset_; | 113 gfx::Vector2d draw_offset_; |
| 104 | 114 |
| 105 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; | 115 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; |
| 106 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_; | 116 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_; |
| 107 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_; | 117 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_; |
| 108 base::win::ScopedComPtr<IDCompositionVisual2> visual_; | 118 base::win::ScopedComPtr<IDCompositionVisual2> visual_; |
| 109 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_; | 119 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_; |
| 120 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain_; |
| 110 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_; | 121 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_; |
| 111 | 122 |
| 112 // Keep track of whether the texture has been rendered to, as the first draw | 123 // Keep track of whether the texture has been rendered to, as the first draw |
| 113 // to it must overwrite the entire thing. | 124 // to it must overwrite the entire thing. |
| 114 bool has_been_rendered_to_ = false; | 125 bool has_been_rendered_to_ = false; |
| 115 | 126 |
| 116 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); | 127 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); |
| 117 }; | 128 }; |
| 118 | 129 |
| 119 } // namespace gpu | 130 } // namespace gpu |
| 120 | 131 |
| 121 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ | 132 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ |
| OLD | NEW |