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

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: Pass display area instead of NativeWindow to GLHelperHolder. 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
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(size_t display_area);
124 ~GLHelperHolder() override; 124 ~GLHelperHolder() override;
125 125
126 void Initialize(); 126 void Initialize(size_t display_area);
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 size_t display_area);
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(size_t display_area) {
145 GLHelperHolder* holder = new GLHelperHolder; 146 GLHelperHolder* holder = new GLHelperHolder;
146 holder->Initialize(); 147 holder->Initialize(display_area);
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(size_t display_area) {
158 context_ = CreateContext3D(); 159 context_ = CreateContext3D(display_area);
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(size_t display_area) {
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 size_t full_screen_texture_size_in_bytes = display_area * kBytesPerPixel;
192 size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
193 display_info.GetDisplayWidth() *
194 kBytesPerPixel;
195 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 193 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
196 limits.command_buffer_size = 64 * 1024; 194 limits.command_buffer_size = 64 * 1024;
197 limits.start_transfer_buffer_size = 64 * 1024; 195 limits.start_transfer_buffer_size = 64 * 1024;
198 limits.min_transfer_buffer_size = 64 * 1024; 196 limits.min_transfer_buffer_size = 64 * 1024;
199 limits.max_transfer_buffer_size = std::min( 197 limits.max_transfer_buffer_size = std::min(
200 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); 198 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize);
201 limits.mapped_memory_reclaim_limit = 199 limits.mapped_memory_reclaim_limit =
202 WebGraphicsContext3DCommandBufferImpl::kNoLimit; 200 WebGraphicsContext3DCommandBufferImpl::kNoLimit;
203 bool lose_context_when_out_of_memory = false; 201 bool lose_context_when_out_of_memory = false;
204 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 202 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
205 new WebGraphicsContext3DCommandBufferImpl( 203 new WebGraphicsContext3DCommandBufferImpl(
206 0, // offscreen 204 0, // offscreen
207 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory, 205 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory,
208 limits, nullptr)); 206 limits, nullptr));
209 context->SetContextType(BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 207 context->SetContextType(BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
210 if (context->InitializeOnCurrentThread()) { 208 if (context->InitializeOnCurrentThread()) {
211 context->traceBeginCHROMIUM( 209 context->traceBeginCHROMIUM(
212 "gpu_toplevel", 210 "gpu_toplevel",
213 base::StringPrintf("CmdBufferImageTransportFactory-%p", 211 base::StringPrintf("CmdBufferImageTransportFactory-%p",
214 context.get()).c_str()); 212 context.get()).c_str());
215 } else { 213 } else {
216 context.reset(); 214 context.reset();
217 } 215 }
218 216
219 return context.Pass(); 217 return context.Pass();
220 } 218 }
221 219
222 // This can only be used for readback postprocessing. It may return null if the 220 // This can only be used for readback postprocessing. It may return null if the
223 // channel was lost and not reestablished yet. 221 // channel was lost and not reestablished yet.
224 GLHelper* GetPostReadbackGLHelper() { 222 GLHelper* GetPostReadbackGLHelper(size_t display_area) {
225 static GLHelperHolder* g_readback_helper_holder = nullptr; 223 static GLHelperHolder* g_readback_helper_holder = nullptr;
226 224
227 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { 225 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
228 delete g_readback_helper_holder; 226 delete g_readback_helper_holder;
229 g_readback_helper_holder = nullptr; 227 g_readback_helper_holder = nullptr;
230 } 228 }
231 229
232 if (!g_readback_helper_holder) 230 if (!g_readback_helper_holder)
233 g_readback_helper_holder = GLHelperHolder::Create(); 231 g_readback_helper_holder = GLHelperHolder::Create(display_area);
234 232
235 return g_readback_helper_holder->GetGLHelper(); 233 return g_readback_helper_holder->GetGLHelper();
236 } 234 }
237 235
238 void CopyFromCompositingSurfaceFinished( 236 void CopyFromCompositingSurfaceFinished(
239 const ReadbackRequestCallback& callback, 237 const ReadbackRequestCallback& callback,
240 scoped_ptr<cc::SingleReleaseCallback> release_callback, 238 scoped_ptr<cc::SingleReleaseCallback> release_callback,
241 scoped_ptr<SkBitmap> bitmap, 239 scoped_ptr<SkBitmap> bitmap,
242 const base::TimeTicks& start_time, 240 const base::TimeTicks& start_time,
243 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 241 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
242 size_t display_area,
244 bool result) { 243 bool result) {
245 TRACE_EVENT0( 244 TRACE_EVENT0(
246 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); 245 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished");
247 bitmap_pixels_lock.reset(); 246 bitmap_pixels_lock.reset();
248 uint32 sync_point = 0; 247 uint32 sync_point = 0;
249 if (result) { 248 if (result) {
250 GLHelper* gl_helper = GetPostReadbackGLHelper(); 249 GLHelper* gl_helper = GetPostReadbackGLHelper(display_area);
251 if (gl_helper) 250 if (gl_helper)
252 sync_point = gl_helper->InsertSyncPoint(); 251 sync_point = gl_helper->InsertSyncPoint();
253 } 252 }
254 bool lost_resource = sync_point == 0; 253 bool lost_resource = sync_point == 0;
255 release_callback->Run(sync_point, lost_resource); 254 release_callback->Run(sync_point, lost_resource);
256 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, 255 UMA_HISTOGRAM_TIMES(kAsyncReadBackString,
257 base::TimeTicks::Now() - start_time); 256 base::TimeTicks::Now() - start_time);
258 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; 257 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED;
259 callback.Run(*bitmap, response); 258 callback.Run(*bitmap, response);
260 } 259 }
(...skipping 25 matching lines...) Expand all
286 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { 285 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
287 gfx::RectF rect = controller.GetRectBetweenBounds(); 286 gfx::RectF rect = controller.GetRectBetweenBounds();
288 if (rect.IsEmpty()) 287 if (rect.IsEmpty())
289 return rect; 288 return rect;
290 289
291 rect.Union(controller.GetStartHandleRect()); 290 rect.Union(controller.GetStartHandleRect());
292 rect.Union(controller.GetEndHandleRect()); 291 rect.Union(controller.GetEndHandleRect());
293 return rect; 292 return rect;
294 } 293 }
295 294
295 void DisplayInfoToScreenInfo(const gfx::Display& display,
296 const gfx::DeviceDisplayInfo& info,
297 blink::WebScreenInfo* results) {
298 results->rect = display.bounds();
299 // TODO(husky): Remove any system controls from availableRect.
300 results->availableRect = display.work_area();
301 results->deviceScaleFactor = display.device_scale_factor();
302 results->orientationAngle = display.RotationAsDegree();
303 results->orientationType =
304 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
305 results->depth = info.GetBitsPerPixel();
306 results->depthPerComponent = info.GetBitsPerComponent();
307 results->isMonochrome = (results->depthPerComponent == 0);
308 }
309
296 } // anonymous namespace 310 } // anonymous namespace
297 311
298 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( 312 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo(
299 uint32 output_id, 313 uint32 output_id,
300 scoped_ptr<cc::CompositorFrame> output_frame) 314 scoped_ptr<cc::CompositorFrame> output_frame)
301 : output_surface_id(output_id), frame(output_frame.Pass()) {} 315 : output_surface_id(output_id), frame(output_frame.Pass()) {}
302 316
303 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} 317 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {}
304 318
305 void RenderWidgetHostViewAndroid::OnContextLost() { 319 void RenderWidgetHostViewAndroid::OnContextLost() {
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 DCHECK(content_view_core_window_android_); 910 DCHECK(content_view_core_window_android_);
897 ui::WindowAndroidCompositor* compositor = 911 ui::WindowAndroidCompositor* compositor =
898 content_view_core_window_android_->GetCompositor(); 912 content_view_core_window_android_->GetCompositor();
899 DCHECK(compositor); 913 DCHECK(compositor);
900 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 914 DCHECK(frame_provider_.get() || !surface_id_.is_null());
901 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); 915 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer();
902 DCHECK(layer); 916 DCHECK(layer);
903 layer->SetHideLayerAndSubtree(true); 917 layer->SetHideLayerAndSubtree(true);
904 compositor->AttachLayerForReadback(layer); 918 compositor->AttachLayerForReadback(layer);
905 919
920 const gfx::DeviceDisplayInfo& display_info =
921 content_view_core_window_android_->GetDeviceDisplayInfo();
922 size_t display_area =
923 display_info.GetDisplayHeight() * display_info.GetDisplayWidth();
924
906 readback_layer = layer; 925 readback_layer = layer;
907 request = cc::CopyOutputRequest::CreateRequest( 926 request = cc::CopyOutputRequest::CreateRequest(
908 base::Bind(&RenderWidgetHostViewAndroid:: 927 base::Bind(&RenderWidgetHostViewAndroid::
909 PrepareTextureCopyOutputResultForDelegatedReadback, 928 PrepareTextureCopyOutputResultForDelegatedReadback,
910 dst_size_in_pixel, preferred_color_type, start_time, 929 dst_size_in_pixel, preferred_color_type, start_time,
911 readback_layer, callback)); 930 readback_layer, callback, display_area));
912 if (!src_subrect_in_pixel.IsEmpty()) 931 if (!src_subrect_in_pixel.IsEmpty())
913 request->set_area(src_subrect_in_pixel); 932 request->set_area(src_subrect_in_pixel);
914 readback_layer->RequestCopyOfOutput(request.Pass()); 933 readback_layer->RequestCopyOfOutput(request.Pass());
915 } 934 }
916 935
917 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 936 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
918 const gfx::Rect& src_subrect, 937 const gfx::Rect& src_subrect,
919 const scoped_refptr<media::VideoFrame>& target, 938 const scoped_refptr<media::VideoFrame>& target,
920 const base::Callback<void(bool)>& callback) { 939 const base::Callback<void(bool)>& callback) {
921 NOTIMPLEMENTED(); 940 NOTIMPLEMENTED();
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 DestroyDelegatedContent(); 1558 DestroyDelegatedContent();
1540 frame_evictor_->DiscardedFrame(); 1559 frame_evictor_->DiscardedFrame();
1541 } 1560 }
1542 1561
1543 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 1562 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
1544 const gfx::Size& desired_size) { 1563 const gfx::Size& desired_size) {
1545 NOTREACHED(); 1564 NOTREACHED();
1546 return false; 1565 return false;
1547 } 1566 }
1548 1567
1549 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { 1568 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) {
1550 // ScreenInfo isn't tied to the widget on Android. Always return the default. 1569 if (content_view_core_) {
1551 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 }
1552 } 1580 }
1553 1581
1554 bool RenderWidgetHostViewAndroid::GetScreenColorProfile( 1582 bool RenderWidgetHostViewAndroid::GetScreenColorProfile(
1555 std::vector<char>* color_profile) { 1583 std::vector<char>* color_profile) {
1556 DCHECK(color_profile->empty()); 1584 DCHECK(color_profile->empty());
1557 NOTREACHED(); 1585 NOTREACHED();
1558 return false; 1586 return false;
1559 } 1587 }
1560 1588
1561 // TODO(jrg): Find out the implications and answer correctly here, 1589 // TODO(jrg): Find out the implications and answer correctly here,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 } 1954 }
1927 1955
1928 // static 1956 // static
1929 void RenderWidgetHostViewAndroid:: 1957 void RenderWidgetHostViewAndroid::
1930 PrepareTextureCopyOutputResultForDelegatedReadback( 1958 PrepareTextureCopyOutputResultForDelegatedReadback(
1931 const gfx::Size& dst_size_in_pixel, 1959 const gfx::Size& dst_size_in_pixel,
1932 SkColorType color_type, 1960 SkColorType color_type,
1933 const base::TimeTicks& start_time, 1961 const base::TimeTicks& start_time,
1934 scoped_refptr<cc::Layer> readback_layer, 1962 scoped_refptr<cc::Layer> readback_layer,
1935 const ReadbackRequestCallback& callback, 1963 const ReadbackRequestCallback& callback,
1964 size_t display_area,
1936 scoped_ptr<cc::CopyOutputResult> result) { 1965 scoped_ptr<cc::CopyOutputResult> result) {
1937 readback_layer->RemoveFromParent(); 1966 readback_layer->RemoveFromParent();
1938 PrepareTextureCopyOutputResult( 1967 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
1939 dst_size_in_pixel, color_type, start_time, callback, result.Pass()); 1968 callback, display_area, result.Pass());
1940 } 1969 }
1941 1970
1942 // static 1971 // static
1943 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1972 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1944 const gfx::Size& dst_size_in_pixel, 1973 const gfx::Size& dst_size_in_pixel,
1945 SkColorType color_type, 1974 SkColorType color_type,
1946 const base::TimeTicks& start_time, 1975 const base::TimeTicks& start_time,
1947 const ReadbackRequestCallback& callback, 1976 const ReadbackRequestCallback& callback,
1977 size_t display_area,
1948 scoped_ptr<cc::CopyOutputResult> result) { 1978 scoped_ptr<cc::CopyOutputResult> result) {
1949 base::ScopedClosureRunner scoped_callback_runner( 1979 base::ScopedClosureRunner scoped_callback_runner(
1950 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1980 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1951 TRACE_EVENT0("cc", 1981 TRACE_EVENT0("cc",
1952 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1982 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1953 1983
1954 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1984 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1955 return; 1985 return;
1956 1986
1957 gfx::Size output_size_in_pixel; 1987 gfx::Size output_size_in_pixel;
1958 if (dst_size_in_pixel.IsEmpty()) 1988 if (dst_size_in_pixel.IsEmpty())
1959 output_size_in_pixel = result->size(); 1989 output_size_in_pixel = result->size();
1960 else 1990 else
1961 output_size_in_pixel = dst_size_in_pixel; 1991 output_size_in_pixel = dst_size_in_pixel;
1962 1992
1963 GLHelper* gl_helper = GetPostReadbackGLHelper(); 1993 GLHelper* gl_helper = GetPostReadbackGLHelper(display_area);
1964 if (!gl_helper) 1994 if (!gl_helper)
1965 return; 1995 return;
1966 if (!gl_helper->IsReadbackConfigSupported(color_type)) 1996 if (!gl_helper->IsReadbackConfigSupported(color_type))
1967 color_type = kRGBA_8888_SkColorType; 1997 color_type = kRGBA_8888_SkColorType;
1968 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 1998 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
1969 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 1999 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(),
1970 output_size_in_pixel.height(), 2000 output_size_in_pixel.height(),
1971 color_type, 2001 color_type,
1972 kOpaque_SkAlphaType))) { 2002 kOpaque_SkAlphaType))) {
1973 scoped_callback_runner.Reset( 2003 scoped_callback_runner.Reset(
1974 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); 2004 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE));
1975 return; 2005 return;
1976 } 2006 }
1977 2007
1978 2008
1979 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 2009 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
1980 new SkAutoLockPixels(*bitmap)); 2010 new SkAutoLockPixels(*bitmap));
1981 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 2011 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
1982 2012
1983 cc::TextureMailbox texture_mailbox; 2013 cc::TextureMailbox texture_mailbox;
1984 scoped_ptr<cc::SingleReleaseCallback> release_callback; 2014 scoped_ptr<cc::SingleReleaseCallback> release_callback;
1985 result->TakeTexture(&texture_mailbox, &release_callback); 2015 result->TakeTexture(&texture_mailbox, &release_callback);
1986 DCHECK(texture_mailbox.IsTexture()); 2016 DCHECK(texture_mailbox.IsTexture());
1987 if (!texture_mailbox.IsTexture()) 2017 if (!texture_mailbox.IsTexture())
1988 return; 2018 return;
1989 2019
1990 ignore_result(scoped_callback_runner.Release()); 2020 ignore_result(scoped_callback_runner.Release());
1991 2021
1992 gl_helper->CropScaleReadbackAndCleanMailbox( 2022 gl_helper->CropScaleReadbackAndCleanMailbox(
1993 texture_mailbox.mailbox(), 2023 texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(),
1994 texture_mailbox.sync_point(), 2024 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
1995 result->size(), 2025 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
1996 gfx::Rect(result->size()), 2026 base::Passed(&release_callback), base::Passed(&bitmap),
1997 output_size_in_pixel, 2027 start_time, base::Passed(&bitmap_pixels_lock), display_area),
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); 2028 GLHelper::SCALER_QUALITY_GOOD);
2007 } 2029 }
2008 2030
2009 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 2031 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
2010 float y0, 2032 float y0,
2011 float x1, 2033 float x1,
2012 float y1) { 2034 float y1) {
2013 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 2035 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
2014 } 2036 }
2015 2037
(...skipping 15 matching lines...) Expand all
2031 blink::WebInputEvent::GestureLongPress, 2053 blink::WebInputEvent::GestureLongPress,
2032 (time - base::TimeTicks()).InSecondsF(), x, y); 2054 (time - base::TimeTicks()).InSecondsF(), x, y);
2033 SendGestureEvent(long_press); 2055 SendGestureEvent(long_press);
2034 } 2056 }
2035 2057
2036 // static 2058 // static
2037 void RenderWidgetHostViewBase::GetDefaultScreenInfo( 2059 void RenderWidgetHostViewBase::GetDefaultScreenInfo(
2038 blink::WebScreenInfo* results) { 2060 blink::WebScreenInfo* results) {
2039 const gfx::Display& display = 2061 const gfx::Display& display =
2040 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 2062 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; 2063 gfx::DeviceDisplayInfo info;
2049 results->depth = info.GetBitsPerPixel(); 2064 DisplayInfoToScreenInfo(display, info, results);
2050 results->depthPerComponent = info.GetBitsPerComponent();
2051 results->isMonochrome = (results->depthPerComponent == 0);
2052 } 2065 }
2053 2066
2054 } // namespace content 2067 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698