| 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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 if (!output->Allocate( | 848 if (!output->Allocate( |
| 849 dst_pixel_size.width(), dst_pixel_size.height(), true)) | 849 dst_pixel_size.width(), dst_pixel_size.height(), true)) |
| 850 return; | 850 return; |
| 851 scoped_callback_runner.Release(); | 851 scoped_callback_runner.Release(); |
| 852 | 852 |
| 853 // Convert |src_subrect| from the views coordinate (upper-left origin) into | 853 // Convert |src_subrect| from the views coordinate (upper-left origin) into |
| 854 // the OpenGL coordinate (lower-left origin). | 854 // the OpenGL coordinate (lower-left origin). |
| 855 gfx::Rect src_gl_subrect = src_subrect; | 855 gfx::Rect src_gl_subrect = src_subrect; |
| 856 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); | 856 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); |
| 857 | 857 |
| 858 gfx::RectF scaled_src_gl_subrect = src_gl_subrect; | 858 gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect( |
| 859 scaled_src_gl_subrect.Scale(scale); | 859 gfx::Scale(src_gl_subrect, scale)); |
| 860 gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(scaled_src_gl_subrect); | |
| 861 compositing_iosurface_->CopyTo( | 860 compositing_iosurface_->CopyTo( |
| 862 src_pixel_gl_subrect, | 861 src_pixel_gl_subrect, |
| 863 dst_pixel_size, | 862 dst_pixel_size, |
| 864 output->GetBitmap().getPixels(), | 863 output->GetBitmap().getPixels(), |
| 865 callback); | 864 callback); |
| 866 } | 865 } |
| 867 | 866 |
| 868 // Sets whether or not to accept first responder status. | 867 // Sets whether or not to accept first responder status. |
| 869 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { | 868 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { |
| 870 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; | 869 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; |
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2266 // Note: All coordinates are in view units, not pixels. | 2265 // Note: All coordinates are in view units, not pixels. |
| 2267 gfx::Rect bitmapRect(0, 0, | 2266 gfx::Rect bitmapRect(0, 0, |
| 2268 backingStore->size().width(), | 2267 backingStore->size().width(), |
| 2269 backingStore->size().height()); | 2268 backingStore->size().height()); |
| 2270 | 2269 |
| 2271 // Specify the proper y offset to ensure that the view is rooted to the | 2270 // Specify the proper y offset to ensure that the view is rooted to the |
| 2272 // upper left corner. This can be negative, if the window was resized | 2271 // upper left corner. This can be negative, if the window was resized |
| 2273 // smaller and the renderer hasn't yet repainted. | 2272 // smaller and the renderer hasn't yet repainted. |
| 2274 int yOffset = NSHeight([self bounds]) - backingStore->size().height(); | 2273 int yOffset = NSHeight([self bounds]) - backingStore->size().height(); |
| 2275 | 2274 |
| 2276 gfx::Rect paintRect = bitmapRect; | 2275 gfx::Rect paintRect = gfx::Intersection(bitmapRect, damagedRect); |
| 2277 paintRect.Intersect(damagedRect); | |
| 2278 if (!paintRect.IsEmpty()) { | 2276 if (!paintRect.IsEmpty()) { |
| 2279 // if we have a CGLayer, draw that into the window | 2277 // if we have a CGLayer, draw that into the window |
| 2280 if (backingStore->cg_layer()) { | 2278 if (backingStore->cg_layer()) { |
| 2281 CGContextRef context = static_cast<CGContextRef>( | 2279 CGContextRef context = static_cast<CGContextRef>( |
| 2282 [[NSGraphicsContext currentContext] graphicsPort]); | 2280 [[NSGraphicsContext currentContext] graphicsPort]); |
| 2283 | 2281 |
| 2284 // TODO: add clipping to dirtyRect if it improves drawing performance. | 2282 // TODO: add clipping to dirtyRect if it improves drawing performance. |
| 2285 CGContextDrawLayerAtPoint(context, CGPointMake(0.0, yOffset), | 2283 CGContextDrawLayerAtPoint(context, CGPointMake(0.0, yOffset), |
| 2286 backingStore->cg_layer()); | 2284 backingStore->cg_layer()); |
| 2287 } else { | 2285 } else { |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3302 if (!string) return NO; | 3300 if (!string) return NO; |
| 3303 | 3301 |
| 3304 // If the user is currently using an IME, confirm the IME input, | 3302 // If the user is currently using an IME, confirm the IME input, |
| 3305 // and then insert the text from the service, the same as TextEdit and Safari. | 3303 // and then insert the text from the service, the same as TextEdit and Safari. |
| 3306 [self confirmComposition]; | 3304 [self confirmComposition]; |
| 3307 [self insertText:string]; | 3305 [self insertText:string]; |
| 3308 return YES; | 3306 return YES; |
| 3309 } | 3307 } |
| 3310 | 3308 |
| 3311 @end | 3309 @end |
| OLD | NEW |