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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 12277023: Define frame subscription interface and implementation on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac impl Created 7 years, 9 months 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 | Annotate | Revision Log
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_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 20 matching lines...) Expand all
31 #include "content/browser/renderer_host/compositing_iosurface_mac.h" 31 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
32 #include "content/browser/renderer_host/render_process_host_impl.h" 32 #include "content/browser/renderer_host/render_process_host_impl.h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 34 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
35 #import "content/browser/renderer_host/text_input_client_mac.h" 35 #import "content/browser/renderer_host/text_input_client_mac.h"
36 #include "content/common/accessibility_messages.h" 36 #include "content/common/accessibility_messages.h"
37 #include "content/common/edit_command.h" 37 #include "content/common/edit_command.h"
38 #include "content/common/gpu/gpu_messages.h" 38 #include "content/common/gpu/gpu_messages.h"
39 #include "content/common/plugin_messages.h" 39 #include "content/common/plugin_messages.h"
40 #include "content/common/view_messages.h" 40 #include "content/common/view_messages.h"
41 #include "content/port/browser/render_widget_host_view_frame_subscriber.h"
41 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
42 #include "content/public/browser/native_web_keyboard_event.h" 43 #include "content/public/browser/native_web_keyboard_event.h"
43 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 44 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
44 #include "skia/ext/platform_canvas.h" 45 #include "skia/ext/platform_canvas.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h" 49 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h"
49 #import "third_party/mozilla/ComplexTextInputPanel.h" 50 #import "third_party/mozilla/ComplexTextInputPanel.h"
50 #include "third_party/skia/include/core/SkColor.h" 51 #include "third_party/skia/include/core/SkColor.h"
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 callback); 1013 callback);
1013 } 1014 }
1014 1015
1015 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { 1016 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const {
1016 return (!render_widget_host_->GetBackingStore(false) && 1017 return (!render_widget_host_->GetBackingStore(false) &&
1017 render_widget_host_->is_accelerated_compositing_active() && 1018 render_widget_host_->is_accelerated_compositing_active() &&
1018 compositing_iosurface_.get() && 1019 compositing_iosurface_.get() &&
1019 compositing_iosurface_->HasIOSurface()); 1020 compositing_iosurface_->HasIOSurface());
1020 } 1021 }
1021 1022
1023 bool RenderWidgetHostViewMac::CanSubscribeFrame() const {
1024 return true;
1025 }
1026
1027 void RenderWidgetHostViewMac::BeginFrameSubscription(
1028 RenderWidgetHostViewFrameSubscriber* subscriber) {
1029 frame_subscriber_.reset(subscriber);
1030 }
1031
1032 void RenderWidgetHostViewMac::EndFrameSubscription() {
1033 frame_subscriber_.reset();
1034 }
1035
1022 // Sets whether or not to accept first responder status. 1036 // Sets whether or not to accept first responder status.
1023 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { 1037 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) {
1024 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; 1038 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag];
1025 } 1039 }
1026 1040
1027 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { 1041 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) {
1028 if (render_widget_host_) 1042 if (render_widget_host_)
1029 render_widget_host_->ForwardMouseEvent(event); 1043 render_widget_host_->ForwardMouseEvent(event);
1030 1044
1031 if (event.type == WebInputEvent::MouseLeave) { 1045 if (event.type == WebInputEvent::MouseLeave) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 if (window_size.IsEmpty()) { 1139 if (window_size.IsEmpty()) {
1126 // setNeedsDisplay will never display and we'll never ack if the window is 1140 // setNeedsDisplay will never display and we'll never ack if the window is
1127 // empty, so ack now and don't bother calling setNeedsDisplay below. 1141 // empty, so ack now and don't bother calling setNeedsDisplay below.
1128 return true; 1142 return true;
1129 } 1143 }
1130 1144
1131 // No need to draw the surface if we are inside a drawRect. It will be done 1145 // No need to draw the surface if we are inside a drawRect. It will be done
1132 // later. 1146 // later.
1133 if (!about_to_validate_and_paint_) { 1147 if (!about_to_validate_and_paint_) {
1134 compositing_iosurface_->DrawIOSurface(cocoa_view_, 1148 compositing_iosurface_->DrawIOSurface(cocoa_view_,
1135 ScaleFactor(cocoa_view_)); 1149 ScaleFactor(cocoa_view_),
1150 frame_subscriber_.get());
1136 } 1151 }
1137 return true; 1152 return true;
1138 } 1153 }
1139 1154
1140 void RenderWidgetHostViewMac::AckPendingSwapBuffers() { 1155 void RenderWidgetHostViewMac::AckPendingSwapBuffers() {
1141 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::AckPendingSwapBuffers"); 1156 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::AckPendingSwapBuffers");
1142 while (!pending_swap_buffers_acks_.empty()) { 1157 while (!pending_swap_buffers_acks_.empty()) {
1143 if (pending_swap_buffers_acks_.front().first != 0) { 1158 if (pending_swap_buffers_acks_.front().first != 0) {
1144 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 1159 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
1145 ack_params.sync_point = 0; 1160 ack_params.sync_point = 0;
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so 2466 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so
2452 // this is only done when it's a real invalidation from window damage (not 2467 // this is only done when it's a real invalidation from window damage (not
2453 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill 2468 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill
2454 // can take many milliseconds sometimes (!) so this is skipped completely 2469 // can take many milliseconds sometimes (!) so this is skipped completely
2455 // for drawRects that are triggered by BuffersSwapped messages. 2470 // for drawRects that are triggered by BuffersSwapped messages.
2456 [[NSColor clearColor] set]; 2471 [[NSColor clearColor] set];
2457 NSRectFill(dirtyRect); 2472 NSRectFill(dirtyRect);
2458 } 2473 }
2459 2474
2460 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface( 2475 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface(
2461 self, ScaleFactor(self)); 2476 self, ScaleFactor(self), renderWidgetHostView_->frame_subscriber());
2462 return; 2477 return;
2463 } 2478 }
2464 2479
2465 if (backingStore) { 2480 if (backingStore) {
2466 // Note: All coordinates are in view units, not pixels. 2481 // Note: All coordinates are in view units, not pixels.
2467 gfx::Rect bitmapRect(0, 0, 2482 gfx::Rect bitmapRect(0, 0,
2468 backingStore->size().width(), 2483 backingStore->size().width(),
2469 backingStore->size().height()); 2484 backingStore->size().height());
2470 2485
2471 // Specify the proper y offset to ensure that the view is rooted to the 2486 // Specify the proper y offset to ensure that the view is rooted to the
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 if (!string) return NO; 3520 if (!string) return NO;
3506 3521
3507 // If the user is currently using an IME, confirm the IME input, 3522 // If the user is currently using an IME, confirm the IME input,
3508 // and then insert the text from the service, the same as TextEdit and Safari. 3523 // and then insert the text from the service, the same as TextEdit and Safari.
3509 [self confirmComposition]; 3524 [self confirmComposition];
3510 [self insertText:string]; 3525 [self insertText:string];
3511 return YES; 3526 return YES;
3512 } 3527 }
3513 3528
3514 @end 3529 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698