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

Side by Side Diff: app/gfx/gl/gl_context_win.cc

Issue 4815001: Use inner HWND for accelerated rendering on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file implements the NativeViewGLContext and PbufferGLContext classes. 5 // This file implements the NativeViewGLContext and PbufferGLContext classes.
6 6
7 #include "app/gfx/gl/gl_context.h" 7 #include "app/gfx/gl/gl_context.h"
8 8
9 #include <GL/osmesa.h> 9 #include <GL/osmesa.h>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 // Initializes the GL context. 45 // Initializes the GL context.
46 bool Initialize(bool multisampled); 46 bool Initialize(bool multisampled);
47 47
48 virtual void Destroy(); 48 virtual void Destroy();
49 virtual bool MakeCurrent(); 49 virtual bool MakeCurrent();
50 virtual bool IsCurrent(); 50 virtual bool IsCurrent();
51 virtual bool IsOffscreen(); 51 virtual bool IsOffscreen();
52 virtual bool SwapBuffers(); 52 virtual bool SwapBuffers();
53 virtual void SetSize(gfx::Size);
53 virtual gfx::Size GetSize(); 54 virtual gfx::Size GetSize();
54 virtual void* GetHandle(); 55 virtual void* GetHandle();
55 virtual void SetSwapInterval(int interval); 56 virtual void SetSwapInterval(int interval);
56 57
57 virtual HDC GetDC(); 58 virtual HDC GetDC();
58 59
59 private: 60 private:
60 gfx::PluginWindowHandle window_; 61 gfx::PluginWindowHandle window_;
61 HDC device_context_; 62 HDC device_context_;
62 GLContextHandle context_; 63 GLContextHandle context_;
(...skipping 12 matching lines...) Expand all
75 } 76 }
76 77
77 // Initializes the GL context. 78 // Initializes the GL context.
78 bool Initialize(); 79 bool Initialize();
79 80
80 virtual void Destroy(); 81 virtual void Destroy();
81 virtual bool MakeCurrent(); 82 virtual bool MakeCurrent();
82 virtual bool IsCurrent(); 83 virtual bool IsCurrent();
83 virtual bool IsOffscreen(); 84 virtual bool IsOffscreen();
84 virtual bool SwapBuffers(); 85 virtual bool SwapBuffers();
86 virtual void SetSize(gfx::Size);
85 virtual gfx::Size GetSize(); 87 virtual gfx::Size GetSize();
86 virtual void* GetHandle(); 88 virtual void* GetHandle();
87 virtual void SetSwapInterval(int interval); 89 virtual void SetSwapInterval(int interval);
88 90
89 private: 91 private:
90 void UpdateSize(); 92 void UpdateSize();
91 93
92 gfx::PluginWindowHandle window_; 94 gfx::PluginWindowHandle window_;
93 HDC device_context_; 95 HDC device_context_;
94 OSMesaGLContext osmesa_context_; 96 OSMesaGLContext osmesa_context_;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 406
405 bool NativeViewGLContext::IsOffscreen() { 407 bool NativeViewGLContext::IsOffscreen() {
406 return false; 408 return false;
407 } 409 }
408 410
409 bool NativeViewGLContext::SwapBuffers() { 411 bool NativeViewGLContext::SwapBuffers() {
410 DCHECK(device_context_); 412 DCHECK(device_context_);
411 return ::SwapBuffers(device_context_) == TRUE; 413 return ::SwapBuffers(device_context_) == TRUE;
412 } 414 }
413 415
416 void NativeViewGLContext::SetSize(gfx::Size size) {
417 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS |
418 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE;
419 SetWindowPos(window_, NULL, 0, 0, size.width(), size.height(), swp_flags);
420 }
421
414 gfx::Size NativeViewGLContext::GetSize() { 422 gfx::Size NativeViewGLContext::GetSize() {
415 RECT rect; 423 RECT rect;
416 CHECK(GetClientRect(window_, &rect)); 424 CHECK(GetClientRect(window_, &rect));
417 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); 425 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top);
418 } 426 }
419 427
420 void* NativeViewGLContext::GetHandle() { 428 void* NativeViewGLContext::GetHandle() {
421 return context_; 429 return context_;
422 } 430 }
423 431
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 void* OSMesaViewGLContext::GetHandle() { 528 void* OSMesaViewGLContext::GetHandle() {
521 return osmesa_context_.GetHandle(); 529 return osmesa_context_.GetHandle();
522 } 530 }
523 531
524 void OSMesaViewGLContext::SetSwapInterval(int interval) { 532 void OSMesaViewGLContext::SetSwapInterval(int interval) {
525 DCHECK(IsCurrent()); 533 DCHECK(IsCurrent());
526 // Fail silently. It is legitimate to set the swap interval on a view context 534 // Fail silently. It is legitimate to set the swap interval on a view context
527 // but GDI does not have those semantics. 535 // but GDI does not have those semantics.
528 } 536 }
529 537
538 void OSMesaViewGLContext::SetSize(gfx::Size size) {
539 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS |
540 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE;
541 SetWindowPos(window_, NULL, 0, 0, size.width(), size.height(), swp_flags);
542 UpdateSize();
543 }
544
545
530 void OSMesaViewGLContext::UpdateSize() { 546 void OSMesaViewGLContext::UpdateSize() {
531 // Change back buffer size to that of window. If window handle is invalid, do 547 // Change back buffer size to that of window. If window handle is invalid, do
532 // not change the back buffer size. 548 // not change the back buffer size.
533 RECT rect; 549 RECT rect;
534 if (!GetClientRect(window_, &rect)) 550 if (!GetClientRect(window_, &rect))
535 return; 551 return;
536 552
537 gfx::Size window_size = gfx::Size( 553 gfx::Size window_size = gfx::Size(
538 std::max(1, static_cast<int>(rect.right - rect.left)), 554 std::max(1, static_cast<int>(rect.right - rect.left)),
539 std::max(1, static_cast<int>(rect.bottom - rect.top))); 555 std::max(1, static_cast<int>(rect.bottom - rect.top)));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 745 }
730 case kGLImplementationMockGL: 746 case kGLImplementationMockGL:
731 return new StubGLContext; 747 return new StubGLContext;
732 default: 748 default:
733 NOTREACHED(); 749 NOTREACHED();
734 return NULL; 750 return NULL;
735 } 751 }
736 } 752 }
737 753
738 } // namespace gfx 754 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698