summaryrefslogtreecommitdiffstats
path: root/ui/surface
diff options
context:
space:
mode:
Diffstat (limited to 'ui/surface')
-rw-r--r--ui/surface/accelerated_surface_win.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc
index 4ed0ffd4..969bf8a 100644
--- a/ui/surface/accelerated_surface_win.cc
+++ b/ui/surface/accelerated_surface_win.cc
@@ -189,6 +189,7 @@ class PresentThread : public base::Thread,
void ResetDevice();
protected:
+ virtual void Init();
virtual void CleanUp();
private:
@@ -353,6 +354,11 @@ void PresentThread::ResetDevice() {
device_->SetVertexDeclaration(vertex_declaration);
}
+void PresentThread::Init() {
+ TRACE_EVENT0("gpu", "Initialize thread");
+ InitDevice();
+}
+
void PresentThread::CleanUp() {
// The D3D device and query are leaked because destroying the associated D3D
// query crashes some Intel drivers.
@@ -365,18 +371,19 @@ PresentThread::~PresentThread() {
}
PresentThreadPool::PresentThreadPool() : next_thread_(0) {
- // Do this in the constructor so present_threads_ is initialized before any
- // other thread sees it. See LazyInstance documentation.
- for (int i = 0; i < kNumPresentThreads; ++i) {
- present_threads_[i] = new PresentThread(
- base::StringPrintf("PresentThread #%d", i).c_str());
- present_threads_[i]->Start();
- }
}
PresentThread* PresentThreadPool::NextThread() {
next_thread_ = (next_thread_ + 1) % kNumPresentThreads;
- return present_threads_[next_thread_].get();
+ PresentThread* thread = present_threads_[next_thread_].get();
+ if (!thread) {
+ thread = new PresentThread(
+ base::StringPrintf("PresentThread #%d", next_thread_).c_str());
+ thread->Start();
+ present_threads_[next_thread_] = thread;
+ }
+
+ return thread;
}
AcceleratedPresenterMap::AcceleratedPresenterMap() {
@@ -1018,7 +1025,7 @@ gfx::Size AcceleratedPresenter::GetWindowSize() {
bool AcceleratedPresenter::CheckDirect3DWillWork() {
gfx::Size window_size = GetWindowSize();
- if (window_size != last_window_size_) {
+ if (window_size != last_window_size_ && last_window_size_.GetArea() != 0) {
last_window_size_ = window_size;
last_window_resize_time_ = base::Time::Now();
return false;