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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 java_ref_(env, obj), | 168 java_ref_(env, obj), |
169 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 169 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
170 root_layer_(cc::Layer::Create()), | 170 root_layer_(cc::Layer::Create()), |
171 vsync_interval_(base::TimeDelta::FromMicroseconds( | 171 vsync_interval_(base::TimeDelta::FromMicroseconds( |
172 kDefaultVSyncIntervalMicros)), | 172 kDefaultVSyncIntervalMicros)), |
173 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( | 173 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( |
174 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), | 174 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), |
175 view_android_(view_android), | 175 view_android_(view_android), |
176 window_android_(window_android), | 176 window_android_(window_android), |
177 device_orientation_(0), | 177 device_orientation_(0), |
178 geolocation_needs_pause_(false) { | 178 geolocation_needs_pause_(false), |
| 179 bitmap_config_is_565_(false) { |
179 CHECK(web_contents) << | 180 CHECK(web_contents) << |
180 "A ContentViewCoreImpl should be created with a valid WebContents."; | 181 "A ContentViewCoreImpl should be created with a valid WebContents."; |
181 | 182 |
182 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 183 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
183 | 184 |
184 const gfx::Display& display = | 185 const gfx::Display& display = |
185 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 186 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
186 dpi_scale_ = display.device_scale_factor(); | 187 dpi_scale_ = display.device_scale_factor(); |
187 | 188 |
188 // Currently, the only use case we have for overriding a user agent involves | 189 // Currently, the only use case we have for overriding a user agent involves |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1272 |
1272 return view->Animate(base::TimeTicks::FromInternalValue(frame_time_micros)); | 1273 return view->Animate(base::TimeTicks::FromInternalValue(frame_time_micros)); |
1273 } | 1274 } |
1274 | 1275 |
1275 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, | 1276 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, |
1276 jobject obj, | 1277 jobject obj, |
1277 jobject jbitmap) { | 1278 jobject jbitmap) { |
1278 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1279 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
1279 if (!view) | 1280 if (!view) |
1280 return false; | 1281 return false; |
1281 | |
1282 return view->PopulateBitmapWithContents(jbitmap); | 1282 return view->PopulateBitmapWithContents(jbitmap); |
1283 } | 1283 } |
1284 | 1284 |
1285 void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) { | 1285 void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) { |
1286 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1286 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
1287 if (view) | 1287 if (view) |
1288 view->WasResized(); | 1288 view->WasResized(); |
1289 } | 1289 } |
1290 | 1290 |
1291 void ContentViewCoreImpl::ShowInterstitialPage( | 1291 void ContentViewCoreImpl::ShowInterstitialPage( |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1618 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
1619 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1619 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
1620 if (rwhv) | 1620 if (rwhv) |
1621 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); | 1621 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); |
1622 | 1622 |
1623 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1623 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
1624 web_contents_->GetRenderViewHost()); | 1624 web_contents_->GetRenderViewHost()); |
1625 rvhi->SendOrientationChangeEvent(device_orientation_); | 1625 rvhi->SendOrientationChangeEvent(device_orientation_); |
1626 } | 1626 } |
1627 | 1627 |
| 1628 static void recieveOutputBitmap(bool, const SkBitmap& bitmap) |
| 1629 { |
| 1630 if(bitmap.isNull()){ |
| 1631 return; |
| 1632 } |
| 1633 } |
| 1634 |
| 1635 void ContentViewCoreImpl::PopulateBitmapAsync(gfx::Rect src_subrect, |
| 1636 gfx::Size dst_size, |
| 1637 bool readback_config_rgb565) { |
| 1638 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1639 if (!view) |
| 1640 return ; |
| 1641 bitmap_config_is_565_ = readback_config_rgb565; |
| 1642 view->CopyFromCompositingSurface(src_subrect, |
| 1643 dst_size, |
| 1644 base::Bind(&recieveOutputBitmap)); |
| 1645 bitmap_config_is_565_ = false; |
| 1646 } |
| 1647 |
| 1648 bool ContentViewCoreImpl::IsReadBackConfig565() |
| 1649 { |
| 1650 return bitmap_config_is_565_; |
| 1651 } |
1628 // This is called for each ContentView. | 1652 // This is called for each ContentView. |
1629 jlong Init(JNIEnv* env, jobject obj, | 1653 jlong Init(JNIEnv* env, jobject obj, |
1630 jboolean hardware_accelerated, | 1654 jboolean hardware_accelerated, |
1631 jlong native_web_contents, | 1655 jlong native_web_contents, |
1632 jlong view_android, | 1656 jlong view_android, |
1633 jlong window_android) { | 1657 jlong window_android) { |
1634 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1658 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
1635 env, obj, hardware_accelerated, | 1659 env, obj, hardware_accelerated, |
1636 reinterpret_cast<WebContents*>(native_web_contents), | 1660 reinterpret_cast<WebContents*>(native_web_contents), |
1637 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1661 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1638 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1662 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1639 return reinterpret_cast<intptr_t>(view); | 1663 return reinterpret_cast<intptr_t>(view); |
1640 } | 1664 } |
1641 | 1665 |
1642 bool RegisterContentViewCore(JNIEnv* env) { | 1666 bool RegisterContentViewCore(JNIEnv* env) { |
1643 return RegisterNativesImpl(env); | 1667 return RegisterNativesImpl(env); |
1644 } | 1668 } |
1645 | 1669 |
1646 } // namespace content | 1670 } // namespace content |
OLD | NEW |