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

Unified Diff: gpu/ipc/service/direct_composition_surface_win.h

Issue 2646243002: Use IDCompositionSurface to implement DirectCompositionSurfaceWin. (Closed)
Patch Set: better Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: gpu/ipc/service/direct_composition_surface_win.h
diff --git a/gpu/ipc/service/direct_composition_surface_win.h b/gpu/ipc/service/direct_composition_surface_win.h
index 01fdbb18b650e42f9c10ece9ed20b3abc72594d5..929ed5993da32aab0450d570d60e341606a83f47 100644
--- a/gpu/ipc/service/direct_composition_surface_win.h
+++ b/gpu/ipc/service/direct_composition_surface_win.h
@@ -5,17 +5,21 @@
#ifndef GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
#define GPU_IPC_SERVICE_DIRECT_COMPOSITION_SURFACE_WIN_H_
+#include <d3d11.h>
+#include <dcomp.h>
+#include <windows.h>
+
#include "base/memory/weak_ptr.h"
+#include "base/win/scoped_comptr.h"
+#include "gpu/gpu_export.h"
#include "gpu/ipc/service/child_window_win.h"
#include "gpu/ipc/service/image_transport_surface_delegate.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_surface_egl.h"
-#include <windows.h>
-
namespace gpu {
-class DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
+class GPU_EXPORT DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
public:
DirectCompositionSurfaceWin(
base::WeakPtr<ImageTransportSurfaceDelegate> delegate,
@@ -41,7 +45,11 @@ class DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
gl::GLImage* image,
const gfx::Rect& bounds_rect,
const gfx::RectF& crop_rect) override;
+ bool FlipsVertically() const override;
bool SupportsPostSubBuffer() override;
+ bool OnMakeCurrent(gl::GLContext* context) override;
+ bool SupportsSetDrawRectangle() const override;
+ bool SetDrawRectangle(const gfx::Rect& rect) override;
bool Initialize(std::unique_ptr<gfx::VSyncProvider> vsync_provider);
@@ -67,16 +75,35 @@ class DirectCompositionSurfaceWin : public gl::GLSurfaceEGL {
};
bool CommitAndClearPendingOverlays();
+ void InitializeSurface();
+ void ReleaseDrawTexture();
ChildWindowWin child_window_;
- HWND window_;
- EGLSurface surface_;
+ HWND window_ = nullptr;
+ // This is a placeholder surface used when not rendering to the
+ // DirectComposition surface.
+ EGLSurface default_surface_ = 0;
+
+ // This is the real surface representing the backbuffer. It may be null
+ // outside of a BeginDraw/EndDraw pair.
+ EGLSurface real_surface_ = 0;
gfx::Size size_;
sunnyps 2017/02/14 22:09:13 nit: size_ = gfx::Size(1, 1)
- bool first_swap_;
+ bool first_swap_ = true;
std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
std::vector<Overlay> pending_overlays_;
+ base::win::ScopedComPtr<ID3D11Device> d3d11_device_;
+ base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device_;
+ base::win::ScopedComPtr<IDCompositionTarget> dcomp_target_;
+ base::win::ScopedComPtr<IDCompositionVisual2> visual_;
+ base::win::ScopedComPtr<IDCompositionSurface> dcomp_surface_;
+ base::win::ScopedComPtr<ID3D11Texture2D> draw_texture_;
+
+ // Keep track of whether the texture has been rendered to, as the first draw
+ // to it must overwrite the entire thing.
+ bool has_been_rendered_to_ = false;
+
DISALLOW_COPY_AND_ASSIGN(DirectCompositionSurfaceWin);
};

Powered by Google App Engine
This is Rietveld 408576698