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

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: Fixed variable naming and jdduke nit. Created 5 years, 1 month 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') | ui/android/BUILD.gn » ('j') | 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 surface->AddDestructionDependency(sequence); 113 surface->AddDestructionDependency(sequence);
114 } 114 }
115 115
116 const int kUndefinedOutputSurfaceId = -1; 116 const int kUndefinedOutputSurfaceId = -1;
117 117
118 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 118 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
119 119
120 class GLHelperHolder 120 class GLHelperHolder
121 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { 121 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
122 public: 122 public:
123 static GLHelperHolder* Create(); 123 static GLHelperHolder* Create(gfx::NativeWindow native_window);
124 ~GLHelperHolder() override; 124 ~GLHelperHolder() override;
125 125
126 void Initialize(); 126 void Initialize(gfx::NativeWindow native_window);
127 127
128 // WebGraphicsContextLostCallback implementation. 128 // WebGraphicsContextLostCallback implementation.
129 void onContextLost() override; 129 void onContextLost() override;
130 130
131 GLHelper* GetGLHelper() { return gl_helper_.get(); } 131 GLHelper* GetGLHelper() { return gl_helper_.get(); }
132 bool IsLost() { return !context_.get() || context_->isContextLost(); } 132 bool IsLost() { return !context_.get() || context_->isContextLost(); }
133 133
134 private: 134 private:
135 GLHelperHolder(); 135 GLHelperHolder();
136 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); 136 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(
137 gfx::NativeWindow native_window);
137 138
138 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; 139 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
139 scoped_ptr<GLHelper> gl_helper_; 140 scoped_ptr<GLHelper> gl_helper_;
140 141
141 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); 142 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder);
142 }; 143 };
143 144
144 GLHelperHolder* GLHelperHolder::Create() { 145 GLHelperHolder* GLHelperHolder::Create(gfx::NativeWindow native_window) {
145 GLHelperHolder* holder = new GLHelperHolder; 146 GLHelperHolder* holder = new GLHelperHolder;
146 holder->Initialize(); 147 holder->Initialize(native_window);
147 148
148 return holder; 149 return holder;
149 } 150 }
150 151
151 GLHelperHolder::GLHelperHolder() { 152 GLHelperHolder::GLHelperHolder() {
152 } 153 }
153 154
154 GLHelperHolder::~GLHelperHolder() { 155 GLHelperHolder::~GLHelperHolder() {
155 } 156 }
156 157
157 void GLHelperHolder::Initialize() { 158 void GLHelperHolder::Initialize(gfx::NativeWindow native_window) {
158 context_ = CreateContext3D(); 159 context_ = CreateContext3D(native_window);
159 if (context_) { 160 if (context_) {
160 context_->setContextLostCallback(this); 161 context_->setContextLostCallback(this);
161 gl_helper_.reset(new GLHelper(context_->GetImplementation(), 162 gl_helper_.reset(new GLHelper(context_->GetImplementation(),
162 context_->GetContextSupport())); 163 context_->GetContextSupport()));
163 } 164 }
164 } 165 }
165 166
166 void GLHelperHolder::onContextLost() { 167 void GLHelperHolder::onContextLost() {
167 // Need to post a task because the command buffer client cannot be deleted 168 // Need to post a task because the command buffer client cannot be deleted
168 // from within this callback. 169 // from within this callback.
169 LOG(ERROR) << "Context lost."; 170 LOG(ERROR) << "Context lost.";
170 base::MessageLoop::current()->PostTask( 171 base::MessageLoop::current()->PostTask(
171 FROM_HERE, 172 FROM_HERE,
172 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); 173 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost));
173 } 174 }
174 175
175 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 176 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
176 GLHelperHolder::CreateContext3D() { 177 GLHelperHolder::CreateContext3D(gfx::NativeWindow native_window) {
177 BrowserGpuChannelHostFactory* factory = 178 BrowserGpuChannelHostFactory* factory =
178 BrowserGpuChannelHostFactory::instance(); 179 BrowserGpuChannelHostFactory::instance();
179 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); 180 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel());
180 // GLHelper can only be used in asynchronous APIs for postprocessing after 181 // GLHelper can only be used in asynchronous APIs for postprocessing after
181 // Browser Compositor operations (i.e. readback). 182 // Browser Compositor operations (i.e. readback).
182 if (!gpu_channel_host.get()) { 183 if (!gpu_channel_host.get()) {
183 // The Browser Compositor is in charge of reestablishing the channel. 184 // The Browser Compositor is in charge of reestablishing the channel.
184 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 185 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
185 } 186 }
186 187
187 blink::WebGraphicsContext3D::Attributes attrs; 188 blink::WebGraphicsContext3D::Attributes attrs;
188 attrs.shareResources = true; 189 attrs.shareResources = true;
189 GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); 190 GURL url("chrome://gpu/RenderWidgetHostViewAndroid");
190 static const size_t kBytesPerPixel = 4; 191 static const size_t kBytesPerPixel = 4;
191 gfx::DeviceDisplayInfo display_info; 192 const gfx::DeviceDisplayInfo& display_info =
193 native_window->GetDeviceDisplayInfo();
192 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() * 194 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
193 display_info.GetDisplayWidth() * 195 display_info.GetDisplayWidth() *
194 kBytesPerPixel; 196 kBytesPerPixel;
195 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 197 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
196 limits.command_buffer_size = 64 * 1024; 198 limits.command_buffer_size = 64 * 1024;
197 limits.start_transfer_buffer_size = 64 * 1024; 199 limits.start_transfer_buffer_size = 64 * 1024;
198 limits.min_transfer_buffer_size = 64 * 1024; 200 limits.min_transfer_buffer_size = 64 * 1024;
199 limits.max_transfer_buffer_size = std::min( 201 limits.max_transfer_buffer_size = std::min(
200 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); 202 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize);
201 limits.mapped_memory_reclaim_limit = 203 limits.mapped_memory_reclaim_limit =
(...skipping 12 matching lines...) Expand all
214 context.get()).c_str()); 216 context.get()).c_str());
215 } else { 217 } else {
216 context.reset(); 218 context.reset();
217 } 219 }
218 220
219 return context.Pass(); 221 return context.Pass();
220 } 222 }
221 223
222 // This can only be used for readback postprocessing. It may return null if the 224 // This can only be used for readback postprocessing. It may return null if the
223 // channel was lost and not reestablished yet. 225 // channel was lost and not reestablished yet.
224 GLHelper* GetPostReadbackGLHelper() { 226 GLHelper* GetPostReadbackGLHelper(gfx::NativeWindow native_window) {
225 static GLHelperHolder* g_readback_helper_holder = nullptr; 227 static GLHelperHolder* g_readback_helper_holder = nullptr;
226 228
227 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { 229 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
228 delete g_readback_helper_holder; 230 delete g_readback_helper_holder;
229 g_readback_helper_holder = nullptr; 231 g_readback_helper_holder = nullptr;
230 } 232 }
231 233
232 if (!g_readback_helper_holder) 234 if (!g_readback_helper_holder)
233 g_readback_helper_holder = GLHelperHolder::Create(); 235 g_readback_helper_holder = GLHelperHolder::Create(native_window);
234 236
235 return g_readback_helper_holder->GetGLHelper(); 237 return g_readback_helper_holder->GetGLHelper();
236 } 238 }
237 239
238 void CopyFromCompositingSurfaceFinished( 240 void CopyFromCompositingSurfaceFinished(
239 const ReadbackRequestCallback& callback, 241 const ReadbackRequestCallback& callback,
240 scoped_ptr<cc::SingleReleaseCallback> release_callback, 242 scoped_ptr<cc::SingleReleaseCallback> release_callback,
241 scoped_ptr<SkBitmap> bitmap, 243 scoped_ptr<SkBitmap> bitmap,
242 const base::TimeTicks& start_time, 244 const base::TimeTicks& start_time,
243 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 245 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
246 gfx::NativeWindow native_window,
244 bool result) { 247 bool result) {
245 TRACE_EVENT0( 248 TRACE_EVENT0(
246 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); 249 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished");
247 bitmap_pixels_lock.reset(); 250 bitmap_pixels_lock.reset();
248 uint32 sync_point = 0; 251 uint32 sync_point = 0;
249 if (result) { 252 if (result) {
250 GLHelper* gl_helper = GetPostReadbackGLHelper(); 253 GLHelper* gl_helper = GetPostReadbackGLHelper(native_window);
251 if (gl_helper) 254 if (gl_helper)
252 sync_point = gl_helper->InsertSyncPoint(); 255 sync_point = gl_helper->InsertSyncPoint();
253 } 256 }
254 bool lost_resource = sync_point == 0; 257 bool lost_resource = sync_point == 0;
255 release_callback->Run(sync_point, lost_resource); 258 release_callback->Run(sync_point, lost_resource);
256 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, 259 UMA_HISTOGRAM_TIMES(kAsyncReadBackString,
257 base::TimeTicks::Now() - start_time); 260 base::TimeTicks::Now() - start_time);
258 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; 261 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED;
259 callback.Run(*bitmap, response); 262 callback.Run(*bitmap, response);
260 } 263 }
(...skipping 25 matching lines...) Expand all
286 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { 289 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
287 gfx::RectF rect = controller.GetRectBetweenBounds(); 290 gfx::RectF rect = controller.GetRectBetweenBounds();
288 if (rect.IsEmpty()) 291 if (rect.IsEmpty())
289 return rect; 292 return rect;
290 293
291 rect.Union(controller.GetStartHandleRect()); 294 rect.Union(controller.GetStartHandleRect());
292 rect.Union(controller.GetEndHandleRect()); 295 rect.Union(controller.GetEndHandleRect());
293 return rect; 296 return rect;
294 } 297 }
295 298
299 void DisplayInfoToScreenInfo(const gfx::Display& display,
300 const gfx::DeviceDisplayInfo& info,
301 blink::WebScreenInfo* results) {
302 results->rect = display.bounds();
303 // TODO(husky): Remove any system controls from availableRect.
304 results->availableRect = display.work_area();
305 results->deviceScaleFactor = display.device_scale_factor();
306 results->orientationAngle = display.RotationAsDegree();
307 results->orientationType =
308 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
309 results->depth = info.GetBitsPerPixel();
310 results->depthPerComponent = info.GetBitsPerComponent();
311 results->isMonochrome = (results->depthPerComponent == 0);
312 }
313
296 } // anonymous namespace 314 } // anonymous namespace
297 315
298 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( 316 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo(
299 uint32 output_id, 317 uint32 output_id,
300 scoped_ptr<cc::CompositorFrame> output_frame) 318 scoped_ptr<cc::CompositorFrame> output_frame)
301 : output_surface_id(output_id), frame(output_frame.Pass()) {} 319 : output_surface_id(output_id), frame(output_frame.Pass()) {}
302 320
303 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} 321 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {}
304 322
305 void RenderWidgetHostViewAndroid::OnContextLost() { 323 void RenderWidgetHostViewAndroid::OnContextLost() {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); 919 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer();
902 DCHECK(layer); 920 DCHECK(layer);
903 layer->SetHideLayerAndSubtree(true); 921 layer->SetHideLayerAndSubtree(true);
904 compositor->AttachLayerForReadback(layer); 922 compositor->AttachLayerForReadback(layer);
905 923
906 readback_layer = layer; 924 readback_layer = layer;
907 request = cc::CopyOutputRequest::CreateRequest( 925 request = cc::CopyOutputRequest::CreateRequest(
908 base::Bind(&RenderWidgetHostViewAndroid:: 926 base::Bind(&RenderWidgetHostViewAndroid::
909 PrepareTextureCopyOutputResultForDelegatedReadback, 927 PrepareTextureCopyOutputResultForDelegatedReadback,
910 dst_size_in_pixel, preferred_color_type, start_time, 928 dst_size_in_pixel, preferred_color_type, start_time,
911 readback_layer, callback)); 929 readback_layer, callback, content_view_core_window_android_));
912 if (!src_subrect_in_pixel.IsEmpty()) 930 if (!src_subrect_in_pixel.IsEmpty())
913 request->set_area(src_subrect_in_pixel); 931 request->set_area(src_subrect_in_pixel);
914 readback_layer->RequestCopyOfOutput(request.Pass()); 932 readback_layer->RequestCopyOfOutput(request.Pass());
915 } 933 }
916 934
917 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 935 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
918 const gfx::Rect& src_subrect, 936 const gfx::Rect& src_subrect,
919 const scoped_refptr<media::VideoFrame>& target, 937 const scoped_refptr<media::VideoFrame>& target,
920 const base::Callback<void(bool)>& callback) { 938 const base::Callback<void(bool)>& callback) {
921 NOTIMPLEMENTED(); 939 NOTIMPLEMENTED();
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 DestroyDelegatedContent(); 1557 DestroyDelegatedContent();
1540 frame_evictor_->DiscardedFrame(); 1558 frame_evictor_->DiscardedFrame();
1541 } 1559 }
1542 1560
1543 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 1561 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
1544 const gfx::Size& desired_size) { 1562 const gfx::Size& desired_size) {
1545 NOTREACHED(); 1563 NOTREACHED();
1546 return false; 1564 return false;
1547 } 1565 }
1548 1566
1549 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { 1567 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) {
1550 // ScreenInfo isn't tied to the widget on Android. Always return the default. 1568 if (content_view_core_) {
1551 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); 1569 gfx::NativeView view_android = GetNativeView();
1570
1571 const gfx::Display& display =
1572 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view_android);
1573 const gfx::DeviceDisplayInfo& info =
1574 content_view_core_window_android_->GetDeviceDisplayInfo();
1575 DisplayInfoToScreenInfo(display, info, results);
1576 } else {
1577 GetDefaultScreenInfo(results);
1578 }
1552 } 1579 }
1553 1580
1554 bool RenderWidgetHostViewAndroid::GetScreenColorProfile( 1581 bool RenderWidgetHostViewAndroid::GetScreenColorProfile(
1555 std::vector<char>* color_profile) { 1582 std::vector<char>* color_profile) {
1556 DCHECK(color_profile->empty()); 1583 DCHECK(color_profile->empty());
1557 NOTREACHED(); 1584 NOTREACHED();
1558 return false; 1585 return false;
1559 } 1586 }
1560 1587
1561 // TODO(jrg): Find out the implications and answer correctly here, 1588 // TODO(jrg): Find out the implications and answer correctly here,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 } 1953 }
1927 1954
1928 // static 1955 // static
1929 void RenderWidgetHostViewAndroid:: 1956 void RenderWidgetHostViewAndroid::
1930 PrepareTextureCopyOutputResultForDelegatedReadback( 1957 PrepareTextureCopyOutputResultForDelegatedReadback(
1931 const gfx::Size& dst_size_in_pixel, 1958 const gfx::Size& dst_size_in_pixel,
1932 SkColorType color_type, 1959 SkColorType color_type,
1933 const base::TimeTicks& start_time, 1960 const base::TimeTicks& start_time,
1934 scoped_refptr<cc::Layer> readback_layer, 1961 scoped_refptr<cc::Layer> readback_layer,
1935 const ReadbackRequestCallback& callback, 1962 const ReadbackRequestCallback& callback,
1963 gfx::NativeWindow native_window,
1936 scoped_ptr<cc::CopyOutputResult> result) { 1964 scoped_ptr<cc::CopyOutputResult> result) {
1937 readback_layer->RemoveFromParent(); 1965 readback_layer->RemoveFromParent();
1938 PrepareTextureCopyOutputResult( 1966 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
1939 dst_size_in_pixel, color_type, start_time, callback, result.Pass()); 1967 callback, native_window, result.Pass());
1940 } 1968 }
1941 1969
1942 // static 1970 // static
1943 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1971 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1944 const gfx::Size& dst_size_in_pixel, 1972 const gfx::Size& dst_size_in_pixel,
1945 SkColorType color_type, 1973 SkColorType color_type,
1946 const base::TimeTicks& start_time, 1974 const base::TimeTicks& start_time,
1947 const ReadbackRequestCallback& callback, 1975 const ReadbackRequestCallback& callback,
1976 gfx::NativeWindow native_window,
1948 scoped_ptr<cc::CopyOutputResult> result) { 1977 scoped_ptr<cc::CopyOutputResult> result) {
1949 base::ScopedClosureRunner scoped_callback_runner( 1978 base::ScopedClosureRunner scoped_callback_runner(
1950 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1979 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1951 TRACE_EVENT0("cc", 1980 TRACE_EVENT0("cc",
1952 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1981 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1953 1982
1954 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1983 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1955 return; 1984 return;
1956 1985
1957 gfx::Size output_size_in_pixel; 1986 gfx::Size output_size_in_pixel;
1958 if (dst_size_in_pixel.IsEmpty()) 1987 if (dst_size_in_pixel.IsEmpty())
1959 output_size_in_pixel = result->size(); 1988 output_size_in_pixel = result->size();
1960 else 1989 else
1961 output_size_in_pixel = dst_size_in_pixel; 1990 output_size_in_pixel = dst_size_in_pixel;
1962 1991
1963 GLHelper* gl_helper = GetPostReadbackGLHelper(); 1992 GLHelper* gl_helper = GetPostReadbackGLHelper(native_window);
1964 if (!gl_helper) 1993 if (!gl_helper)
1965 return; 1994 return;
1966 if (!gl_helper->IsReadbackConfigSupported(color_type)) 1995 if (!gl_helper->IsReadbackConfigSupported(color_type))
1967 color_type = kRGBA_8888_SkColorType; 1996 color_type = kRGBA_8888_SkColorType;
1968 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 1997 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
1969 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 1998 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(),
1970 output_size_in_pixel.height(), 1999 output_size_in_pixel.height(),
1971 color_type, 2000 color_type,
1972 kOpaque_SkAlphaType))) { 2001 kOpaque_SkAlphaType))) {
1973 scoped_callback_runner.Reset( 2002 scoped_callback_runner.Reset(
1974 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); 2003 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE));
1975 return; 2004 return;
1976 } 2005 }
1977 2006
1978 2007
1979 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 2008 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
1980 new SkAutoLockPixels(*bitmap)); 2009 new SkAutoLockPixels(*bitmap));
1981 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 2010 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
1982 2011
1983 cc::TextureMailbox texture_mailbox; 2012 cc::TextureMailbox texture_mailbox;
1984 scoped_ptr<cc::SingleReleaseCallback> release_callback; 2013 scoped_ptr<cc::SingleReleaseCallback> release_callback;
1985 result->TakeTexture(&texture_mailbox, &release_callback); 2014 result->TakeTexture(&texture_mailbox, &release_callback);
1986 DCHECK(texture_mailbox.IsTexture()); 2015 DCHECK(texture_mailbox.IsTexture());
1987 if (!texture_mailbox.IsTexture()) 2016 if (!texture_mailbox.IsTexture())
1988 return; 2017 return;
1989 2018
1990 ignore_result(scoped_callback_runner.Release()); 2019 ignore_result(scoped_callback_runner.Release());
1991 2020
1992 gl_helper->CropScaleReadbackAndCleanMailbox( 2021 gl_helper->CropScaleReadbackAndCleanMailbox(
1993 texture_mailbox.mailbox(), 2022 texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(),
1994 texture_mailbox.sync_point(), 2023 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
1995 result->size(), 2024 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
1996 gfx::Rect(result->size()), 2025 base::Passed(&release_callback), base::Passed(&bitmap),
1997 output_size_in_pixel, 2026 start_time, base::Passed(&bitmap_pixels_lock), native_window),
jdduke (slow) 2015/10/22 15:37:05 sievers@ is it safe to bind this pointer? I know W
no sievers 2015/10/26 20:42:25 No this is actually not safe, since the pointer is
gsennton 2015/10/27 11:40:24 Since all we need from the window_android pointer
1998 pixels,
1999 color_type,
2000 base::Bind(&CopyFromCompositingSurfaceFinished,
2001 callback,
2002 base::Passed(&release_callback),
2003 base::Passed(&bitmap),
2004 start_time,
2005 base::Passed(&bitmap_pixels_lock)),
2006 GLHelper::SCALER_QUALITY_GOOD); 2027 GLHelper::SCALER_QUALITY_GOOD);
2007 } 2028 }
2008 2029
2009 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 2030 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
2010 float y0, 2031 float y0,
2011 float x1, 2032 float x1,
2012 float y1) { 2033 float y1) {
2013 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 2034 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
2014 } 2035 }
2015 2036
(...skipping 15 matching lines...) Expand all
2031 blink::WebInputEvent::GestureLongPress, 2052 blink::WebInputEvent::GestureLongPress,
2032 (time - base::TimeTicks()).InSecondsF(), x, y); 2053 (time - base::TimeTicks()).InSecondsF(), x, y);
2033 SendGestureEvent(long_press); 2054 SendGestureEvent(long_press);
2034 } 2055 }
2035 2056
2036 // static 2057 // static
2037 void RenderWidgetHostViewBase::GetDefaultScreenInfo( 2058 void RenderWidgetHostViewBase::GetDefaultScreenInfo(
2038 blink::WebScreenInfo* results) { 2059 blink::WebScreenInfo* results) {
2039 const gfx::Display& display = 2060 const gfx::Display& display =
2040 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 2061 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
2041 results->rect = display.bounds();
2042 // TODO(husky): Remove any system controls from availableRect.
2043 results->availableRect = display.work_area();
2044 results->deviceScaleFactor = display.device_scale_factor();
2045 results->orientationAngle = display.RotationAsDegree();
2046 results->orientationType =
2047 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2048 gfx::DeviceDisplayInfo info; 2062 gfx::DeviceDisplayInfo info;
2049 results->depth = info.GetBitsPerPixel(); 2063 DisplayInfoToScreenInfo(display, info, results);
2050 results->depthPerComponent = info.GetBitsPerComponent();
2051 results->isMonochrome = (results->depthPerComponent == 0);
2052 } 2064 }
2053 2065
2054 } // namespace content 2066 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | ui/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698