| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #import <QuartzCore/QuartzCore.h> | 6 #import <QuartzCore/QuartzCore.h> |
| 7 | 7 |
| 8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // the surface. | 377 // the surface. |
| 378 CALayer* layer = nil; | 378 CALayer* layer = nil; |
| 379 NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer, | 379 NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer, |
| 380 reinterpret_cast<void*>(&layer)); | 380 reinterpret_cast<void*>(&layer)); |
| 381 if (!err) { | 381 if (!err) { |
| 382 if (drawing_model == NPDrawingModelCoreAnimation) { | 382 if (drawing_model == NPDrawingModelCoreAnimation) { |
| 383 // Create the timer; it will be started when we get a window handle. | 383 // Create the timer; it will be started when we get a window handle. |
| 384 redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); | 384 redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); |
| 385 } | 385 } |
| 386 layer_ = layer; | 386 layer_ = layer; |
| 387 surface_ = plugin_->GetAcceleratedSurface(); | 387 |
| 388 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 389 // On dual GPU systems, force the use of the discrete GPU for |
| 390 // the CARenderer underlying our Core Animation backend for |
| 391 // all plugins except Flash. For some reason Unity3D's output |
| 392 // doesn't show up if the integrated GPU is used. Safari keeps |
| 393 // even Flash 11 with Stage3D on the integrated GPU, so mirror |
| 394 // that behavior here. |
| 395 const WebPluginInfo& plugin_info = |
| 396 instance_->plugin_lib()->plugin_info(); |
| 397 if (plugin_info.name.find(ASCIIToUTF16("Flash")) != string16::npos) |
| 398 gpu_preference = gfx::PreferIntegratedGpu; |
| 399 surface_ = plugin_->GetAcceleratedSurface(gpu_preference); |
| 388 | 400 |
| 389 // If surface initialization fails for some reason, just continue | 401 // If surface initialization fails for some reason, just continue |
| 390 // without any drawing; returning false would be a more confusing user | 402 // without any drawing; returning false would be a more confusing user |
| 391 // experience (since it triggers a missing plugin placeholder). | 403 // experience (since it triggers a missing plugin placeholder). |
| 392 if (surface_ && surface_->context()) { | 404 if (surface_ && surface_->context()) { |
| 393 renderer_ = [[CARenderer rendererWithCGLContext:surface_->context() | 405 renderer_ = [[CARenderer rendererWithCGLContext:surface_->context() |
| 394 options:NULL] retain]; | 406 options:NULL] retain]; |
| 395 [renderer_ setLayer:layer_]; | 407 [renderer_ setLayer:layer_]; |
| 396 } | 408 } |
| 397 plugin_->BindFakePluginWindowHandle(false); | 409 plugin_->BindFakePluginWindowHandle(false); |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 qd_manager_->SetFastPathEnabled(enabled); | 1221 qd_manager_->SetFastPathEnabled(enabled); |
| 1210 qd_port_.port = qd_manager_->port(); | 1222 qd_port_.port = qd_manager_->port(); |
| 1211 WindowlessSetWindow(); | 1223 WindowlessSetWindow(); |
| 1212 // Send a paint event so that the new buffer gets updated immediately. | 1224 // Send a paint event so that the new buffer gets updated immediately. |
| 1213 WindowlessPaint(buffer_context_, clip_rect_); | 1225 WindowlessPaint(buffer_context_, clip_rect_); |
| 1214 } | 1226 } |
| 1215 #endif // !NP_NO_QUICKDRAW | 1227 #endif // !NP_NO_QUICKDRAW |
| 1216 | 1228 |
| 1217 } // namespace npapi | 1229 } // namespace npapi |
| 1218 } // namespace webkit | 1230 } // namespace webkit |
| OLD | NEW |