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