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

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: git fetch 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 callback); 1015 callback);
1015 } 1016 }
1016 1017
1017 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { 1018 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const {
1018 return (!render_widget_host_->GetBackingStore(false) && 1019 return (!render_widget_host_->GetBackingStore(false) &&
1019 render_widget_host_->is_accelerated_compositing_active() && 1020 render_widget_host_->is_accelerated_compositing_active() &&
1020 compositing_iosurface_.get() && 1021 compositing_iosurface_.get() &&
1021 compositing_iosurface_->HasIOSurface()); 1022 compositing_iosurface_->HasIOSurface());
1022 } 1023 }
1023 1024
1025 bool RenderWidgetHostViewMac::CanSubscribeFrame() const {
1026 return true;
1027 }
1028
1029 void RenderWidgetHostViewMac::BeginFrameSubscription(
1030 RenderWidgetHostViewFrameSubscriber* subscriber) {
1031 frame_subscriber_.reset(subscriber);
1032 }
1033
1034 void RenderWidgetHostViewMac::EndFrameSubscription() {
1035 frame_subscriber_.reset();
1036 }
1037
1024 // Sets whether or not to accept first responder status. 1038 // Sets whether or not to accept first responder status.
1025 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { 1039 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) {
1026 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; 1040 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag];
1027 } 1041 }
1028 1042
1029 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { 1043 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) {
1030 if (render_widget_host_) 1044 if (render_widget_host_)
1031 render_widget_host_->ForwardMouseEvent(event); 1045 render_widget_host_->ForwardMouseEvent(event);
1032 1046
1033 if (event.type == WebInputEvent::MouseLeave) { 1047 if (event.type == WebInputEvent::MouseLeave) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 if (window_size.IsEmpty()) { 1141 if (window_size.IsEmpty()) {
1128 // setNeedsDisplay will never display and we'll never ack if the window is 1142 // setNeedsDisplay will never display and we'll never ack if the window is
1129 // empty, so ack now and don't bother calling setNeedsDisplay below. 1143 // empty, so ack now and don't bother calling setNeedsDisplay below.
1130 return true; 1144 return true;
1131 } 1145 }
1132 1146
1133 // No need to draw the surface if we are inside a drawRect. It will be done 1147 // No need to draw the surface if we are inside a drawRect. It will be done
1134 // later. 1148 // later.
1135 if (!about_to_validate_and_paint_) { 1149 if (!about_to_validate_and_paint_) {
1136 compositing_iosurface_->DrawIOSurface(cocoa_view_, 1150 compositing_iosurface_->DrawIOSurface(cocoa_view_,
1137 ScaleFactor(cocoa_view_)); 1151 ScaleFactor(cocoa_view_),
1152 frame_subscriber_.get());
1138 } 1153 }
1139 return true; 1154 return true;
1140 } 1155 }
1141 1156
1142 void RenderWidgetHostViewMac::AckPendingSwapBuffers() { 1157 void RenderWidgetHostViewMac::AckPendingSwapBuffers() {
1143 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::AckPendingSwapBuffers"); 1158 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::AckPendingSwapBuffers");
1144 while (!pending_swap_buffers_acks_.empty()) { 1159 while (!pending_swap_buffers_acks_.empty()) {
1145 if (pending_swap_buffers_acks_.front().first != 0) { 1160 if (pending_swap_buffers_acks_.front().first != 0) {
1146 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 1161 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
1147 ack_params.sync_point = 0; 1162 ack_params.sync_point = 0;
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so 2468 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so
2454 // this is only done when it's a real invalidation from window damage (not 2469 // this is only done when it's a real invalidation from window damage (not
2455 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill 2470 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill
2456 // can take many milliseconds sometimes (!) so this is skipped completely 2471 // can take many milliseconds sometimes (!) so this is skipped completely
2457 // for drawRects that are triggered by BuffersSwapped messages. 2472 // for drawRects that are triggered by BuffersSwapped messages.
2458 [[NSColor clearColor] set]; 2473 [[NSColor clearColor] set];
2459 NSRectFill(dirtyRect); 2474 NSRectFill(dirtyRect);
2460 } 2475 }
2461 2476
2462 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface( 2477 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface(
2463 self, ScaleFactor(self)); 2478 self, ScaleFactor(self), renderWidgetHostView_->frame_subscriber());
2464 return; 2479 return;
2465 } 2480 }
2466 2481
2467 if (backingStore) { 2482 if (backingStore) {
2468 // Note: All coordinates are in view units, not pixels. 2483 // Note: All coordinates are in view units, not pixels.
2469 gfx::Rect bitmapRect(0, 0, 2484 gfx::Rect bitmapRect(0, 0,
2470 backingStore->size().width(), 2485 backingStore->size().width(),
2471 backingStore->size().height()); 2486 backingStore->size().height());
2472 2487
2473 // Specify the proper y offset to ensure that the view is rooted to the 2488 // 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
3507 if (!string) return NO; 3522 if (!string) return NO;
3508 3523
3509 // If the user is currently using an IME, confirm the IME input, 3524 // If the user is currently using an IME, confirm the IME input,
3510 // and then insert the text from the service, the same as TextEdit and Safari. 3525 // and then insert the text from the service, the same as TextEdit and Safari.
3511 [self confirmComposition]; 3526 [self confirmComposition];
3512 [self insertText:string]; 3527 [self insertText:string];
3513 return YES; 3528 return YES;
3514 } 3529 }
3515 3530
3516 @end 3531 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698