Windows: cefclient: Create a new D3D11 device for each browser (issue #2538)

This fixes a texture resizing issue when creating multiple windows with OSR
and shared textures enabled.
This commit is contained in:
Marshall Greenblatt 2018-11-15 15:42:50 -05:00
parent 3e06fa8271
commit 91a1286d52
4 changed files with 2 additions and 27 deletions

View File

@ -14,12 +14,6 @@
namespace client {
#if defined(OS_WIN)
namespace d3d11 {
class Device;
}
#endif
class RootWindowManager;
// Used to store global context in the browser process. The methods of this
@ -58,10 +52,6 @@ class MainContext {
// Returns the object used to create/manage RootWindow instances.
virtual RootWindowManager* GetRootWindowManager() = 0;
#if defined(OS_WIN)
virtual std::shared_ptr<d3d11::Device> GetD3D11Device() = 0;
#endif
protected:
MainContext();
virtual ~MainContext();

View File

@ -34,10 +34,6 @@ class MainContextImpl : public MainContext {
void PopulateOsrSettings(OsrRendererSettings* settings) OVERRIDE;
RootWindowManager* GetRootWindowManager() OVERRIDE;
#if defined(OS_WIN)
std::shared_ptr<d3d11::Device> GetD3D11Device() OVERRIDE;
#endif
// Initialize CEF and associated main context state. This method must be
// called on the same thread that created this object.
bool Initialize(const CefMainArgs& args,
@ -79,7 +75,6 @@ class MainContextImpl : public MainContext {
#if defined(OS_WIN)
bool shared_texture_enabled_;
std::shared_ptr<d3d11::Device> d3d11_device_;
#endif
bool external_begin_frame_enabled_;

View File

@ -7,8 +7,6 @@
#include <direct.h>
#include <shlobj.h>
#include "tests/cefclient/browser/osr_d3d11_win.h"
namespace client {
std::string MainContextImpl::GetDownloadPath(const std::string& file_name) {
@ -38,11 +36,4 @@ std::string MainContextImpl::GetAppWorkingDirectory() {
return szWorkingDir;
}
std::shared_ptr<d3d11::Device> MainContextImpl::GetD3D11Device() {
CEF_REQUIRE_UI_THREAD();
if (!d3d11_device_)
d3d11_device_ = d3d11::Device::create();
return d3d11_device_;
}
} // namespace client

View File

@ -7,7 +7,6 @@
#include "include/base/cef_bind.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h"
#include "tests/cefclient/browser/main_context.h"
#include "tests/shared/browser/util_win.h"
namespace client {
@ -80,8 +79,8 @@ bool OsrRenderHandlerWinD3D11::Initialize(CefRefPtr<CefBrowser> browser,
int height) {
CEF_REQUIRE_UI_THREAD();
// Retrieve the shared D3D11 device instance.
device_ = MainContext::Get()->GetD3D11Device();
// Create a D3D11 device instance.
device_ = d3d11::Device::create();
DCHECK(device_);
if (!device_)
return false;