Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 tracker->SetSurfaceHandle( | 156 tracker->SetSurfaceHandle( |
| 157 surface_id_, | 157 surface_id_, |
| 158 gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::NATIVE_DIRECT)); | 158 gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::NATIVE_DIRECT)); |
| 159 SetVisible(true); | 159 SetVisible(true); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 void CompositorImpl::SetSurface(jobject surface) { | 163 void CompositorImpl::SetSurface(jobject surface) { |
| 164 JNIEnv* env = base::android::AttachCurrentThread(); | 164 JNIEnv* env = base::android::AttachCurrentThread(); |
| 165 base::android::ScopedJavaLocalRef<jobject> j_surface(env, surface); | 165 base::android::ScopedJavaLocalRef<jobject> j_surface(env, surface); |
| 166 if (surface) { | 166 ANativeWindow* window = NULL; |
| 167 ANativeWindow* window = ANativeWindow_fromSurface(env, surface); | 167 if (surface) |
| 168 window = ANativeWindow_fromSurface(env, surface); | |
| 169 if (window) { | |
| 168 SetWindowSurface(window); | 170 SetWindowSurface(window); |
| 169 ANativeWindow_release(window); | 171 ANativeWindow_release(window); |
| 170 { | 172 { |
| 171 base::AutoLock lock(g_surface_map_lock.Get()); | 173 base::AutoLock lock(g_surface_map_lock.Get()); |
| 172 g_surface_map.Get().insert(std::make_pair(surface_id_, j_surface)); | 174 g_surface_map.Get().insert(std::make_pair(surface_id_, j_surface)); |
| 173 } | 175 } |
| 174 } else { | 176 } else { |
| 175 { | 177 { |
|
no sievers
2013/04/18 01:08:50
but don't fall into 'else' here if surface is not
| |
| 176 base::AutoLock lock(g_surface_map_lock.Get()); | 178 base::AutoLock lock(g_surface_map_lock.Get()); |
| 177 g_surface_map.Get().erase(surface_id_); | 179 g_surface_map.Get().erase(surface_id_); |
| 178 } | 180 } |
| 179 SetWindowSurface(NULL); | 181 SetWindowSurface(NULL); |
| 180 } | 182 } |
| 181 } | 183 } |
| 182 | 184 |
| 183 void CompositorImpl::SetVisible(bool visible) { | 185 void CompositorImpl::SetVisible(bool visible) { |
| 184 if (!visible) { | 186 if (!visible) { |
| 185 host_.reset(); | 187 host_.reset(); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 448 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
| 447 return GL_UNSIGNED_BYTE; | 449 return GL_UNSIGNED_BYTE; |
| 448 break; | 450 break; |
| 449 case ANDROID_BITMAP_FORMAT_RGB_565: | 451 case ANDROID_BITMAP_FORMAT_RGB_565: |
| 450 default: | 452 default: |
| 451 return GL_UNSIGNED_SHORT_5_6_5; | 453 return GL_UNSIGNED_SHORT_5_6_5; |
| 452 } | 454 } |
| 453 } | 455 } |
| 454 | 456 |
| 455 } // namespace content | 457 } // namespace content |
| OLD | NEW |