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

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

Issue 10538039: Renamed BrowserWindow::GetNativeHandle() to GetNativeWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyrights Created 8 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/android_native_window.cc ('k') | no next file » | 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_android.h" 5 #include "ui/gl/gl_surface_android.h"
6 6
7 #include <EGL/egl.h> 7 #include <EGL/egl.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (pbuffer_surface_.get()) 120 if (pbuffer_surface_.get())
121 return pbuffer_surface_->GetHandle(); 121 return pbuffer_surface_->GetHandle();
122 else 122 else
123 return NativeViewGLSurfaceEGL::GetHandle(); 123 return NativeViewGLSurfaceEGL::GetHandle();
124 } 124 }
125 125
126 bool AndroidViewSurface::Resize(const gfx::Size& size) { 126 bool AndroidViewSurface::Resize(const gfx::Size& size) {
127 if (pbuffer_surface_.get()) 127 if (pbuffer_surface_.get())
128 return pbuffer_surface_->Resize(size); 128 return pbuffer_surface_->Resize(size);
129 else if (GetHandle()) { 129 else if (GetHandle()) {
130 DCHECK(window_ && window_->GetNativeHandle()); 130 DCHECK(window_ && window_->GetNativeWindow());
131 // Deactivate and restore any currently active context. 131 // Deactivate and restore any currently active context.
132 EGLContext context = eglGetCurrentContext(); 132 EGLContext context = eglGetCurrentContext();
133 if (context != EGL_NO_CONTEXT) { 133 if (context != EGL_NO_CONTEXT) {
134 eglMakeCurrent(GetDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, 134 eglMakeCurrent(GetDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE,
135 EGL_NO_CONTEXT); 135 EGL_NO_CONTEXT);
136 } 136 }
137 NativeViewGLSurfaceEGL::Destroy(); 137 NativeViewGLSurfaceEGL::Destroy();
138 if (CreateWindowSurface(window_)) { 138 if (CreateWindowSurface(window_)) {
139 if (context != EGL_NO_CONTEXT) 139 if (context != EGL_NO_CONTEXT)
140 eglMakeCurrent(GetDisplay(), GetHandle(), GetHandle(), context); 140 eglMakeCurrent(GetDisplay(), GetHandle(), GetHandle(), context);
141 } 141 }
142 } 142 }
143 return true; 143 return true;
144 } 144 }
145 145
146 bool AndroidViewSurface::CreateWindowSurface(AndroidNativeWindow* window) { 146 bool AndroidViewSurface::CreateWindowSurface(AndroidNativeWindow* window) {
147 DCHECK(window->GetNativeHandle()); 147 DCHECK(window->GetNativeWindow());
148 window_ = window; 148 window_ = window;
149 EGLSurface surface = eglCreateWindowSurface(GetDisplay(), 149 EGLSurface surface = eglCreateWindowSurface(GetDisplay(),
150 GetConfig(), 150 GetConfig(),
151 window->GetNativeHandle(), 151 window->GetNativeWindow(),
152 NULL); 152 NULL);
153 if (surface == EGL_NO_SURFACE) { 153 if (surface == EGL_NO_SURFACE) {
154 LOG(ERROR) << "eglCreateWindowSurface failed with error " 154 LOG(ERROR) << "eglCreateWindowSurface failed with error "
155 << GetLastEGLErrorString(); 155 << GetLastEGLErrorString();
156 Destroy(); 156 Destroy();
157 return false; 157 return false;
158 } 158 }
159 159
160 SetHandle(surface); 160 SetHandle(surface);
161 return true; 161 return true;
162 } 162 }
163 163
164 void AndroidViewSurface::SetNativeWindow(AndroidNativeWindow* window) { 164 void AndroidViewSurface::SetNativeWindow(AndroidNativeWindow* window) {
165 if (window->GetNativeHandle()) { 165 if (window->GetNativeWindow()) {
166 DCHECK(pbuffer_surface_.get()); 166 DCHECK(pbuffer_surface_.get());
167 pbuffer_surface_->Destroy(); 167 pbuffer_surface_->Destroy();
168 pbuffer_surface_ = NULL; 168 pbuffer_surface_ = NULL;
169 169
170 CreateWindowSurface(window); 170 CreateWindowSurface(window);
171 } else { 171 } else {
172 DCHECK(GetHandle()); 172 DCHECK(GetHandle());
173 NativeViewGLSurfaceEGL::Destroy(); 173 NativeViewGLSurfaceEGL::Destroy();
174 window_ = NULL; 174 window_ = NULL;
175 175
176 pbuffer_surface_ = new PbufferGLSurfaceEGL(false, Size(1,1)); 176 pbuffer_surface_ = new PbufferGLSurfaceEGL(false, Size(1,1));
177 pbuffer_surface_->Initialize(); 177 pbuffer_surface_->Initialize();
178 } 178 }
179 } 179 }
180 180
181 } // namespace gfx 181 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/android_native_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698