| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 surface_id_(0), | 122 surface_id_(0), |
| 123 client_(client), | 123 client_(client), |
| 124 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 124 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 125 DCHECK(client); | 125 DCHECK(client); |
| 126 } | 126 } |
| 127 | 127 |
| 128 CompositorImpl::~CompositorImpl() { | 128 CompositorImpl::~CompositorImpl() { |
| 129 } | 129 } |
| 130 | 130 |
| 131 void CompositorImpl::Composite() { | 131 void CompositorImpl::Composite() { |
| 132 if (host_.get()) | 132 if (host_) |
| 133 host_->Composite(base::TimeTicks::Now()); | 133 host_->Composite(base::TimeTicks::Now()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { | 136 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { |
| 137 root_layer_->RemoveAllChildren(); | 137 root_layer_->RemoveAllChildren(); |
| 138 root_layer_->AddChild(root_layer); | 138 root_layer_->AddChild(root_layer); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { | 141 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { |
| 142 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 142 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 base::AutoLock lock(g_surface_map_lock.Get()); | 176 base::AutoLock lock(g_surface_map_lock.Get()); |
| 177 g_surface_map.Get().erase(surface_id_); | 177 g_surface_map.Get().erase(surface_id_); |
| 178 } | 178 } |
| 179 SetWindowSurface(NULL); | 179 SetWindowSurface(NULL); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 void CompositorImpl::SetVisible(bool visible) { | 183 void CompositorImpl::SetVisible(bool visible) { |
| 184 if (!visible) { | 184 if (!visible) { |
| 185 host_.reset(); | 185 host_.reset(); |
| 186 } else if (!host_.get()) { | 186 } else if (!host_) { |
| 187 cc::LayerTreeSettings settings; | 187 cc::LayerTreeSettings settings; |
| 188 settings.refresh_rate = 60.0; | 188 settings.refresh_rate = 60.0; |
| 189 settings.impl_side_painting = false; | 189 settings.impl_side_painting = false; |
| 190 settings.calculate_top_controls_position = false; | 190 settings.calculate_top_controls_position = false; |
| 191 settings.top_controls_height = 0.f; | 191 settings.top_controls_height = 0.f; |
| 192 settings.use_memory_management = false; | 192 settings.use_memory_management = false; |
| 193 settings.highp_threshold_min = 2048; | 193 settings.highp_threshold_min = 2048; |
| 194 | 194 |
| 195 // Do not clear the framebuffer when rendering into external GL contexts | 195 // Do not clear the framebuffer when rendering into external GL contexts |
| 196 // like Android View System's. | 196 // like Android View System's. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 size_ = size; | 224 size_ = size; |
| 225 if (host_) | 225 if (host_) |
| 226 host_->SetViewportSize(size); | 226 host_->SetViewportSize(size); |
| 227 root_layer_->SetBounds(size); | 227 root_layer_->SetBounds(size); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void CompositorImpl::SetHasTransparentBackground(bool flag) { | 230 void CompositorImpl::SetHasTransparentBackground(bool flag) { |
| 231 has_transparent_background_ = flag; | 231 has_transparent_background_ = flag; |
| 232 if (host_.get()) | 232 if (host_) |
| 233 host_->set_has_transparent_background(flag); | 233 host_->set_has_transparent_background(flag); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool CompositorImpl::CompositeAndReadback(void *pixels, const gfx::Rect& rect) { | 236 bool CompositorImpl::CompositeAndReadback(void *pixels, const gfx::Rect& rect) { |
| 237 if (host_.get()) | 237 if (host_) |
| 238 return host_->CompositeAndReadback(pixels, rect); | 238 return host_->CompositeAndReadback(pixels, rect); |
| 239 else | 239 else |
| 240 return false; | 240 return false; |
| 241 } | 241 } |
| 242 | 242 |
| 243 WebKit::WebGLId CompositorImpl::GenerateTexture(gfx::JavaBitmap& bitmap) { | 243 WebKit::WebGLId CompositorImpl::GenerateTexture(gfx::JavaBitmap& bitmap) { |
| 244 unsigned int texture_id = BuildBasicTexture(); | 244 unsigned int texture_id = BuildBasicTexture(); |
| 245 WebKit::WebGraphicsContext3D* context = | 245 WebKit::WebGraphicsContext3D* context = |
| 246 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | 246 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); |
| 247 if (texture_id == 0 || context->isContextLost() || | 247 if (texture_id == 0 || context->isContextLost() || |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 446 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
| 447 return GL_UNSIGNED_BYTE; | 447 return GL_UNSIGNED_BYTE; |
| 448 break; | 448 break; |
| 449 case ANDROID_BITMAP_FORMAT_RGB_565: | 449 case ANDROID_BITMAP_FORMAT_RGB_565: |
| 450 default: | 450 default: |
| 451 return GL_UNSIGNED_SHORT_5_6_5; | 451 return GL_UNSIGNED_SHORT_5_6_5; |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace content | 455 } // namespace content |
| OLD | NEW |