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

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 15928002: GPU: Keep track of the last real context and real surface made current. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nix unnecessary changes. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_gl_api_implementation.cc ('k') | ui/gl/gl_surface_osmesa.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #if defined(OS_ANDROID) 7 #if defined(OS_ANDROID)
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #endif 9 #endif
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/gl/egl_util.h" 15 #include "ui/gl/egl_util.h"
16 #include "ui/gl/gl_context.h" 16 #include "ui/gl/gl_context.h"
17 #include "ui/gl/gl_implementation.h" 17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_surface_stub.h" 18 #include "ui/gl/gl_surface_stub.h"
19 #include "ui/gl/scoped_make_current.h"
19 20
20 #if defined(USE_X11) 21 #if defined(USE_X11)
21 extern "C" { 22 extern "C" {
22 #include <X11/Xlib.h> 23 #include <X11/Xlib.h>
23 } 24 }
24 #endif 25 #endif
25 26
26 #if defined (USE_OZONE) 27 #if defined (USE_OZONE)
27 #include "ui/base/ozone/surface_factory_ozone.h" 28 #include "ui/base/ozone/surface_factory_ozone.h"
28 #endif 29 #endif
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return gfx::Size(); 404 return gfx::Size();
404 } 405 }
405 406
406 return gfx::Size(width, height); 407 return gfx::Size(width, height);
407 } 408 }
408 409
409 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { 410 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) {
410 if (size == GetSize()) 411 if (size == GetSize())
411 return true; 412 return true;
412 413
414 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
413 GLContext* current_context = GLContext::GetCurrent(); 415 GLContext* current_context = GLContext::GetCurrent();
414 bool was_current = current_context && current_context->IsCurrent(this); 416 bool was_current =
415 if (was_current) 417 current_context && current_context->IsCurrent(this);
418 if (was_current) {
419 scoped_make_current.reset(
420 new ui::ScopedMakeCurrent(current_context, this));
416 current_context->ReleaseCurrent(this); 421 current_context->ReleaseCurrent(this);
422 }
417 423
418 Destroy(); 424 Destroy();
419 425
420 if (!Initialize()) { 426 if (!Initialize()) {
421 LOG(ERROR) << "Failed to resize pbuffer."; 427 LOG(ERROR) << "Failed to resize window.";
422 return false; 428 return false;
423 } 429 }
424 430
425 if (was_current)
426 return current_context->MakeCurrent(this);
427 return true; 431 return true;
428 } 432 }
429 433
430 bool NativeViewGLSurfaceEGL::Recreate() { 434 bool NativeViewGLSurfaceEGL::Recreate() {
431 Destroy(); 435 Destroy();
432 if (!Initialize()) { 436 if (!Initialize()) {
433 LOG(ERROR) << "Failed to create surface."; 437 LOG(ERROR) << "Failed to create surface.";
434 return false; 438 return false;
435 } 439 }
436 return true; 440 return true;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 551 }
548 552
549 gfx::Size PbufferGLSurfaceEGL::GetSize() { 553 gfx::Size PbufferGLSurfaceEGL::GetSize() {
550 return size_; 554 return size_;
551 } 555 }
552 556
553 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { 557 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) {
554 if (size == size_) 558 if (size == size_)
555 return true; 559 return true;
556 560
561 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
557 GLContext* current_context = GLContext::GetCurrent(); 562 GLContext* current_context = GLContext::GetCurrent();
558 bool was_current = current_context && current_context->IsCurrent(this); 563 bool was_current =
564 current_context && current_context->IsCurrent(this);
565 if (was_current) {
566 scoped_make_current.reset(
567 new ui::ScopedMakeCurrent(current_context, this));
568 }
559 569
560 size_ = size; 570 size_ = size;
561 571
562 if (!Initialize()) { 572 if (!Initialize()) {
563 LOG(ERROR) << "Failed to resize pbuffer."; 573 LOG(ERROR) << "Failed to resize pbuffer.";
564 return false; 574 return false;
565 } 575 }
566 576
567 if (was_current)
568 return current_context->MakeCurrent(this);
569
570 return true; 577 return true;
571 } 578 }
572 579
573 EGLSurface PbufferGLSurfaceEGL::GetHandle() { 580 EGLSurface PbufferGLSurfaceEGL::GetHandle() {
574 return surface_; 581 return surface_;
575 } 582 }
576 583
577 void* PbufferGLSurfaceEGL::GetShareHandle() { 584 void* PbufferGLSurfaceEGL::GetShareHandle() {
578 #if defined(OS_ANDROID) 585 #if defined(OS_ANDROID)
579 NOTREACHED(); 586 NOTREACHED();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 664 }
658 default: 665 default:
659 NOTREACHED(); 666 NOTREACHED();
660 return NULL; 667 return NULL;
661 } 668 }
662 } 669 }
663 670
664 #endif 671 #endif
665 672
666 } // namespace gfx 673 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_gl_api_implementation.cc ('k') | ui/gl/gl_surface_osmesa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698