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

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

Issue 1144333004: Make WebView work for external displays (over Presentations). Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another context-use through making WindowAndroid::GetJavaContext public Created 5 years, 5 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 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 118 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
119 119
120 // Sends an acknowledgement to the renderer of a processed IME event. 120 // Sends an acknowledgement to the renderer of a processed IME event.
121 void SendImeEventAck(RenderWidgetHostImpl* host) { 121 void SendImeEventAck(RenderWidgetHostImpl* host) {
122 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID())); 122 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID()));
123 } 123 }
124 124
125 class GLHelperHolder 125 class GLHelperHolder
126 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { 126 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
127 public: 127 public:
128 static GLHelperHolder* Create(); 128 static GLHelperHolder* Create(gfx::NativeWindow nativeWindow);
jdduke (slow) 2015/07/15 16:03:07 Again, I wonder if it would improve readability to
129 ~GLHelperHolder() override; 129 ~GLHelperHolder() override;
130 130
131 void Initialize(); 131 void Initialize(gfx::NativeWindow nativeWindow);
132 132
133 // WebGraphicsContextLostCallback implementation. 133 // WebGraphicsContextLostCallback implementation.
134 void onContextLost() override; 134 void onContextLost() override;
135 135
136 GLHelper* GetGLHelper() { return gl_helper_.get(); } 136 GLHelper* GetGLHelper() { return gl_helper_.get(); }
137 bool IsLost() { return !context_.get() || context_->isContextLost(); } 137 bool IsLost() { return !context_.get() || context_->isContextLost(); }
138 138
139 private: 139 private:
140 GLHelperHolder(); 140 GLHelperHolder();
141 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); 141 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(
142 gfx::NativeWindow nativeWindow);
142 143
143 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; 144 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
144 scoped_ptr<GLHelper> gl_helper_; 145 scoped_ptr<GLHelper> gl_helper_;
145 146
146 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); 147 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder);
147 }; 148 };
148 149
149 GLHelperHolder* GLHelperHolder::Create() { 150 GLHelperHolder* GLHelperHolder::Create(gfx::NativeWindow nativeWindow) {
150 GLHelperHolder* holder = new GLHelperHolder; 151 GLHelperHolder* holder = new GLHelperHolder;
151 holder->Initialize(); 152 holder->Initialize(nativeWindow);
152 153
153 return holder; 154 return holder;
154 } 155 }
155 156
156 GLHelperHolder::GLHelperHolder() { 157 GLHelperHolder::GLHelperHolder() {
157 } 158 }
158 159
159 GLHelperHolder::~GLHelperHolder() { 160 GLHelperHolder::~GLHelperHolder() {
160 } 161 }
161 162
162 void GLHelperHolder::Initialize() { 163 void GLHelperHolder::Initialize(gfx::NativeWindow nativeWindow) {
163 context_ = CreateContext3D(); 164 context_ = CreateContext3D(nativeWindow);
164 if (context_) { 165 if (context_) {
165 context_->setContextLostCallback(this); 166 context_->setContextLostCallback(this);
166 gl_helper_.reset(new GLHelper(context_->GetImplementation(), 167 gl_helper_.reset(new GLHelper(context_->GetImplementation(),
167 context_->GetContextSupport())); 168 context_->GetContextSupport()));
168 } 169 }
169 } 170 }
170 171
171 void GLHelperHolder::onContextLost() { 172 void GLHelperHolder::onContextLost() {
172 // Need to post a task because the command buffer client cannot be deleted 173 // Need to post a task because the command buffer client cannot be deleted
173 // from within this callback. 174 // from within this callback.
174 LOG(ERROR) << "Context lost."; 175 LOG(ERROR) << "Context lost.";
175 base::MessageLoop::current()->PostTask( 176 base::MessageLoop::current()->PostTask(
176 FROM_HERE, 177 FROM_HERE,
177 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); 178 base::Bind(&RenderWidgetHostViewAndroid::OnContextLost));
178 } 179 }
179 180
180 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 181 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
181 GLHelperHolder::CreateContext3D() { 182 GLHelperHolder::CreateContext3D(gfx::NativeWindow nativeWindow) {
182 BrowserGpuChannelHostFactory* factory = 183 BrowserGpuChannelHostFactory* factory =
183 BrowserGpuChannelHostFactory::instance(); 184 BrowserGpuChannelHostFactory::instance();
184 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); 185 scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel());
185 // GLHelper can only be used in asynchronous APIs for postprocessing after 186 // GLHelper can only be used in asynchronous APIs for postprocessing after
186 // Browser Compositor operations (i.e. readback). 187 // Browser Compositor operations (i.e. readback).
187 if (!gpu_channel_host.get()) { 188 if (!gpu_channel_host.get()) {
188 // The Browser Compositor is in charge of reestablishing the channel. 189 // The Browser Compositor is in charge of reestablishing the channel.
189 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 190 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
190 } 191 }
191 192
192 blink::WebGraphicsContext3D::Attributes attrs; 193 blink::WebGraphicsContext3D::Attributes attrs;
193 attrs.shareResources = true; 194 attrs.shareResources = true;
194 GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); 195 GURL url("chrome://gpu/RenderWidgetHostViewAndroid");
195 static const size_t kBytesPerPixel = 4; 196 static const size_t kBytesPerPixel = 4;
196 gfx::DeviceDisplayInfo display_info; 197 const gfx::DeviceDisplayInfo& display_info =
198 nativeWindow->GetDeviceDisplayInfo();
197 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() * 199 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
198 display_info.GetDisplayWidth() * 200 display_info.GetDisplayWidth() *
199 kBytesPerPixel; 201 kBytesPerPixel;
200 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 202 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
201 limits.command_buffer_size = 64 * 1024; 203 limits.command_buffer_size = 64 * 1024;
202 limits.start_transfer_buffer_size = 64 * 1024; 204 limits.start_transfer_buffer_size = 64 * 1024;
203 limits.min_transfer_buffer_size = 64 * 1024; 205 limits.min_transfer_buffer_size = 64 * 1024;
204 limits.max_transfer_buffer_size = std::min( 206 limits.max_transfer_buffer_size = std::min(
205 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); 207 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize);
206 limits.mapped_memory_reclaim_limit = 208 limits.mapped_memory_reclaim_limit =
(...skipping 12 matching lines...) Expand all
219 context.get()).c_str()); 221 context.get()).c_str());
220 } else { 222 } else {
221 context.reset(); 223 context.reset();
222 } 224 }
223 225
224 return context.Pass(); 226 return context.Pass();
225 } 227 }
226 228
227 // This can only be used for readback postprocessing. It may return null if the 229 // This can only be used for readback postprocessing. It may return null if the
228 // channel was lost and not reestablished yet. 230 // channel was lost and not reestablished yet.
229 GLHelper* GetPostReadbackGLHelper() { 231 GLHelper* GetPostReadbackGLHelper(gfx::NativeWindow nativeWindow) {
230 static GLHelperHolder* g_readback_helper_holder = nullptr; 232 static GLHelperHolder* g_readback_helper_holder = nullptr;
231 233
232 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { 234 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
233 delete g_readback_helper_holder; 235 delete g_readback_helper_holder;
234 g_readback_helper_holder = nullptr; 236 g_readback_helper_holder = nullptr;
235 } 237 }
236 238
237 if (!g_readback_helper_holder) 239 if (!g_readback_helper_holder)
238 g_readback_helper_holder = GLHelperHolder::Create(); 240 g_readback_helper_holder = GLHelperHolder::Create(nativeWindow);
239 241
240 return g_readback_helper_holder->GetGLHelper(); 242 return g_readback_helper_holder->GetGLHelper();
241 } 243 }
242 244
243 void CopyFromCompositingSurfaceFinished( 245 void CopyFromCompositingSurfaceFinished(
244 ReadbackRequestCallback& callback, 246 ReadbackRequestCallback& callback,
245 scoped_ptr<cc::SingleReleaseCallback> release_callback, 247 scoped_ptr<cc::SingleReleaseCallback> release_callback,
246 scoped_ptr<SkBitmap> bitmap, 248 scoped_ptr<SkBitmap> bitmap,
247 const base::TimeTicks& start_time, 249 const base::TimeTicks& start_time,
248 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 250 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
251 gfx::NativeWindow nativeWindow,
249 bool result) { 252 bool result) {
250 TRACE_EVENT0( 253 TRACE_EVENT0(
251 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); 254 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished");
252 bitmap_pixels_lock.reset(); 255 bitmap_pixels_lock.reset();
253 uint32 sync_point = 0; 256 uint32 sync_point = 0;
254 if (result) { 257 if (result) {
255 GLHelper* gl_helper = GetPostReadbackGLHelper(); 258 GLHelper* gl_helper = GetPostReadbackGLHelper(nativeWindow);
256 if (gl_helper) 259 if (gl_helper)
257 sync_point = gl_helper->InsertSyncPoint(); 260 sync_point = gl_helper->InsertSyncPoint();
258 } 261 }
259 bool lost_resource = sync_point == 0; 262 bool lost_resource = sync_point == 0;
260 release_callback->Run(sync_point, lost_resource); 263 release_callback->Run(sync_point, lost_resource);
261 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, 264 UMA_HISTOGRAM_TIMES(kAsyncReadBackString,
262 base::TimeTicks::Now() - start_time); 265 base::TimeTicks::Now() - start_time);
263 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; 266 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED;
264 callback.Run(*bitmap, response); 267 callback.Run(*bitmap, response);
265 } 268 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { 300 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
298 gfx::RectF rect = controller.GetRectBetweenBounds(); 301 gfx::RectF rect = controller.GetRectBetweenBounds();
299 if (rect.IsEmpty()) 302 if (rect.IsEmpty())
300 return rect; 303 return rect;
301 304
302 rect.Union(controller.GetStartHandleRect()); 305 rect.Union(controller.GetStartHandleRect());
303 rect.Union(controller.GetEndHandleRect()); 306 rect.Union(controller.GetEndHandleRect());
304 return rect; 307 return rect;
305 } 308 }
306 309
310 void DisplayInfoToScreenInfo(const gfx::Display& display,
311 const gfx::DeviceDisplayInfo& info,
312 blink::WebScreenInfo* results) {
313 results->rect = display.bounds();
314 // TODO(husky): Remove any system controls from availableRect.
315 results->availableRect = display.work_area();
316 results->deviceScaleFactor = display.device_scale_factor();
317 results->orientationAngle = display.RotationAsDegree();
318 results->orientationType =
319 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
320 results->depth = info.GetBitsPerPixel();
321 results->depthPerComponent = info.GetBitsPerComponent();
322 results->isMonochrome = (results->depthPerComponent == 0);
323 }
324
307 } // anonymous namespace 325 } // anonymous namespace
308 326
309 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( 327 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo(
310 uint32 output_id, 328 uint32 output_id,
311 scoped_ptr<cc::CompositorFrame> output_frame) 329 scoped_ptr<cc::CompositorFrame> output_frame)
312 : output_surface_id(output_id), frame(output_frame.Pass()) {} 330 : output_surface_id(output_id), frame(output_frame.Pass()) {}
313 331
314 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} 332 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {}
315 333
316 void RenderWidgetHostViewAndroid::OnContextLost() { 334 void RenderWidgetHostViewAndroid::OnContextLost() {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); 945 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer();
928 DCHECK(layer); 946 DCHECK(layer);
929 layer->SetHideLayerAndSubtree(true); 947 layer->SetHideLayerAndSubtree(true);
930 compositor->AttachLayerForReadback(layer); 948 compositor->AttachLayerForReadback(layer);
931 949
932 readback_layer = layer; 950 readback_layer = layer;
933 request = cc::CopyOutputRequest::CreateRequest( 951 request = cc::CopyOutputRequest::CreateRequest(
934 base::Bind(&RenderWidgetHostViewAndroid:: 952 base::Bind(&RenderWidgetHostViewAndroid::
935 PrepareTextureCopyOutputResultForDelegatedReadback, 953 PrepareTextureCopyOutputResultForDelegatedReadback,
936 dst_size_in_pixel, preferred_color_type, start_time, 954 dst_size_in_pixel, preferred_color_type, start_time,
937 readback_layer, callback)); 955 readback_layer, callback, content_view_core_window_android_));
938 if (!src_subrect_in_pixel.IsEmpty()) 956 if (!src_subrect_in_pixel.IsEmpty())
939 request->set_area(src_subrect_in_pixel); 957 request->set_area(src_subrect_in_pixel);
940 readback_layer->RequestCopyOfOutput(request.Pass()); 958 readback_layer->RequestCopyOfOutput(request.Pass());
941 } 959 }
942 960
943 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 961 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
944 const gfx::Rect& src_subrect, 962 const gfx::Rect& src_subrect,
945 const scoped_refptr<media::VideoFrame>& target, 963 const scoped_refptr<media::VideoFrame>& target,
946 const base::Callback<void(bool)>& callback) { 964 const base::Callback<void(bool)>& callback) {
947 NOTIMPLEMENTED(); 965 NOTIMPLEMENTED();
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 DestroyDelegatedContent(); 1561 DestroyDelegatedContent();
1544 frame_evictor_->DiscardedFrame(); 1562 frame_evictor_->DiscardedFrame();
1545 } 1563 }
1546 1564
1547 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 1565 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
1548 const gfx::Size& desired_size) { 1566 const gfx::Size& desired_size) {
1549 NOTREACHED(); 1567 NOTREACHED();
1550 return false; 1568 return false;
1551 } 1569 }
1552 1570
1553 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { 1571 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) {
1554 // ScreenInfo isn't tied to the widget on Android. Always return the default. 1572 if (content_view_core_) {
1555 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); 1573 gfx::NativeView view_android = GetNativeView();
1574
1575 const gfx::Display& display =
1576 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view_android);
1577 const gfx::DeviceDisplayInfo& info =
1578 content_view_core_window_android_->GetDeviceDisplayInfo();
1579 DisplayInfoToScreenInfo(display, info, results);
1580 } else {
1581 GetDefaultScreenInfo(results);
1582 }
1556 } 1583 }
1557 1584
1558 // TODO(jrg): Find out the implications and answer correctly here, 1585 // TODO(jrg): Find out the implications and answer correctly here,
1559 // as we are returning the WebView and not root window bounds. 1586 // as we are returning the WebView and not root window bounds.
1560 gfx::Rect RenderWidgetHostViewAndroid::GetBoundsInRootWindow() { 1587 gfx::Rect RenderWidgetHostViewAndroid::GetBoundsInRootWindow() {
1561 return GetViewBounds(); 1588 return GetViewBounds();
1562 } 1589 }
1563 1590
1564 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { 1591 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() {
1565 gfx::GLSurfaceHandle handle = 1592 gfx::GLSurfaceHandle handle =
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 } 1955 }
1929 1956
1930 // static 1957 // static
1931 void RenderWidgetHostViewAndroid:: 1958 void RenderWidgetHostViewAndroid::
1932 PrepareTextureCopyOutputResultForDelegatedReadback( 1959 PrepareTextureCopyOutputResultForDelegatedReadback(
1933 const gfx::Size& dst_size_in_pixel, 1960 const gfx::Size& dst_size_in_pixel,
1934 SkColorType color_type, 1961 SkColorType color_type,
1935 const base::TimeTicks& start_time, 1962 const base::TimeTicks& start_time,
1936 scoped_refptr<cc::Layer> readback_layer, 1963 scoped_refptr<cc::Layer> readback_layer,
1937 ReadbackRequestCallback& callback, 1964 ReadbackRequestCallback& callback,
1965 gfx::NativeWindow nativeWindow,
1938 scoped_ptr<cc::CopyOutputResult> result) { 1966 scoped_ptr<cc::CopyOutputResult> result) {
1939 readback_layer->RemoveFromParent(); 1967 readback_layer->RemoveFromParent();
1940 PrepareTextureCopyOutputResult( 1968 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
1941 dst_size_in_pixel, color_type, start_time, callback, result.Pass()); 1969 callback, nativeWindow, result.Pass());
1942 } 1970 }
1943 1971
1944 // static 1972 // static
1945 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1973 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1946 const gfx::Size& dst_size_in_pixel, 1974 const gfx::Size& dst_size_in_pixel,
1947 SkColorType color_type, 1975 SkColorType color_type,
1948 const base::TimeTicks& start_time, 1976 const base::TimeTicks& start_time,
1949 ReadbackRequestCallback& callback, 1977 ReadbackRequestCallback& callback,
1978 gfx::NativeWindow nativeWindow,
1950 scoped_ptr<cc::CopyOutputResult> result) { 1979 scoped_ptr<cc::CopyOutputResult> result) {
1951 base::ScopedClosureRunner scoped_callback_runner( 1980 base::ScopedClosureRunner scoped_callback_runner(
1952 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1981 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1953 TRACE_EVENT0("cc", 1982 TRACE_EVENT0("cc",
1954 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1983 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1955 1984
1956 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1985 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1957 return; 1986 return;
1958 1987
1959 gfx::Size output_size_in_pixel; 1988 gfx::Size output_size_in_pixel;
1960 if (dst_size_in_pixel.IsEmpty()) 1989 if (dst_size_in_pixel.IsEmpty())
1961 output_size_in_pixel = result->size(); 1990 output_size_in_pixel = result->size();
1962 else 1991 else
1963 output_size_in_pixel = dst_size_in_pixel; 1992 output_size_in_pixel = dst_size_in_pixel;
1964 1993
1965 GLHelper* gl_helper = GetPostReadbackGLHelper(); 1994 GLHelper* gl_helper = GetPostReadbackGLHelper(nativeWindow);
1966 if (!gl_helper) 1995 if (!gl_helper)
1967 return; 1996 return;
1968 if (!gl_helper->IsReadbackConfigSupported(color_type)) 1997 if (!gl_helper->IsReadbackConfigSupported(color_type))
1969 color_type = kRGBA_8888_SkColorType; 1998 color_type = kRGBA_8888_SkColorType;
1970 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 1999 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
1971 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 2000 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(),
1972 output_size_in_pixel.height(), 2001 output_size_in_pixel.height(),
1973 color_type, 2002 color_type,
1974 kOpaque_SkAlphaType))) { 2003 kOpaque_SkAlphaType))) {
1975 scoped_callback_runner.Reset( 2004 scoped_callback_runner.Reset(
1976 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); 2005 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE));
1977 return; 2006 return;
1978 } 2007 }
1979 2008
1980 2009
1981 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 2010 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
1982 new SkAutoLockPixels(*bitmap)); 2011 new SkAutoLockPixels(*bitmap));
1983 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 2012 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
1984 2013
1985 cc::TextureMailbox texture_mailbox; 2014 cc::TextureMailbox texture_mailbox;
1986 scoped_ptr<cc::SingleReleaseCallback> release_callback; 2015 scoped_ptr<cc::SingleReleaseCallback> release_callback;
1987 result->TakeTexture(&texture_mailbox, &release_callback); 2016 result->TakeTexture(&texture_mailbox, &release_callback);
1988 DCHECK(texture_mailbox.IsTexture()); 2017 DCHECK(texture_mailbox.IsTexture());
1989 if (!texture_mailbox.IsTexture()) 2018 if (!texture_mailbox.IsTexture())
1990 return; 2019 return;
1991 2020
1992 ignore_result(scoped_callback_runner.Release()); 2021 ignore_result(scoped_callback_runner.Release());
1993 2022
1994 gl_helper->CropScaleReadbackAndCleanMailbox( 2023 gl_helper->CropScaleReadbackAndCleanMailbox(
1995 texture_mailbox.mailbox(), 2024 texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(),
1996 texture_mailbox.sync_point(), 2025 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
1997 result->size(), 2026 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
1998 gfx::Rect(result->size()), 2027 base::Passed(&release_callback), base::Passed(&bitmap),
1999 output_size_in_pixel, 2028 start_time, base::Passed(&bitmap_pixels_lock), nativeWindow),
2000 pixels,
2001 color_type,
2002 base::Bind(&CopyFromCompositingSurfaceFinished,
2003 callback,
2004 base::Passed(&release_callback),
2005 base::Passed(&bitmap),
2006 start_time,
2007 base::Passed(&bitmap_pixels_lock)),
2008 GLHelper::SCALER_QUALITY_GOOD); 2029 GLHelper::SCALER_QUALITY_GOOD);
2009 } 2030 }
2010 2031
2011 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 2032 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
2012 float y0, 2033 float y0,
2013 float x1, 2034 float x1,
2014 float y1) { 2035 float y1) {
2015 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 2036 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
2016 } 2037 }
2017 2038
(...skipping 15 matching lines...) Expand all
2033 blink::WebInputEvent::GestureLongPress, 2054 blink::WebInputEvent::GestureLongPress,
2034 (time - base::TimeTicks()).InSecondsF(), x, y); 2055 (time - base::TimeTicks()).InSecondsF(), x, y);
2035 SendGestureEvent(long_press); 2056 SendGestureEvent(long_press);
2036 } 2057 }
2037 2058
2038 // static 2059 // static
2039 void RenderWidgetHostViewBase::GetDefaultScreenInfo( 2060 void RenderWidgetHostViewBase::GetDefaultScreenInfo(
2040 blink::WebScreenInfo* results) { 2061 blink::WebScreenInfo* results) {
2041 const gfx::Display& display = 2062 const gfx::Display& display =
2042 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 2063 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
2043 results->rect = display.bounds();
2044 // TODO(husky): Remove any system controls from availableRect.
2045 results->availableRect = display.work_area();
2046 results->deviceScaleFactor = display.device_scale_factor();
2047 results->orientationAngle = display.RotationAsDegree();
2048 results->orientationType =
2049 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2050 gfx::DeviceDisplayInfo info; 2064 gfx::DeviceDisplayInfo info;
2051 results->depth = info.GetBitsPerPixel(); 2065 DisplayInfoToScreenInfo(display, info, results);
2052 results->depthPerComponent = info.GetBitsPerComponent();
2053 results->isMonochrome = (results->depthPerComponent == 0);
2054 } 2066 }
2055 2067
2056 } // namespace content 2068 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698