| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::AutoLock lock(g_surface_map_lock.Get()); | 108 base::AutoLock lock(g_surface_map_lock.Get()); |
| 109 SurfaceMap* surfaces = g_surface_map.Pointer(); | 109 SurfaceMap* surfaces = g_surface_map.Pointer(); |
| 110 SurfaceMap::iterator it = surfaces->find(surface_id); | 110 SurfaceMap::iterator it = surfaces->find(surface_id); |
| 111 jobject jsurface = it == surfaces->end() ? NULL : it->second.obj(); | 111 jobject jsurface = it == surfaces->end() ? NULL : it->second.obj(); |
| 112 | 112 |
| 113 LOG_IF(WARNING, !jsurface) << "No surface for surface id " << surface_id; | 113 LOG_IF(WARNING, !jsurface) << "No surface for surface id " << surface_id; |
| 114 return jsurface; | 114 return jsurface; |
| 115 } | 115 } |
| 116 | 116 |
| 117 CompositorImpl::CompositorImpl(Compositor::Client* client) | 117 CompositorImpl::CompositorImpl(Compositor::Client* client) |
| 118 : root_layer_(cc::Layer::create()), | 118 : root_layer_(cc::Layer::Create()), |
| 119 has_transparent_background_(false), | 119 has_transparent_background_(false), |
| 120 window_(NULL), | 120 window_(NULL), |
| 121 surface_id_(0), | 121 surface_id_(0), |
| 122 client_(client), | 122 client_(client), |
| 123 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 123 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 124 DCHECK(client); | 124 DCHECK(client); |
| 125 } | 125 } |
| 126 | 126 |
| 127 CompositorImpl::~CompositorImpl() { | 127 CompositorImpl::~CompositorImpl() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 void CompositorImpl::Composite() { | 130 void CompositorImpl::Composite() { |
| 131 if (host_.get()) | 131 if (host_.get()) |
| 132 host_->composite(); | 132 host_->composite(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { | 135 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { |
| 136 root_layer_->removeAllChildren(); | 136 root_layer_->RemoveAllChildren(); |
| 137 root_layer_->addChild(root_layer); | 137 root_layer_->AddChild(root_layer); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { | 140 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { |
| 141 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 141 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
| 142 | 142 |
| 143 if (window_) { | 143 if (window_) { |
| 144 tracker->RemoveSurface(surface_id_); | 144 tracker->RemoveSurface(surface_id_); |
| 145 ANativeWindow_release(window_); | 145 ANativeWindow_release(window_); |
| 146 window_ = NULL; | 146 window_ = NULL; |
| 147 surface_id_ = 0; | 147 surface_id_ = 0; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 host_->setDeviceScaleFactor(factor); | 215 host_->setDeviceScaleFactor(factor); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { | 218 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { |
| 219 if (size_ == size) | 219 if (size_ == size) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 size_ = size; | 222 size_ = size; |
| 223 if (host_) | 223 if (host_) |
| 224 host_->setViewportSize(size, size); | 224 host_->setViewportSize(size, size); |
| 225 root_layer_->setBounds(size); | 225 root_layer_->SetBounds(size); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void CompositorImpl::SetHasTransparentBackground(bool flag) { | 228 void CompositorImpl::SetHasTransparentBackground(bool flag) { |
| 229 has_transparent_background_ = flag; | 229 has_transparent_background_ = flag; |
| 230 if (host_.get()) | 230 if (host_.get()) |
| 231 host_->setHasTransparentBackground(flag); | 231 host_->setHasTransparentBackground(flag); |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool CompositorImpl::CompositeAndReadback(void *pixels, const gfx::Rect& rect) { | 234 bool CompositorImpl::CompositeAndReadback(void *pixels, const gfx::Rect& rect) { |
| 235 if (host_.get()) | 235 if (host_.get()) |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 478 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
| 479 return GL_UNSIGNED_BYTE; | 479 return GL_UNSIGNED_BYTE; |
| 480 break; | 480 break; |
| 481 case ANDROID_BITMAP_FORMAT_RGB_565: | 481 case ANDROID_BITMAP_FORMAT_RGB_565: |
| 482 default: | 482 default: |
| 483 return GL_UNSIGNED_SHORT_5_6_5; | 483 return GL_UNSIGNED_SHORT_5_6_5; |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| 487 } // namespace content | 487 } // namespace content |
| OLD | NEW |