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

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

Issue 2743663006: Allow switching DirectCompositionSurfaceWin between drawing modes. (Closed)
Patch Set: post-review changes 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();
59 const base::win::ScopedComPtr<IDXGISwapChain1> swap_chain() const {
sunnyps 2017/03/21 00:19:00 nit: operator-> on ScopedComPtr is const so the fi
60 return swap_chain_;
61 }
58 62
59 protected: 63 protected:
60 ~DirectCompositionSurfaceWin() override; 64 ~DirectCompositionSurfaceWin() override;
61 65
62 private: 66 private:
63 struct Overlay { 67 struct Overlay {
64 Overlay(int z_order, 68 Overlay(int z_order,
65 gfx::OverlayTransform transform, 69 gfx::OverlayTransform transform,
66 scoped_refptr<gl::GLImage> image, 70 scoped_refptr<gl::GLImage> image,
67 gfx::Rect bounds_rect, 71 gfx::Rect bounds_rect,
68 gfx::RectF crop_rect); 72 gfx::RectF crop_rect);
69 Overlay(const Overlay& overlay); 73 Overlay(const Overlay& overlay);
70 74
71 ~Overlay(); 75 ~Overlay();
72 76
73 int z_order; 77 int z_order;
74 gfx::OverlayTransform transform; 78 gfx::OverlayTransform transform;
75 scoped_refptr<gl::GLImage> image; 79 scoped_refptr<gl::GLImage> image;
76 gfx::Rect bounds_rect; 80 gfx::Rect bounds_rect;
77 gfx::RectF crop_rect; 81 gfx::RectF crop_rect;
78 }; 82 };
79 83
80 bool CommitAndClearPendingOverlays(); 84 bool CommitAndClearPendingOverlays();
85 void ReleaseCurrentSurface();
81 void InitializeSurface(); 86 void InitializeSurface();
82 void ReleaseDrawTexture(); 87 // Release the texture that's currently being drawn to. If will_discard is
88 // true then the surface should be discarded without swapping any contents
89 // to it.
90 void ReleaseDrawTexture(bool will_discard);
83 91
84 ChildWindowWin child_window_; 92 ChildWindowWin child_window_;
85 93
86 HWND window_ = nullptr; 94 HWND window_ = nullptr;
87 // This is a placeholder surface used when not rendering to the 95 // This is a placeholder surface used when not rendering to the
88 // DirectComposition surface. 96 // DirectComposition surface.
89 EGLSurface default_surface_ = 0; 97 EGLSurface default_surface_ = 0;
90 98
91 // This is the real surface representing the backbuffer. It may be null 99 // This is the real surface representing the backbuffer. It may be null
92 // outside of a BeginDraw/EndDraw pair. 100 // outside of a BeginDraw/EndDraw pair.
93 EGLSurface real_surface_ = 0; 101 EGLSurface real_surface_ = 0;
94 gfx::Size size_ = gfx::Size(1, 1); 102 gfx::Size size_ = gfx::Size(1, 1);
95 bool first_swap_ = true; 103 bool first_swap_ = true;
104 bool enable_dc_layers_ = false;
96 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; 105 std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
97 std::vector<Overlay> pending_overlays_; 106 std::vector<Overlay> pending_overlays_;
107 gfx::Rect swap_rect_;
98 108
99 gfx::Vector2d draw_offset_; 109 gfx::Vector2d draw_offset_;
100 110
101 base::win::ScopedComPtr<ID3D11Device> d3d11_device_; 111 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
102 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_; 112 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_;
103 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_; 113 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_;
104 base::win::ScopedComPtr<IDCompositionVisual2> visual_; 114 base::win::ScopedComPtr<IDCompositionVisual2> visual_;
105 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_; 115 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_;
116 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain_;
106 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_; 117 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_;
107 118
108 // Keep track of whether the texture has been rendered to, as the first draw 119 // Keep track of whether the texture has been rendered to, as the first draw
109 // to it must overwrite the entire thing. 120 // to it must overwrite the entire thing.
110 bool has_been_rendered_to_ = false; 121 bool has_been_rendered_to_ = false;
111 122
112 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); 123 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin);
113 }; 124 };
114 125
115 } // namespace gpu 126 } // namespace gpu
116 127
117 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 128 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
OLDNEW
« no previous file with comments | « gpu/ipc/common/gpu_command_buffer_traits_multi.h ('k') | gpu/ipc/service/direct_composition_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698