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