Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1095993002: Fallback to RGBA_8888 if readback format is not supported (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 1996
1997 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1997 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1998 return; 1998 return;
1999 1999
2000 gfx::Size output_size_in_pixel; 2000 gfx::Size output_size_in_pixel;
2001 if (dst_size_in_pixel.IsEmpty()) 2001 if (dst_size_in_pixel.IsEmpty())
2002 output_size_in_pixel = result->size(); 2002 output_size_in_pixel = result->size();
2003 else 2003 else
2004 output_size_in_pixel = dst_size_in_pixel; 2004 output_size_in_pixel = dst_size_in_pixel;
2005 2005
2006 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 2006 SkColorType preferred_color_type = color_type;
no sievers 2015/04/22 20:20:39 Can we make color_type non-const instead and overw
patro 2015/04/23 09:43:46 Done.
2007 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 2007 GLHelper* gl_helper = GetPostReadbackGLHelper();
2008 output_size_in_pixel.height(), 2008 if (gl_helper) {
no sievers 2015/04/22 20:20:39 nit: if (!gl_helper) return
patro 2015/04/23 09:43:46 Done.
2009 color_type, 2009 if (!gl_helper->IsReadbackConfigSupported(preferred_color_type))
2010 kOpaque_SkAlphaType))) { 2010 preferred_color_type = kRGBA_8888_SkColorType;
2011 } else {
2011 return; 2012 return;
2012 } 2013 }
2013 2014
2014 GLHelper* gl_helper = GetPostReadbackGLHelper(); 2015 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
2015 if (!gl_helper || !gl_helper->IsReadbackConfigSupported(color_type)) 2016 if (!bitmap->tryAllocPixels(SkImageInfo::Make(
2017 output_size_in_pixel.width(), output_size_in_pixel.height(),
2018 preferred_color_type, kOpaque_SkAlphaType))) {
2016 return; 2019 return;
2020 }
2017 2021
2018 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 2022 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
2019 new SkAutoLockPixels(*bitmap)); 2023 new SkAutoLockPixels(*bitmap));
2020 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 2024 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
2021 2025
2022 cc::TextureMailbox texture_mailbox; 2026 cc::TextureMailbox texture_mailbox;
2023 scoped_ptr<cc::SingleReleaseCallback> release_callback; 2027 scoped_ptr<cc::SingleReleaseCallback> release_callback;
2024 result->TakeTexture(&texture_mailbox, &release_callback); 2028 result->TakeTexture(&texture_mailbox, &release_callback);
2025 DCHECK(texture_mailbox.IsTexture()); 2029 DCHECK(texture_mailbox.IsTexture());
2026 if (!texture_mailbox.IsTexture()) 2030 if (!texture_mailbox.IsTexture())
2027 return; 2031 return;
2028 2032
2029 ignore_result(scoped_callback_runner.Release()); 2033 ignore_result(scoped_callback_runner.Release());
2030 2034
2031 gl_helper->CropScaleReadbackAndCleanMailbox( 2035 gl_helper->CropScaleReadbackAndCleanMailbox(
2032 texture_mailbox.mailbox(), 2036 texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(),
2033 texture_mailbox.sync_point(), 2037 gfx::Rect(result->size()), output_size_in_pixel, pixels,
2034 result->size(), 2038 preferred_color_type,
2035 gfx::Rect(result->size()), 2039 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
2036 output_size_in_pixel, 2040 base::Passed(&release_callback), base::Passed(&bitmap),
2037 pixels, 2041 start_time, base::Passed(&bitmap_pixels_lock)),
2038 color_type,
2039 base::Bind(&CopyFromCompositingSurfaceFinished,
2040 callback,
2041 base::Passed(&release_callback),
2042 base::Passed(&bitmap),
2043 start_time,
2044 base::Passed(&bitmap_pixels_lock)),
2045 GLHelper::SCALER_QUALITY_GOOD); 2042 GLHelper::SCALER_QUALITY_GOOD);
2046 } 2043 }
2047 2044
2048 SkColorType RenderWidgetHostViewAndroid::PreferredReadbackFormat() {
2049 // Define the criteria here. If say the 16 texture readback is
2050 // supported we should go with that (this degrades quality)
2051 // or stick back to the default format.
2052 if (base::SysInfo::IsLowEndDevice()) {
2053 // TODO(sievers): Cannot use GLHelper here. Instead remove this API
2054 // and have CopyFromCompositingSurface() fall back to RGB8 if 565 was
2055 // requested but is not supported.
2056 GLHelper* gl_helper = GetPostReadbackGLHelper();
2057 if (gl_helper && gl_helper->IsReadbackConfigSupported(kRGB_565_SkColorType))
2058 return kRGB_565_SkColorType;
2059 }
2060 return kN32_SkColorType;
2061 }
2062
2063 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 2045 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
2064 float y0, 2046 float y0,
2065 float x1, 2047 float x1,
2066 float y1) { 2048 float y1) {
2067 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 2049 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
2068 } 2050 }
2069 2051
2070 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { 2052 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) {
2071 MoveRangeSelectionExtent(gfx::PointF(x, y)); 2053 MoveRangeSelectionExtent(gfx::PointF(x, y));
2072 } 2054 }
(...skipping 26 matching lines...) Expand all
2099 results->orientationAngle = display.RotationAsDegree(); 2081 results->orientationAngle = display.RotationAsDegree();
2100 results->orientationType = 2082 results->orientationType =
2101 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2083 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2102 gfx::DeviceDisplayInfo info; 2084 gfx::DeviceDisplayInfo info;
2103 results->depth = info.GetBitsPerPixel(); 2085 results->depth = info.GetBitsPerPixel();
2104 results->depthPerComponent = info.GetBitsPerComponent(); 2086 results->depthPerComponent = info.GetBitsPerComponent();
2105 results->isMonochrome = (results->depthPerComponent == 0); 2087 results->isMonochrome = (results->depthPerComponent == 0);
2106 } 2088 }
2107 2089
2108 } // namespace content 2090 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698