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

Side by Side Diff: gpu/ipc/service/direct_composition_surface_win.h

Issue 2743663006: Allow switching DirectCompositionSurfaceWin between drawing modes. (Closed)
Patch Set: fix release current in resize Created 3 years, 9 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 #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 27 matching lines...) Expand all
38 float scale_factor, 38 float scale_factor,
39 bool has_alpha) override; 39 bool has_alpha) override;
40 gfx::SwapResult SwapBuffers() override; 40 gfx::SwapResult SwapBuffers() override;
41 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; 41 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
42 gfx::VSyncProvider* GetVSyncProvider() override; 42 gfx::VSyncProvider* GetVSyncProvider() override;
43 bool ScheduleOverlayPlane(int z_order, 43 bool ScheduleOverlayPlane(int z_order,
44 gfx::OverlayTransform transform, 44 gfx::OverlayTransform transform,
45 gl::GLImage* image, 45 gl::GLImage* image,
46 const gfx::Rect& bounds_rect, 46 const gfx::Rect& bounds_rect,
47 const gfx::RectF& crop_rect) override; 47 const gfx::RectF& crop_rect) override;
48 bool SetEnableDCLayers(bool enable) override;
48 bool FlipsVertically() const override; 49 bool FlipsVertically() const override;
49 bool SupportsPostSubBuffer() override; 50 bool SupportsPostSubBuffer() override;
50 bool OnMakeCurrent(gl::GLContext* context) override; 51 bool OnMakeCurrent(gl::GLContext* context) override;
51 bool SupportsSetDrawRectangle() const override; 52 bool SupportsDCLayers() const override;
52 bool SetDrawRectangle(const gfx::Rect& rect) override; 53 bool SetDrawRectangle(const gfx::Rect& rect) override;
53 gfx::Vector2d GetDrawOffset() const override; 54 gfx::Vector2d GetDrawOffset() const override;
54 55
55 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider); 56 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider);
56 57
57 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting(); 58 scoped_refptr<base::TaskRunner> GetWindowTaskRunnerForTesting();
58 59
59 protected: 60 protected:
60 ~DirectCompositionSurfaceWin() override; 61 ~DirectCompositionSurfaceWin() override;
61 62
62 private: 63 private:
63 struct Overlay { 64 struct Overlay {
64 Overlay(int z_order, 65 Overlay(int z_order,
65 gfx::OverlayTransform transform, 66 gfx::OverlayTransform transform,
66 scoped_refptr<gl::GLImage> image, 67 scoped_refptr<gl::GLImage> image,
67 gfx::Rect bounds_rect, 68 gfx::Rect bounds_rect,
68 gfx::RectF crop_rect); 69 gfx::RectF crop_rect);
69 Overlay(const Overlay& overlay); 70 Overlay(const Overlay& overlay);
70 71
71 ~Overlay(); 72 ~Overlay();
72 73
73 int z_order; 74 int z_order;
74 gfx::OverlayTransform transform; 75 gfx::OverlayTransform transform;
75 scoped_refptr<gl::GLImage> image; 76 scoped_refptr<gl::GLImage> image;
76 gfx::Rect bounds_rect; 77 gfx::Rect bounds_rect;
77 gfx::RectF crop_rect; 78 gfx::RectF crop_rect;
78 }; 79 };
79 80
80 bool CommitAndClearPendingOverlays(); 81 bool CommitAndClearPendingOverlays();
82 void ReleaseCurrentSurface();
81 void InitializeSurface(); 83 void InitializeSurface();
82 void ReleaseDrawTexture(); 84 void ReleaseDrawTexture();
83 85
84 ChildWindowWin child_window_; 86 ChildWindowWin child_window_;
85 87
86 HWND window_ = nullptr; 88 HWND window_ = nullptr;
87 // This is a placeholder surface used when not rendering to the 89 // This is a placeholder surface used when not rendering to the
88 // DirectComposition surface. 90 // DirectComposition surface.
89 EGLSurface default_surface_ = 0; 91 EGLSurface default_surface_ = 0;
90 92
91 // This is the real surface representing the backbuffer. It may be null 93 // This is the real surface representing the backbuffer. It may be null
92 // outside of a BeginDraw/EndDraw pair. 94 // outside of a BeginDraw/EndDraw pair.
93 EGLSurface real_surface_ = 0; 95 EGLSurface real_surface_ = 0;
94 gfx::Size size_ = gfx::Size(1, 1); 96 gfx::Size size_ = gfx::Size(1, 1);
95 bool first_swap_ = true; 97 bool first_swap_ = true;
98 bool enable_dc_layers_ = false;
96 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; 99 std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
97 std::vector<Overlay> pending_overlays_; 100 std::vector<Overlay> pending_overlays_;
101 gfx::Rect swap_rect_;
98 102
99 gfx::Vector2d draw_offset_; 103 gfx::Vector2d draw_offset_;
100 104
101 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; 105 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
102 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_; 106 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_;
103 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_; 107 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_;
104 base::win::ScopedComPtr<IDCompositionVisual2> visual_; 108 base::win::ScopedComPtr<IDCompositionVisual2> visual_;
105 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_; 109 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_;
110 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain_;
106 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_; 111 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_;
107 112
108 // Keep track of whether the texture has been rendered to, as the first draw 113 // Keep track of whether the texture has been rendered to, as the first draw
109 // to it must overwrite the entire thing. 114 // to it must overwrite the entire thing.
110 bool has_been_rendered_to_ = false; 115 bool has_been_rendered_to_ = false;
111 116
112 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); 117 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin);
113 }; 118 };
114 119
115 } // namespace gpu 120 } // namespace gpu
116 121
117 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 122 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698