OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 java_ref_(env, obj), | 169 java_ref_(env, obj), |
170 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 170 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
171 root_layer_(cc::Layer::Create()), | 171 root_layer_(cc::Layer::Create()), |
172 vsync_interval_(base::TimeDelta::FromMicroseconds( | 172 vsync_interval_(base::TimeDelta::FromMicroseconds( |
173 kDefaultVSyncIntervalMicros)), | 173 kDefaultVSyncIntervalMicros)), |
174 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( | 174 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( |
175 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), | 175 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), |
176 view_android_(view_android), | 176 view_android_(view_android), |
177 window_android_(window_android), | 177 window_android_(window_android), |
178 device_orientation_(0), | 178 device_orientation_(0), |
179 geolocation_needs_pause_(false) { | 179 geolocation_needs_pause_(false), |
| 180 bitmap_config_is_565_(false) { |
180 CHECK(web_contents) << | 181 CHECK(web_contents) << |
181 "A ContentViewCoreImpl should be created with a valid WebContents."; | 182 "A ContentViewCoreImpl should be created with a valid WebContents."; |
182 | 183 |
183 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 184 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
184 | 185 |
185 const gfx::Display& display = | 186 const gfx::Display& display = |
186 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 187 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
187 dpi_scale_ = display.device_scale_factor(); | 188 dpi_scale_ = display.device_scale_factor(); |
188 | 189 |
189 // Currently, the only use case we have for overriding a user agent involves | 190 // Currently, the only use case we have for overriding a user agent involves |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 | 1281 |
1281 return view->Animate(base::TimeTicks::FromInternalValue(frame_time_micros)); | 1282 return view->Animate(base::TimeTicks::FromInternalValue(frame_time_micros)); |
1282 } | 1283 } |
1283 | 1284 |
1284 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, | 1285 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, |
1285 jobject obj, | 1286 jobject obj, |
1286 jobject jbitmap) { | 1287 jobject jbitmap) { |
1287 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1288 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
1288 if (!view) | 1289 if (!view) |
1289 return false; | 1290 return false; |
1290 | |
1291 return view->PopulateBitmapWithContents(jbitmap); | 1291 return view->PopulateBitmapWithContents(jbitmap); |
1292 } | 1292 } |
1293 | 1293 |
1294 void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) { | 1294 void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) { |
1295 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1295 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
1296 if (view) | 1296 if (view) |
1297 view->WasResized(); | 1297 view->WasResized(); |
1298 } | 1298 } |
1299 | 1299 |
1300 void ContentViewCoreImpl::ShowInterstitialPage( | 1300 void ContentViewCoreImpl::ShowInterstitialPage( |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1627 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
1628 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1628 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
1629 if (rwhv) | 1629 if (rwhv) |
1630 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); | 1630 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); |
1631 | 1631 |
1632 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1632 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
1633 web_contents_->GetRenderViewHost()); | 1633 web_contents_->GetRenderViewHost()); |
1634 rvhi->SendOrientationChangeEvent(device_orientation_); | 1634 rvhi->SendOrientationChangeEvent(device_orientation_); |
1635 } | 1635 } |
1636 | 1636 |
| 1637 static void recieveOutputBitmap(bool, const SkBitmap& bitmap) |
| 1638 { |
| 1639 if(bitmap.isNull()){ |
| 1640 return; |
| 1641 } |
| 1642 } |
| 1643 |
| 1644 void ContentViewCoreImpl::PopulateBitmapAsync(gfx::Rect src_subrect, |
| 1645 gfx::Size dst_size, |
| 1646 bool readback_config_rgb565) { |
| 1647 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1648 if (!view) |
| 1649 return ; |
| 1650 bitmap_config_is_565_ = readback_config_rgb565; |
| 1651 view->CopyFromCompositingSurface(src_subrect, |
| 1652 dst_size, |
| 1653 base::Bind(&recieveOutputBitmap)); |
| 1654 bitmap_config_is_565_ = false; |
| 1655 } |
| 1656 |
| 1657 bool ContentViewCoreImpl::IsReadBackConfig565() |
| 1658 { |
| 1659 return bitmap_config_is_565_; |
| 1660 } |
1637 // This is called for each ContentView. | 1661 // This is called for each ContentView. |
1638 jlong Init(JNIEnv* env, jobject obj, | 1662 jlong Init(JNIEnv* env, jobject obj, |
1639 jboolean hardware_accelerated, | 1663 jboolean hardware_accelerated, |
1640 jlong native_web_contents, | 1664 jlong native_web_contents, |
1641 jlong view_android, | 1665 jlong view_android, |
1642 jlong window_android) { | 1666 jlong window_android) { |
1643 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1667 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
1644 env, obj, hardware_accelerated, | 1668 env, obj, hardware_accelerated, |
1645 reinterpret_cast<WebContents*>(native_web_contents), | 1669 reinterpret_cast<WebContents*>(native_web_contents), |
1646 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1670 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1647 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1671 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1648 return reinterpret_cast<intptr_t>(view); | 1672 return reinterpret_cast<intptr_t>(view); |
1649 } | 1673 } |
1650 | 1674 |
1651 bool RegisterContentViewCore(JNIEnv* env) { | 1675 bool RegisterContentViewCore(JNIEnv* env) { |
1652 return RegisterNativesImpl(env); | 1676 return RegisterNativesImpl(env); |
1653 } | 1677 } |
1654 | 1678 |
1655 } // namespace content | 1679 } // namespace content |
OLD | NEW |