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

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

Issue 2766423003: Allow creating opaque swapchains in DirectCompositionSurfaceWin (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/ipc/service/direct_composition_surface_win.cc
diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc
index 7f65213481bc0c2f4b7a61aa60731668c3259097..3fa5c3aa58d8eeae9b7895c28512bc7238972980 100644
--- a/gpu/ipc/service/direct_composition_surface_win.cc
+++ b/gpu/ipc/service/direct_composition_surface_win.cc
@@ -168,12 +168,16 @@ void DirectCompositionSurfaceWin::InitializeSurface() {
DCHECK(!dcomp_surface_);
DCHECK(!swap_chain_);
if (enable_dc_layers_) {
+ // Always treat as premultiplied, because an underlay could cause it to
+ // become transparent.
HRESULT hr = dcomp_device_->CreateSurface(
size_.width(), size_.height(), DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_ALPHA_MODE_PREMULTIPLIED, dcomp_surface_.Receive());
has_been_rendered_to_ = false;
CHECK(SUCCEEDED(hr));
} else {
+ DXGI_ALPHA_MODE alpha_mode =
+ has_alpha_ ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE;
base::win::ScopedComPtr<IDXGIDevice> dxgi_device;
d3d11_device_.QueryInterface(dxgi_device.Receive());
base::win::ScopedComPtr<IDXGIAdapter> dxgi_adapter;
@@ -191,7 +195,7 @@ void DirectCompositionSurfaceWin::InitializeSurface() {
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.Scaling = DXGI_SCALING_STRETCH;
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
- desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED;
+ desc.AlphaMode = alpha_mode;
desc.Flags = 0;
HRESULT hr = dxgi_factory->CreateSwapChainForComposition(
d3d11_device_.get(), &desc, nullptr, swap_chain_.Receive());
@@ -276,7 +280,7 @@ void* DirectCompositionSurfaceWin::GetHandle() {
bool DirectCompositionSurfaceWin::Resize(const gfx::Size& size,
float scale_factor,
bool has_alpha) {
- if (size == GetSize())
+ if (size == GetSize() || has_alpha != has_alpha_)
sunnyps 2017/03/28 22:33:37 Shouldn't this be " && has_alpha == has_alpha_"?
return true;
// Force a resize and redraw (but not a move, activate, etc.).
@@ -286,6 +290,7 @@ bool DirectCompositionSurfaceWin::Resize(const gfx::Size& size,
return false;
}
size_ = size;
+ has_alpha_ = has_alpha;
ScopedReleaseCurrent release_current(this);
// New surface will be initialized in SetDrawRectangle.
ReleaseCurrentSurface();
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698