Chromium Code Reviews| 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 | 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 Loading... | |
| 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:06
native_window everywhere, though if these classes
| |
| 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 Loading... | |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 301 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 299 gfx::RectF rect = controller.GetRectBetweenBounds(); | 302 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 300 if (rect.IsEmpty()) | 303 if (rect.IsEmpty()) |
| 301 return rect; | 304 return rect; |
| 302 | 305 |
| 303 rect.Union(controller.GetStartHandleRect()); | 306 rect.Union(controller.GetStartHandleRect()); |
| 304 rect.Union(controller.GetEndHandleRect()); | 307 rect.Union(controller.GetEndHandleRect()); |
| 305 return rect; | 308 return rect; |
| 306 } | 309 } |
| 307 | 310 |
| 311 void DisplayInfoToScreenInfo(const gfx::Display& display, | |
| 312 const gfx::DeviceDisplayInfo& info, | |
| 313 blink::WebScreenInfo* results) { | |
| 314 results->rect = display.bounds(); | |
| 315 // TODO(husky): Remove any system controls from availableRect. | |
| 316 results->availableRect = display.work_area(); | |
| 317 results->deviceScaleFactor = display.device_scale_factor(); | |
| 318 results->orientationAngle = display.RotationAsDegree(); | |
| 319 results->orientationType = | |
| 320 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | |
| 321 results->depth = info.GetBitsPerPixel(); | |
| 322 results->depthPerComponent = info.GetBitsPerComponent(); | |
| 323 results->isMonochrome = (results->depthPerComponent == 0); | |
| 324 } | |
| 325 | |
| 308 } // anonymous namespace | 326 } // anonymous namespace |
| 309 | 327 |
| 310 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( | 328 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( |
| 311 uint32 output_id, | 329 uint32 output_id, |
| 312 scoped_ptr<cc::CompositorFrame> output_frame) | 330 scoped_ptr<cc::CompositorFrame> output_frame) |
| 313 : output_surface_id(output_id), frame(output_frame.Pass()) {} | 331 : output_surface_id(output_id), frame(output_frame.Pass()) {} |
| 314 | 332 |
| 315 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} | 333 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} |
| 316 | 334 |
| 317 void RenderWidgetHostViewAndroid::OnContextLost() { | 335 void RenderWidgetHostViewAndroid::OnContextLost() { |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); | 940 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); |
| 923 DCHECK(layer); | 941 DCHECK(layer); |
| 924 layer->SetHideLayerAndSubtree(true); | 942 layer->SetHideLayerAndSubtree(true); |
| 925 compositor->AttachLayerForReadback(layer); | 943 compositor->AttachLayerForReadback(layer); |
| 926 | 944 |
| 927 readback_layer = layer; | 945 readback_layer = layer; |
| 928 request = cc::CopyOutputRequest::CreateRequest( | 946 request = cc::CopyOutputRequest::CreateRequest( |
| 929 base::Bind(&RenderWidgetHostViewAndroid:: | 947 base::Bind(&RenderWidgetHostViewAndroid:: |
| 930 PrepareTextureCopyOutputResultForDelegatedReadback, | 948 PrepareTextureCopyOutputResultForDelegatedReadback, |
| 931 dst_size_in_pixel, preferred_color_type, start_time, | 949 dst_size_in_pixel, preferred_color_type, start_time, |
| 932 readback_layer, callback)); | 950 readback_layer, callback, content_view_core_window_android_)); |
| 933 if (!src_subrect_in_pixel.IsEmpty()) | 951 if (!src_subrect_in_pixel.IsEmpty()) |
| 934 request->set_area(src_subrect_in_pixel); | 952 request->set_area(src_subrect_in_pixel); |
| 935 readback_layer->RequestCopyOfOutput(request.Pass()); | 953 readback_layer->RequestCopyOfOutput(request.Pass()); |
| 936 } | 954 } |
| 937 | 955 |
| 938 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( | 956 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( |
| 939 const gfx::Rect& src_subrect, | 957 const gfx::Rect& src_subrect, |
| 940 const scoped_refptr<media::VideoFrame>& target, | 958 const scoped_refptr<media::VideoFrame>& target, |
| 941 const base::Callback<void(bool)>& callback) { | 959 const base::Callback<void(bool)>& callback) { |
| 942 NOTIMPLEMENTED(); | 960 NOTIMPLEMENTED(); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1538 DestroyDelegatedContent(); | 1556 DestroyDelegatedContent(); |
| 1539 frame_evictor_->DiscardedFrame(); | 1557 frame_evictor_->DiscardedFrame(); |
| 1540 } | 1558 } |
| 1541 | 1559 |
| 1542 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( | 1560 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
| 1543 const gfx::Size& desired_size) { | 1561 const gfx::Size& desired_size) { |
| 1544 NOTREACHED(); | 1562 NOTREACHED(); |
| 1545 return false; | 1563 return false; |
| 1546 } | 1564 } |
| 1547 | 1565 |
| 1548 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { | 1566 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) { |
| 1549 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 1567 if (content_view_core_) { |
| 1550 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); | 1568 gfx::NativeView view_android = GetNativeView(); |
| 1569 | |
| 1570 const gfx::Display& display = | |
| 1571 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view_android); | |
| 1572 const gfx::DeviceDisplayInfo& info = | |
| 1573 content_view_core_window_android_->GetDeviceDisplayInfo(); | |
| 1574 DisplayInfoToScreenInfo(display, info, results); | |
| 1575 } else { | |
| 1576 GetDefaultScreenInfo(results); | |
| 1577 } | |
| 1551 } | 1578 } |
| 1552 | 1579 |
| 1553 // TODO(jrg): Find out the implications and answer correctly here, | 1580 // TODO(jrg): Find out the implications and answer correctly here, |
| 1554 // as we are returning the WebView and not root window bounds. | 1581 // as we are returning the WebView and not root window bounds. |
| 1555 gfx::Rect RenderWidgetHostViewAndroid::GetBoundsInRootWindow() { | 1582 gfx::Rect RenderWidgetHostViewAndroid::GetBoundsInRootWindow() { |
| 1556 return GetViewBounds(); | 1583 return GetViewBounds(); |
| 1557 } | 1584 } |
| 1558 | 1585 |
| 1559 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { | 1586 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { |
| 1560 gfx::GLSurfaceHandle handle = | 1587 gfx::GLSurfaceHandle handle = |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1918 } | 1945 } |
| 1919 | 1946 |
| 1920 // static | 1947 // static |
| 1921 void RenderWidgetHostViewAndroid:: | 1948 void RenderWidgetHostViewAndroid:: |
| 1922 PrepareTextureCopyOutputResultForDelegatedReadback( | 1949 PrepareTextureCopyOutputResultForDelegatedReadback( |
| 1923 const gfx::Size& dst_size_in_pixel, | 1950 const gfx::Size& dst_size_in_pixel, |
| 1924 SkColorType color_type, | 1951 SkColorType color_type, |
| 1925 const base::TimeTicks& start_time, | 1952 const base::TimeTicks& start_time, |
| 1926 scoped_refptr<cc::Layer> readback_layer, | 1953 scoped_refptr<cc::Layer> readback_layer, |
| 1927 ReadbackRequestCallback& callback, | 1954 ReadbackRequestCallback& callback, |
| 1955 gfx::NativeWindow nativeWindow, | |
| 1928 scoped_ptr<cc::CopyOutputResult> result) { | 1956 scoped_ptr<cc::CopyOutputResult> result) { |
| 1929 readback_layer->RemoveFromParent(); | 1957 readback_layer->RemoveFromParent(); |
| 1930 PrepareTextureCopyOutputResult( | 1958 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time, |
| 1931 dst_size_in_pixel, color_type, start_time, callback, result.Pass()); | 1959 callback, nativeWindow, result.Pass()); |
| 1932 } | 1960 } |
| 1933 | 1961 |
| 1934 // static | 1962 // static |
| 1935 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1963 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| 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 ReadbackRequestCallback& callback, | 1967 ReadbackRequestCallback& callback, |
| 1968 gfx::NativeWindow nativeWindow, | |
| 1940 scoped_ptr<cc::CopyOutputResult> result) { | 1969 scoped_ptr<cc::CopyOutputResult> result) { |
| 1941 base::ScopedClosureRunner scoped_callback_runner( | 1970 base::ScopedClosureRunner scoped_callback_runner( |
| 1942 base::Bind(callback, SkBitmap(), READBACK_FAILED)); | 1971 base::Bind(callback, SkBitmap(), READBACK_FAILED)); |
| 1943 TRACE_EVENT0("cc", | 1972 TRACE_EVENT0("cc", |
| 1944 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); | 1973 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); |
| 1945 | 1974 |
| 1946 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) | 1975 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) |
| 1947 return; | 1976 return; |
| 1948 | 1977 |
| 1949 gfx::Size output_size_in_pixel; | 1978 gfx::Size output_size_in_pixel; |
| 1950 if (dst_size_in_pixel.IsEmpty()) | 1979 if (dst_size_in_pixel.IsEmpty()) |
| 1951 output_size_in_pixel = result->size(); | 1980 output_size_in_pixel = result->size(); |
| 1952 else | 1981 else |
| 1953 output_size_in_pixel = dst_size_in_pixel; | 1982 output_size_in_pixel = dst_size_in_pixel; |
| 1954 | 1983 |
| 1955 GLHelper* gl_helper = GetPostReadbackGLHelper(); | 1984 GLHelper* gl_helper = GetPostReadbackGLHelper(nativeWindow); |
| 1956 if (!gl_helper) | 1985 if (!gl_helper) |
| 1957 return; | 1986 return; |
| 1958 if (!gl_helper->IsReadbackConfigSupported(color_type)) | 1987 if (!gl_helper->IsReadbackConfigSupported(color_type)) |
| 1959 color_type = kRGBA_8888_SkColorType; | 1988 color_type = kRGBA_8888_SkColorType; |
| 1960 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1989 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| 1961 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), | 1990 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), |
| 1962 output_size_in_pixel.height(), | 1991 output_size_in_pixel.height(), |
| 1963 color_type, | 1992 color_type, |
| 1964 kOpaque_SkAlphaType))) { | 1993 kOpaque_SkAlphaType))) { |
| 1965 scoped_callback_runner.Reset( | 1994 scoped_callback_runner.Reset( |
| 1966 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); | 1995 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); |
| 1967 return; | 1996 return; |
| 1968 } | 1997 } |
| 1969 | 1998 |
| 1970 | 1999 |
| 1971 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( | 2000 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( |
| 1972 new SkAutoLockPixels(*bitmap)); | 2001 new SkAutoLockPixels(*bitmap)); |
| 1973 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); | 2002 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); |
| 1974 | 2003 |
| 1975 cc::TextureMailbox texture_mailbox; | 2004 cc::TextureMailbox texture_mailbox; |
| 1976 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 2005 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| 1977 result->TakeTexture(&texture_mailbox, &release_callback); | 2006 result->TakeTexture(&texture_mailbox, &release_callback); |
| 1978 DCHECK(texture_mailbox.IsTexture()); | 2007 DCHECK(texture_mailbox.IsTexture()); |
| 1979 if (!texture_mailbox.IsTexture()) | 2008 if (!texture_mailbox.IsTexture()) |
| 1980 return; | 2009 return; |
| 1981 | 2010 |
| 1982 ignore_result(scoped_callback_runner.Release()); | 2011 ignore_result(scoped_callback_runner.Release()); |
| 1983 | 2012 |
| 1984 gl_helper->CropScaleReadbackAndCleanMailbox( | 2013 gl_helper->CropScaleReadbackAndCleanMailbox( |
| 1985 texture_mailbox.mailbox(), | 2014 texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(), |
| 1986 texture_mailbox.sync_point(), | 2015 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, |
| 1987 result->size(), | 2016 base::Bind(&CopyFromCompositingSurfaceFinished, callback, |
| 1988 gfx::Rect(result->size()), | 2017 base::Passed(&release_callback), base::Passed(&bitmap), |
| 1989 output_size_in_pixel, | 2018 start_time, base::Passed(&bitmap_pixels_lock), nativeWindow), |
| 1990 pixels, | |
| 1991 color_type, | |
| 1992 base::Bind(&CopyFromCompositingSurfaceFinished, | |
| 1993 callback, | |
| 1994 base::Passed(&release_callback), | |
| 1995 base::Passed(&bitmap), | |
| 1996 start_time, | |
| 1997 base::Passed(&bitmap_pixels_lock)), | |
| 1998 GLHelper::SCALER_QUALITY_GOOD); | 2019 GLHelper::SCALER_QUALITY_GOOD); |
| 1999 } | 2020 } |
| 2000 | 2021 |
| 2001 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, | 2022 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, |
| 2002 float y0, | 2023 float y0, |
| 2003 float x1, | 2024 float x1, |
| 2004 float y1) { | 2025 float y1) { |
| 2005 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); | 2026 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); |
| 2006 } | 2027 } |
| 2007 | 2028 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2023 blink::WebInputEvent::GestureLongPress, | 2044 blink::WebInputEvent::GestureLongPress, |
| 2024 (time - base::TimeTicks()).InSecondsF(), x, y); | 2045 (time - base::TimeTicks()).InSecondsF(), x, y); |
| 2025 SendGestureEvent(long_press); | 2046 SendGestureEvent(long_press); |
| 2026 } | 2047 } |
| 2027 | 2048 |
| 2028 // static | 2049 // static |
| 2029 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 2050 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
| 2030 blink::WebScreenInfo* results) { | 2051 blink::WebScreenInfo* results) { |
| 2031 const gfx::Display& display = | 2052 const gfx::Display& display = |
| 2032 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 2053 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; | 2054 gfx::DeviceDisplayInfo info; |
| 2041 results->depth = info.GetBitsPerPixel(); | 2055 DisplayInfoToScreenInfo(display, info, results); |
| 2042 results->depthPerComponent = info.GetBitsPerComponent(); | |
| 2043 results->isMonochrome = (results->depthPerComponent == 0); | |
| 2044 } | 2056 } |
| 2045 | 2057 |
| 2046 } // namespace content | 2058 } // namespace content |
| OLD | NEW |