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

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

Issue 2646243002: Use IDCompositionSurface to implement DirectCompositionSurfaceWin. (Closed)
Patch Set: more changes Created 3 years, 11 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>
sunnyps 2017/01/28 01:33:59 nit: group this with <windows.h> or vice-versa.
9 #include <dcomp.h>
10
8 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/win/scoped_comptr.h"
13 #include "gpu/gpu_export.h"
9 #include "gpu/ipc/service/child_window_win.h" 14 #include "gpu/ipc/service/child_window_win.h"
10 #include "gpu/ipc/service/image_transport_surface_delegate.h" 15 #include "gpu/ipc/service/image_transport_surface_delegate.h"
11 #include "ui/gl/gl_image.h" 16 #include "ui/gl/gl_image.h"
12 #include "ui/gl/gl_surface_egl.h" 17 #include "ui/gl/gl_surface_egl.h"
13 18
14 #include <windows.h> 19 #include <windows.h>
15 20
16 namespace gpu { 21 namespace gpu {
17 22
18 class DirectCompositionSurfaceWin : public gl::GLSurfaceEGL { 23 class GPU_EXPORT DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
19 public: 24 public:
20 DirectCompositionSurfaceWin( 25 DirectCompositionSurfaceWin(
21 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, 26 base::WeakPtr<ImageTransportSurfaceDelegate> delegate,
22 HWND parent_window); 27 HWND parent_window);
23 28
24 bool InitializeNativeWindow(); 29 bool InitializeNativeWindow();
25 30
26 // GLSurfaceEGL implementation. 31 // GLSurfaceEGL implementation.
27 using GLSurfaceEGL::Initialize; 32 using GLSurfaceEGL::Initialize;
28 bool Initialize(gl::GLSurfaceFormat format) override; 33 bool Initialize(gl::GLSurfaceFormat format) override;
29 void Destroy() override; 34 void Destroy() override;
30 gfx::Size GetSize() override; 35 gfx::Size GetSize() override;
31 bool IsOffscreen() override; 36 bool IsOffscreen() override;
32 void* GetHandle() override; 37 void* GetHandle() override;
33 bool Resize(const gfx::Size& size, 38 bool Resize(const gfx::Size& size,
34 float scale_factor, 39 float scale_factor,
35 bool has_alpha) override; 40 bool has_alpha) override;
36 gfx::SwapResult SwapBuffers() override; 41 gfx::SwapResult SwapBuffers() override;
37 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; 42 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
38 gfx::VSyncProvider* GetVSyncProvider() override; 43 gfx::VSyncProvider* GetVSyncProvider() override;
39 bool ScheduleOverlayPlane(int z_order, 44 bool ScheduleOverlayPlane(int z_order,
40 gfx::OverlayTransform transform, 45 gfx::OverlayTransform transform,
41 gl::GLImage* image, 46 gl::GLImage* image,
42 const gfx::Rect& bounds_rect, 47 const gfx::Rect& bounds_rect,
43 const gfx::RectF& crop_rect) override; 48 const gfx::RectF& crop_rect) override;
49 bool FlipsVertically() const override;
44 bool SupportsPostSubBuffer() override; 50 bool SupportsPostSubBuffer() override;
51 bool OnMakeCurrent(gl::GLContext* context) override;
52 bool SupportsSetDrawRectangle() const override;
53 bool SetDrawRectangle(const gfx::Rect& rect) override;
45 54
46 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider); 55 bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider);
47 56
48 protected: 57 protected:
49 ~DirectCompositionSurfaceWin() override; 58 ~DirectCompositionSurfaceWin() override;
50 59
51 private: 60 private:
52 struct Overlay { 61 struct Overlay {
53 Overlay(int z_order, 62 Overlay(int z_order,
54 gfx::OverlayTransform transform, 63 gfx::OverlayTransform transform,
55 scoped_refptr<gl::GLImage> image, 64 scoped_refptr<gl::GLImage> image,
56 gfx::Rect bounds_rect, 65 gfx::Rect bounds_rect,
57 gfx::RectF crop_rect); 66 gfx::RectF crop_rect);
58 Overlay(const Overlay& overlay); 67 Overlay(const Overlay& overlay);
59 68
60 ~Overlay(); 69 ~Overlay();
61 70
62 int z_order; 71 int z_order;
63 gfx::OverlayTransform transform; 72 gfx::OverlayTransform transform;
64 scoped_refptr<gl::GLImage> image; 73 scoped_refptr<gl::GLImage> image;
65 gfx::Rect bounds_rect; 74 gfx::Rect bounds_rect;
66 gfx::RectF crop_rect; 75 gfx::RectF crop_rect;
67 }; 76 };
68 77
69 bool CommitAndClearPendingOverlays(); 78 bool CommitAndClearPendingOverlays();
79 void InitializeSurface();
80 void ReleaseDrawTexture();
70 81
71 ChildWindowWin child_window_; 82 ChildWindowWin child_window_;
72 83
73 HWND window_; 84 HWND window_;
74 EGLSurface surface_; 85 // This is a placeholder surface used when not rendering to the
86 // DirectComposition surface.
87 EGLSurface default_surface_;
sunnyps 2017/01/28 01:33:59 nit: default_surface_ = 0
88
89 // This is the real surface representing the backbuffer. It may be null
90 // outside of a BeginDraw/EndDraw pair.
91 EGLSurface real_surface_;
sunnyps 2017/01/28 01:33:59 nit: real_surface_ = 0
75 gfx::Size size_; 92 gfx::Size size_;
76 bool first_swap_; 93 bool first_swap_;
sunnyps 2017/01/28 01:33:59 nit: first_swap_ = false
77 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; 94 std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
78 std::vector<Overlay> pending_overlays_; 95 std::vector<Overlay> pending_overlays_;
79 96
97 base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
98 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_;
99 base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_;
100 base::win::ScopedComPtr<IDCompositionVisual2> visual_;
101 base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_;
102 base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_;
103
104 // Keep track of whether the texture has been rendered to, as the first draw
105 // to it must overwrite the entire thing.
106 bool has_been_rendered_to_ = false;
107
80 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin); 108 DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin);
81 }; 109 };
82 110
83 } // namespace gpu 111 } // namespace gpu
84 112
85 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_ 113 #endif // GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698