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/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
| 9 #include "base/android/sys_utils.h" |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/threading/worker_pool.h" | 18 #include "base/threading/worker_pool.h" |
18 #include "cc/base/latency_info_swap_promise.h" | 19 #include "cc/base/latency_info_swap_promise.h" |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 bool RenderWidgetHostViewAndroid::IsReadbackConfigSupported( | 1380 bool RenderWidgetHostViewAndroid::IsReadbackConfigSupported( |
1380 SkBitmap::Config bitmap_config) { | 1381 SkBitmap::Config bitmap_config) { |
1381 ImageTransportFactoryAndroid* factory = | 1382 ImageTransportFactoryAndroid* factory = |
1382 ImageTransportFactoryAndroid::GetInstance(); | 1383 ImageTransportFactoryAndroid::GetInstance(); |
1383 GLHelper* gl_helper = factory->GetGLHelper(); | 1384 GLHelper* gl_helper = factory->GetGLHelper(); |
1384 if (!gl_helper) | 1385 if (!gl_helper) |
1385 return false; | 1386 return false; |
1386 return gl_helper->IsReadbackConfigSupported(bitmap_config); | 1387 return gl_helper->IsReadbackConfigSupported(bitmap_config); |
1387 } | 1388 } |
1388 | 1389 |
| 1390 SkBitmap::Config RenderWidgetHostViewAndroid::PreferredReadbackFormat() { |
| 1391 // Define the criteria here. If say the 16 texture readback is |
| 1392 // supported we should go with that (this degrades quality) |
| 1393 // or stick back to the default format. |
| 1394 if (base::android::SysUtils::IsLowEndDevice()) { |
| 1395 if (IsReadbackConfigSupported(SkBitmap::kRGB_565_Config)) |
| 1396 return SkBitmap::kRGB_565_Config; |
| 1397 } |
| 1398 return SkBitmap::kARGB_8888_Config; |
| 1399 } |
| 1400 |
1389 // static | 1401 // static |
1390 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1402 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
1391 blink::WebScreenInfo* results) { | 1403 blink::WebScreenInfo* results) { |
1392 const gfx::Display& display = | 1404 const gfx::Display& display = |
1393 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 1405 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
1394 results->rect = display.bounds(); | 1406 results->rect = display.bounds(); |
1395 // TODO(husky): Remove any system controls from availableRect. | 1407 // TODO(husky): Remove any system controls from availableRect. |
1396 results->availableRect = display.work_area(); | 1408 results->availableRect = display.work_area(); |
1397 results->deviceScaleFactor = display.device_scale_factor(); | 1409 results->deviceScaleFactor = display.device_scale_factor(); |
1398 gfx::DeviceDisplayInfo info; | 1410 gfx::DeviceDisplayInfo info; |
1399 results->depth = info.GetBitsPerPixel(); | 1411 results->depth = info.GetBitsPerPixel(); |
1400 results->depthPerComponent = info.GetBitsPerComponent(); | 1412 results->depthPerComponent = info.GetBitsPerComponent(); |
1401 results->isMonochrome = (results->depthPerComponent == 0); | 1413 results->isMonochrome = (results->depthPerComponent == 0); |
1402 } | 1414 } |
1403 | 1415 |
1404 //////////////////////////////////////////////////////////////////////////////// | 1416 //////////////////////////////////////////////////////////////////////////////// |
1405 // RenderWidgetHostView, public: | 1417 // RenderWidgetHostView, public: |
1406 | 1418 |
1407 // static | 1419 // static |
1408 RenderWidgetHostView* | 1420 RenderWidgetHostView* |
1409 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1421 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
1410 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1422 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
1411 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1423 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
1412 } | 1424 } |
1413 | 1425 |
1414 } // namespace content | 1426 } // namespace content |
OLD | NEW |