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

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

Issue 2766423003: Allow creating opaque swapchains in DirectCompositionSurfaceWin (Closed)
Patch Set: rebase 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
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 acbc271b0dd81360928050c87c9ecec203fc9e08..73ea79818b11eab217f3ccf18df336c8e9c52130 100644
--- a/gpu/ipc/service/direct_composition_surface_win.cc
+++ b/gpu/ipc/service/direct_composition_surface_win.cc
@@ -722,12 +722,16 @@ void DirectCompositionSurfaceWin::InitializeSurface() {
? DXGI_FORMAT_R16G16B16A16_FLOAT
: DXGI_FORMAT_B8G8R8A8_UNORM;
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(), output_format,
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;
@@ -745,7 +749,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());
@@ -830,7 +834,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_))
return true;
// Force a resize and redraw (but not a move, activate, etc.).
@@ -840,6 +844,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') | gpu/ipc/service/direct_composition_surface_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698