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

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

Issue 1409833004: Add DeviceDisplayInfo getter in WindowAndroid. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some minor/comment/nits changes for sky@ and boliu@. Created 4 years, 10 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
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 surface->AddDestructionDependency(sequence); 112 surface->AddDestructionDependency(sequence);
113 } 113 }
114 114
115 const int kUndefinedOutputSurfaceId = -1; 115 const int kUndefinedOutputSurfaceId = -1;
116 116
117 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 117 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
118 118
119 class GLHelperHolder 119 class GLHelperHolder
120 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { 120 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
121 public: 121 public:
122 static GLHelperHolder* Create(); 122 static GLHelperHolder* Create(size_t display_area);
123 ~GLHelperHolder() override; 123 ~GLHelperHolder() override;
124 124
125 void Initialize(); 125 void Initialize(size_t display_area);
126 126
127 // WebGraphicsContextLostCallback implementation. 127 // WebGraphicsContextLostCallback implementation.
128 void onContextLost() override; 128 void onContextLost() override;
129 129
130 GLHelper* GetGLHelper() { return gl_helper_.get(); } 130 GLHelper* GetGLHelper() { return gl_helper_.get(); }
131 bool IsLost() { return !context_.get() || context_->isContextLost(); } 131 bool IsLost() { return !context_.get() || context_->isContextLost(); }
132 132
133 private: 133 private:
134 GLHelperHolder(); 134 GLHelperHolder();
135 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); 135 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(
136 size_t display_area);
136 137
137 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; 138 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
138 scoped_ptr<GLHelper> gl_helper_; 139 scoped_ptr<GLHelper> gl_helper_;
139 140
140 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); 141 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder);
141 }; 142 };
142 143
143 GLHelperHolder* GLHelperHolder::Create() { 144 GLHelperHolder* GLHelperHolder::Create(size_t display_area) {
144 GLHelperHolder* holder = new GLHelperHolder; 145 GLHelperHolder* holder = new GLHelperHolder;
145 holder->Initialize(); 146 holder->Initialize(display_area);
146 147
147 return holder; 148 return holder;
148 } 149 }
149 150
150 GLHelperHolder::GLHelperHolder() { 151 GLHelperHolder::GLHelperHolder() {
151 } 152 }
152 153
153 GLHelperHolder::~GLHelperHolder() { 154 GLHelperHolder::~GLHelperHolder() {
154 } 155 }
155 156
156 void GLHelperHolder::Initialize() { 157 void GLHelperHolder::Initialize(size_t display_area) {
157 context_ = CreateContext3D(); 158 context_ = CreateContext3D(display_area);
158 if (context_) { 159 if (context_) {
159 context_->setContextLostCallback(this); 160 context_->setContextLostCallback(this);
160 gl_helper_.reset(new GLHelper(context_->GetImplementation(), 161 gl_helper_.reset(new GLHelper(context_->GetImplementation(),
161 context_->GetContextSupport())); 162 context_->GetContextSupport()));
162 } 163 }
163 } 164 }
164 165
165 void GLHelperHolder::onContextLost() { 166 void GLHelperHolder::onContextLost() {
166 // Need to post a task because the command buffer client cannot be deleted 167 // Need to post a task because the command buffer client cannot be deleted
167 // from within this callback. 168 // from within this callback.
168 LOG(ERROR) << "Context lost."; 169 LOG(ERROR) << "Context lost.";
169 base::MessageLoop::current()->PostTask( 170 base::MessageLoop::current()->PostTask(
170 FROM_HERE, 171 FROM_HERE,
171 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); 172 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost));
172 } 173 }
173 174
174 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 175 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
175 GLHelperHolder::CreateContext3D() { 176 GLHelperHolder::CreateContext3D(size_t display_area) {
176 BrowserGpuChannelHostFactory* factory = 177 BrowserGpuChannelHostFactory* factory =
177 BrowserGpuChannelHostFactory::instance(); 178 BrowserGpuChannelHostFactory::instance();
178 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); 179 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel());
179 // GLHelper can only be used in asynchronous APIs for postprocessing after 180 // GLHelper can only be used in asynchronous APIs for postprocessing after
180 // Browser Compositor operations (i.e. readback). 181 // Browser Compositor operations (i.e. readback).
181 if (!gpu_channel_host.get()) { 182 if (!gpu_channel_host.get()) {
182 // The Browser Compositor is in charge of reestablishing the channel. 183 // The Browser Compositor is in charge of reestablishing the channel.
183 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 184 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
184 } 185 }
185 186
186 blink::WebGraphicsContext3D::Attributes attrs; 187 blink::WebGraphicsContext3D::Attributes attrs;
187 attrs.shareResources = true; 188 attrs.shareResources = true;
188 GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); 189 GURL url("chrome://gpu/RenderWidgetHostViewAndroid");
189 static const size_t kBytesPerPixel = 4; 190 static const size_t kBytesPerPixel = 4;
190 gfx::DeviceDisplayInfo display_info; 191 size_t full_screen_texture_size_in_bytes = display_area * kBytesPerPixel;
191 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
192 display_info.GetDisplayWidth() *
193 kBytesPerPixel;
194 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 192 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
195 limits.command_buffer_size = 64 * 1024; 193 limits.command_buffer_size = 64 * 1024;
196 limits.start_transfer_buffer_size = 64 * 1024; 194 limits.start_transfer_buffer_size = 64 * 1024;
197 limits.min_transfer_buffer_size = 64 * 1024; 195 limits.min_transfer_buffer_size = 64 * 1024;
198 limits.max_transfer_buffer_size = std::min( 196 limits.max_transfer_buffer_size = std::min(
199 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); 197 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize);
200 limits.mapped_memory_reclaim_limit = 198 limits.mapped_memory_reclaim_limit =
201 WebGraphicsContext3DCommandBufferImpl::kNoLimit; 199 WebGraphicsContext3DCommandBufferImpl::kNoLimit;
202 bool lose_context_when_out_of_memory = false; 200 bool lose_context_when_out_of_memory = false;
203 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 201 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
204 new WebGraphicsContext3DCommandBufferImpl( 202 new WebGraphicsContext3DCommandBufferImpl(
205 0, // offscreen 203 0, // offscreen
206 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory, 204 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory,
207 limits, nullptr)); 205 limits, nullptr));
208 context->SetContextType(BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 206 context->SetContextType(BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
209 if (context->InitializeOnCurrentThread()) { 207 if (context->InitializeOnCurrentThread()) {
210 context->traceBeginCHROMIUM( 208 context->traceBeginCHROMIUM(
211 "gpu_toplevel", 209 "gpu_toplevel",
212 base::StringPrintf("CmdBufferImageTransportFactory-%p", 210 base::StringPrintf("CmdBufferImageTransportFactory-%p",
213 context.get()).c_str()); 211 context.get()).c_str());
214 } else { 212 } else {
215 context.reset(); 213 context.reset();
216 } 214 }
217 215
218 return context; 216 return context;
219 } 217 }
220 218
221 // This can only be used for readback postprocessing. It may return null if the 219 // This can only be used for readback postprocessing. It may return null if the
222 // channel was lost and not reestablished yet. 220 // channel was lost and not reestablished yet.
223 GLHelper* GetPostReadbackGLHelper() { 221 GLHelper* GetPostReadbackGLHelper(size_t display_area) {
224 static GLHelperHolder* g_readback_helper_holder = nullptr; 222 static GLHelperHolder* g_readback_helper_holder = nullptr;
225 223
226 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { 224 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
227 delete g_readback_helper_holder; 225 delete g_readback_helper_holder;
228 g_readback_helper_holder = nullptr; 226 g_readback_helper_holder = nullptr;
229 } 227 }
230 228
231 if (!g_readback_helper_holder) 229 if (!g_readback_helper_holder)
232 g_readback_helper_holder = GLHelperHolder::Create(); 230 g_readback_helper_holder = GLHelperHolder::Create(display_area);
233 231
234 return g_readback_helper_holder->GetGLHelper(); 232 return g_readback_helper_holder->GetGLHelper();
235 } 233 }
236 234
237 void CopyFromCompositingSurfaceFinished( 235 void CopyFromCompositingSurfaceFinished(
238 const ReadbackRequestCallback& callback, 236 const ReadbackRequestCallback& callback,
239 scoped_ptr<cc::SingleReleaseCallback> release_callback, 237 scoped_ptr<cc::SingleReleaseCallback> release_callback,
240 scoped_ptr<SkBitmap> bitmap, 238 scoped_ptr<SkBitmap> bitmap,
241 const base::TimeTicks& start_time, 239 const base::TimeTicks& start_time,
242 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 240 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
241 size_t display_area,
243 bool result) { 242 bool result) {
244 TRACE_EVENT0( 243 TRACE_EVENT0(
245 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); 244 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished");
246 bitmap_pixels_lock.reset(); 245 bitmap_pixels_lock.reset();
247 gpu::SyncToken sync_token; 246 gpu::SyncToken sync_token;
248 if (result) { 247 if (result) {
249 GLHelper* gl_helper = GetPostReadbackGLHelper(); 248 GLHelper* gl_helper = GetPostReadbackGLHelper(display_area);
250 if (gl_helper) 249 if (gl_helper)
251 gl_helper->GenerateSyncToken(&sync_token); 250 gl_helper->GenerateSyncToken(&sync_token);
252 } 251 }
253 const bool lost_resource = !sync_token.HasData(); 252 const bool lost_resource = !sync_token.HasData();
254 release_callback->Run(sync_token, lost_resource); 253 release_callback->Run(sync_token, lost_resource);
255 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, 254 UMA_HISTOGRAM_TIMES(kAsyncReadBackString,
256 base::TimeTicks::Now() - start_time); 255 base::TimeTicks::Now() - start_time);
257 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; 256 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED;
258 callback.Run(*bitmap, response); 257 callback.Run(*bitmap, response);
259 } 258 }
(...skipping 25 matching lines...) Expand all
285 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { 284 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
286 gfx::RectF rect = controller.GetRectBetweenBounds(); 285 gfx::RectF rect = controller.GetRectBetweenBounds();
287 if (rect.IsEmpty()) 286 if (rect.IsEmpty())
288 return rect; 287 return rect;
289 288
290 rect.Union(controller.GetStartHandleRect()); 289 rect.Union(controller.GetStartHandleRect());
291 rect.Union(controller.GetEndHandleRect()); 290 rect.Union(controller.GetEndHandleRect());
292 return rect; 291 return rect;
293 } 292 }
294 293
294 void DisplayInfoToScreenInfo(const gfx::Display& display,
295 const gfx::DeviceDisplayInfo& info,
296 blink::WebScreenInfo* results) {
297 results->rect = display.bounds();
298 // TODO(husky): Remove any system controls from availableRect.
299 results->availableRect = display.work_area();
300 results->deviceScaleFactor = display.device_scale_factor();
301 results->orientationAngle = display.RotationAsDegree();
302 results->orientationType =
303 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
304 results->depth = info.GetBitsPerPixel();
305 results->depthPerComponent = info.GetBitsPerComponent();
306 results->isMonochrome = (results->depthPerComponent == 0);
307 }
308
295 } // anonymous namespace 309 } // anonymous namespace
296 310
297 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( 311 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo(
298 uint32_t output_id, 312 uint32_t output_id,
299 scoped_ptr<cc::CompositorFrame> output_frame) 313 scoped_ptr<cc::CompositorFrame> output_frame)
300 : output_surface_id(output_id), frame(std::move(output_frame)) {} 314 : output_surface_id(output_id), frame(std::move(output_frame)) {}
301 315
302 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} 316 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {}
303 317
304 void RenderWidgetHostViewAndroid::OnContextLost() { 318 void RenderWidgetHostViewAndroid::OnContextLost() {
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 913 }
900 ui::WindowAndroidCompositor* compositor = 914 ui::WindowAndroidCompositor* compositor =
901 content_view_core_->GetWindowAndroid()->GetCompositor(); 915 content_view_core_->GetWindowAndroid()->GetCompositor();
902 DCHECK(compositor); 916 DCHECK(compositor);
903 DCHECK(!surface_id_.is_null()); 917 DCHECK(!surface_id_.is_null());
904 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); 918 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer();
905 DCHECK(layer); 919 DCHECK(layer);
906 layer->SetHideLayerAndSubtree(true); 920 layer->SetHideLayerAndSubtree(true);
907 compositor->AttachLayerForReadback(layer); 921 compositor->AttachLayerForReadback(layer);
908 922
923 const gfx::DeviceDisplayInfo& display_info =
924 content_view_core_->GetWindowAndroid()->GetDeviceDisplayInfo();
925 size_t display_area =
926 display_info.GetDisplayHeight() * display_info.GetDisplayWidth();
927
909 readback_layer = layer; 928 readback_layer = layer;
910 request = cc::CopyOutputRequest::CreateRequest( 929 request = cc::CopyOutputRequest::CreateRequest(
911 base::Bind(&RenderWidgetHostViewAndroid:: 930 base::Bind(&RenderWidgetHostViewAndroid::
912 PrepareTextureCopyOutputResultForDelegatedReadback, 931 PrepareTextureCopyOutputResultForDelegatedReadback,
913 dst_size_in_pixel, preferred_color_type, start_time, 932 dst_size_in_pixel, preferred_color_type, start_time,
914 readback_layer, callback)); 933 readback_layer, callback, display_area));
915 if (!src_subrect_in_pixel.IsEmpty()) 934 if (!src_subrect_in_pixel.IsEmpty())
916 request->set_area(src_subrect_in_pixel); 935 request->set_area(src_subrect_in_pixel);
917 readback_layer->RequestCopyOfOutput(std::move(request)); 936 readback_layer->RequestCopyOfOutput(std::move(request));
918 } 937 }
919 938
920 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 939 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
921 const gfx::Rect& src_subrect, 940 const gfx::Rect& src_subrect,
922 const scoped_refptr<media::VideoFrame>& target, 941 const scoped_refptr<media::VideoFrame>& target,
923 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 942 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
924 NOTIMPLEMENTED(); 943 NOTIMPLEMENTED();
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 DestroyDelegatedContent(); 1526 DestroyDelegatedContent();
1508 frame_evictor_->DiscardedFrame(); 1527 frame_evictor_->DiscardedFrame();
1509 } 1528 }
1510 1529
1511 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 1530 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
1512 const gfx::Size& desired_size) { 1531 const gfx::Size& desired_size) {
1513 NOTREACHED(); 1532 NOTREACHED();
1514 return false; 1533 return false;
1515 } 1534 }
1516 1535
1517 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { 1536 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) {
1518 // ScreenInfo isn't tied to the widget on Android. Always return the default. 1537 if (content_view_core_) {
no sievers 2016/02/27 01:11:52 I'm wondering if it's worth plumbing all this info
boliu 2016/02/27 01:30:56 It's also used to determine stuff like screen dens
no sievers 2016/02/29 18:16:03 The point was: If this is for multi-display, then
gsennton 2016/04/25 18:55:58 I experimented a bit by setting different device s
1519 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); 1538 gfx::NativeView view_android = GetNativeView();
1539
1540 const gfx::Display& display =
1541 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view_android);
1542 const gfx::DeviceDisplayInfo& info =
1543 content_view_core_->GetWindowAndroid()->GetDeviceDisplayInfo();
1544 DisplayInfoToScreenInfo(display, info, results);
1545 } else {
1546 GetDefaultScreenInfo(results);
1547 }
1520 } 1548 }
1521 1549
1522 bool RenderWidgetHostViewAndroid::GetScreenColorProfile( 1550 bool RenderWidgetHostViewAndroid::GetScreenColorProfile(
1523 std::vector<char>* color_profile) { 1551 std::vector<char>* color_profile) {
1524 DCHECK(color_profile->empty()); 1552 DCHECK(color_profile->empty());
1525 NOTREACHED(); 1553 NOTREACHED();
1526 return false; 1554 return false;
1527 } 1555 }
1528 1556
1529 // TODO(jrg): Find out the implications and answer correctly here, 1557 // TODO(jrg): Find out the implications and answer correctly here,
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1959 }
1932 1960
1933 // static 1961 // static
1934 void RenderWidgetHostViewAndroid:: 1962 void RenderWidgetHostViewAndroid::
1935 PrepareTextureCopyOutputResultForDelegatedReadback( 1963 PrepareTextureCopyOutputResultForDelegatedReadback(
1936 const gfx::Size& dst_size_in_pixel, 1964 const gfx::Size& dst_size_in_pixel,
1937 SkColorType color_type, 1965 SkColorType color_type,
1938 const base::TimeTicks& start_time, 1966 const base::TimeTicks& start_time,
1939 scoped_refptr<cc::Layer> readback_layer, 1967 scoped_refptr<cc::Layer> readback_layer,
1940 const ReadbackRequestCallback& callback, 1968 const ReadbackRequestCallback& callback,
1969 size_t display_area,
1941 scoped_ptr<cc::CopyOutputResult> result) { 1970 scoped_ptr<cc::CopyOutputResult> result) {
1942 readback_layer->RemoveFromParent(); 1971 readback_layer->RemoveFromParent();
1943 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time, 1972 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
1944 callback, std::move(result)); 1973 callback, display_area, std::move(result));
1945 } 1974 }
1946 1975
1947 // TODO(wjmaclean): There is significant overlap between 1976 // TODO(wjmaclean): There is significant overlap between
1948 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in 1977 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in
1949 // this file, and the versions in surface_utils.cc. They should 1978 // this file, and the versions in surface_utils.cc. They should
1950 // be merged. See https://crbug.com/582955 1979 // be merged. See https://crbug.com/582955
1951 1980
1952 // static 1981 // static
1953 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1982 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1954 const gfx::Size& dst_size_in_pixel, 1983 const gfx::Size& dst_size_in_pixel,
1955 SkColorType color_type, 1984 SkColorType color_type,
1956 const base::TimeTicks& start_time, 1985 const base::TimeTicks& start_time,
1957 const ReadbackRequestCallback& callback, 1986 const ReadbackRequestCallback& callback,
1987 size_t display_area,
1958 scoped_ptr<cc::CopyOutputResult> result) { 1988 scoped_ptr<cc::CopyOutputResult> result) {
1959 base::ScopedClosureRunner scoped_callback_runner( 1989 base::ScopedClosureRunner scoped_callback_runner(
1960 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1990 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1961 TRACE_EVENT0("cc", 1991 TRACE_EVENT0("cc",
1962 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1992 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1963 1993
1964 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1994 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1965 return; 1995 return;
1966 1996
1967 gfx::Size output_size_in_pixel; 1997 gfx::Size output_size_in_pixel;
1968 if (dst_size_in_pixel.IsEmpty()) 1998 if (dst_size_in_pixel.IsEmpty())
1969 output_size_in_pixel = result->size(); 1999 output_size_in_pixel = result->size();
1970 else 2000 else
1971 output_size_in_pixel = dst_size_in_pixel; 2001 output_size_in_pixel = dst_size_in_pixel;
1972 2002
1973 GLHelper* gl_helper = GetPostReadbackGLHelper(); 2003 GLHelper* gl_helper = GetPostReadbackGLHelper(display_area);
1974 if (!gl_helper) 2004 if (!gl_helper)
1975 return; 2005 return;
1976 if (!gl_helper->IsReadbackConfigSupported(color_type)) 2006 if (!gl_helper->IsReadbackConfigSupported(color_type))
1977 color_type = kRGBA_8888_SkColorType; 2007 color_type = kRGBA_8888_SkColorType;
1978 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 2008 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
1979 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 2009 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(),
1980 output_size_in_pixel.height(), 2010 output_size_in_pixel.height(),
1981 color_type, 2011 color_type,
1982 kOpaque_SkAlphaType))) { 2012 kOpaque_SkAlphaType))) {
1983 scoped_callback_runner.Reset( 2013 scoped_callback_runner.Reset(
(...skipping 13 matching lines...) Expand all
1997 if (!texture_mailbox.IsTexture()) 2027 if (!texture_mailbox.IsTexture())
1998 return; 2028 return;
1999 2029
2000 ignore_result(scoped_callback_runner.Release()); 2030 ignore_result(scoped_callback_runner.Release());
2001 2031
2002 gl_helper->CropScaleReadbackAndCleanMailbox( 2032 gl_helper->CropScaleReadbackAndCleanMailbox(
2003 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), 2033 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(),
2004 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, 2034 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
2005 base::Bind(&CopyFromCompositingSurfaceFinished, callback, 2035 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
2006 base::Passed(&release_callback), base::Passed(&bitmap), 2036 base::Passed(&release_callback), base::Passed(&bitmap),
2007 start_time, base::Passed(&bitmap_pixels_lock)), 2037 start_time, base::Passed(&bitmap_pixels_lock), display_area),
2008 GLHelper::SCALER_QUALITY_GOOD); 2038 GLHelper::SCALER_QUALITY_GOOD);
2009 } 2039 }
2010 2040
2011 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 2041 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
2012 float y0, 2042 float y0,
2013 float x1, 2043 float x1,
2014 float y1) { 2044 float y1) {
2015 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 2045 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
2016 } 2046 }
2017 2047
(...skipping 14 matching lines...) Expand all
2032 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( 2062 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build(
2033 blink::WebInputEvent::GestureLongPress, 2063 blink::WebInputEvent::GestureLongPress,
2034 (time - base::TimeTicks()).InSecondsF(), x, y); 2064 (time - base::TimeTicks()).InSecondsF(), x, y);
2035 SendGestureEvent(long_press); 2065 SendGestureEvent(long_press);
2036 } 2066 }
2037 2067
2038 // static 2068 // static
2039 void RenderWidgetHostViewBase::GetDefaultScreenInfo( 2069 void RenderWidgetHostViewBase::GetDefaultScreenInfo(
2040 blink::WebScreenInfo* results) { 2070 blink::WebScreenInfo* results) {
2041 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 2071 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay();
2042 results->rect = display.bounds();
2043 // TODO(husky): Remove any system controls from availableRect.
2044 results->availableRect = display.work_area();
2045 results->deviceScaleFactor = display.device_scale_factor();
2046 results->orientationAngle = display.RotationAsDegree();
2047 results->orientationType =
2048 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2049 gfx::DeviceDisplayInfo info; 2072 gfx::DeviceDisplayInfo info;
2050 results->depth = info.GetBitsPerPixel(); 2073 DisplayInfoToScreenInfo(display, info, results);
2051 results->depthPerComponent = info.GetBitsPerComponent();
2052 results->isMonochrome = (results->depthPerComponent == 0);
2053 } 2074 }
2054 2075
2055 } // namespace content 2076 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698