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

Unified Diff: ui/gfx/gl/gl_surface_android.cc

Issue 10392068: ui: Move gl/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac_rel Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gl/gl_surface_android.h ('k') | ui/gfx/gl/gl_surface_cgl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gl/gl_surface_android.cc
diff --git a/ui/gfx/gl/gl_surface_android.cc b/ui/gfx/gl/gl_surface_android.cc
deleted file mode 100644
index 7f66fd867effe144583ad610bc0c7788b9844309..0000000000000000000000000000000000000000
--- a/ui/gfx/gl/gl_surface_android.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/gl/gl_surface_android.h"
-
-#include <EGL/egl.h>
-
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "ui/gfx/gl/egl_util.h"
-#include "ui/gfx/gl/gl_bindings.h"
-#include "ui/gfx/gl/gl_context.h"
-#include "ui/gfx/gl/gl_implementation.h"
-#include "ui/gfx/gl/android_native_window.h"
-
-namespace gfx {
-
-bool GLSurface::InitializeOneOffInternal() {
- static bool initialized = false;
- if (initialized)
- return true;
-
- switch (GetGLImplementation()) {
- case kGLImplementationEGLGLES2:
- if (!GLSurfaceEGL::InitializeOneOff()) {
- LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
- return false;
- }
- break;
- default:
- NOTREACHED();
- break;
- }
-
- initialized = true;
- return true;
-}
-// static
-scoped_refptr<GLSurface>
-GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) {
- if (software)
- return NULL;
-
- switch (GetGLImplementation()) {
- case kGLImplementationEGLGLES2: {
- // window is unused
- scoped_refptr<AndroidViewSurface> surface(new AndroidViewSurface());
- if (!surface->Initialize())
- return NULL;
- return surface;
- }
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-// static
-scoped_refptr<GLSurface>
-GLSurface::CreateOffscreenGLSurface(bool software, const gfx::Size& size) {
- if (software)
- return NULL;
-
- switch (GetGLImplementation()) {
- case kGLImplementationEGLGLES2: {
- scoped_refptr<PbufferGLSurfaceEGL> surface(
- new PbufferGLSurfaceEGL(false, size));
- if (!surface->Initialize())
- return NULL;
- return surface;
- }
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-AndroidViewSurface::AndroidViewSurface()
- : NativeViewGLSurfaceEGL(false, 0),
- pbuffer_surface_(new PbufferGLSurfaceEGL(false, Size(1, 1))),
- window_(NULL) {
-}
-
-AndroidViewSurface::~AndroidViewSurface() {
-}
-
-bool AndroidViewSurface::Initialize() {
- DCHECK(pbuffer_surface_.get());
- return pbuffer_surface_->Initialize();
-}
-
-void AndroidViewSurface::Destroy() {
- if (pbuffer_surface_.get()) {
- pbuffer_surface_->Destroy();
- } else {
- window_ = NULL;
- }
- NativeViewGLSurfaceEGL::Destroy();
-}
-
-bool AndroidViewSurface::IsOffscreen() {
- return false;
-}
-
-bool AndroidViewSurface::SwapBuffers() {
- if (!pbuffer_surface_.get())
- return NativeViewGLSurfaceEGL::SwapBuffers();
- return true;
-}
-
-gfx::Size AndroidViewSurface::GetSize() {
- if (pbuffer_surface_.get())
- return pbuffer_surface_->GetSize();
- else
- return NativeViewGLSurfaceEGL::GetSize();
-}
-
-EGLSurface AndroidViewSurface::GetHandle() {
- if (pbuffer_surface_.get())
- return pbuffer_surface_->GetHandle();
- else
- return NativeViewGLSurfaceEGL::GetHandle();
-}
-
-bool AndroidViewSurface::Resize(const gfx::Size& size) {
- if (pbuffer_surface_.get())
- return pbuffer_surface_->Resize(size);
- else if (GetHandle()) {
- DCHECK(window_ && window_->GetNativeHandle());
- // Deactivate and restore any currently active context.
- EGLContext context = eglGetCurrentContext();
- if (context != EGL_NO_CONTEXT) {
- eglMakeCurrent(GetDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE,
- EGL_NO_CONTEXT);
- }
- NativeViewGLSurfaceEGL::Destroy();
- if (CreateWindowSurface(window_)) {
- if (context != EGL_NO_CONTEXT)
- eglMakeCurrent(GetDisplay(), GetHandle(), GetHandle(), context);
- }
- }
- return true;
-}
-
-bool AndroidViewSurface::CreateWindowSurface(AndroidNativeWindow* window) {
- DCHECK(window->GetNativeHandle());
- window_ = window;
- EGLSurface surface = eglCreateWindowSurface(GetDisplay(),
- GetConfig(),
- window->GetNativeHandle(),
- NULL);
- if (surface == EGL_NO_SURFACE) {
- LOG(ERROR) << "eglCreateWindowSurface failed with error "
- << GetLastEGLErrorString();
- Destroy();
- return false;
- }
-
- SetHandle(surface);
- return true;
-}
-
-void AndroidViewSurface::SetNativeWindow(AndroidNativeWindow* window) {
- if (window->GetNativeHandle()) {
- DCHECK(pbuffer_surface_.get());
- pbuffer_surface_->Destroy();
- pbuffer_surface_ = NULL;
-
- CreateWindowSurface(window);
- } else {
- DCHECK(GetHandle());
- NativeViewGLSurfaceEGL::Destroy();
- window_ = NULL;
-
- pbuffer_surface_ = new PbufferGLSurfaceEGL(false, Size(1,1));
- pbuffer_surface_->Initialize();
- }
-}
-
-} // namespace gfx
« no previous file with comments | « ui/gfx/gl/gl_surface_android.h ('k') | ui/gfx/gl/gl_surface_cgl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698