Mac: Fix performance issues with remote CoreAnimation
commit2fa389cfe85e24cd9c9fba67b06b025bdb1cd6c1
authorccameron <ccameron@chromium.org>
Wed, 26 Nov 2014 23:49:49 +0000 (26 15:49 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 26 Nov 2014 23:50:45 +0000 (26 23:50 +0000)
treef9b5af8437162973a1052fda944db0f1c4330d23
parent2c7a699cf6b4a85072ddf0b27f99aafc12116363
Mac: Fix performance issues with remote CoreAnimation

There are two separate issues here.

First, virtualized contexts did not appropriately force the switch
between GPUs when made current. The forced switch would only happen
when the real context was changed, which is much less often. This issue
is not specific to remote CoreAnimation, and also impacted the IOSurface
path (it has likely been an issue since virtual contexts were enabled).

Second, when the GPU switches, tear down and re-create the CAOpenGLLayer
that is exported across processes. This is already done for the
IOSurface path, in IOSurfaceLayerHelper. When the CGLContextObj for the
CAOpenGLLayer is re-created, it will be running on the current GPU.
Without the re-creation, it may stay indefinitely on the old GPU. It is
from this context that we read the CGL renderer ID which we will pass
to the rendering context, to force it to switch GPUs as well.

BUG=424433

TEST=
0. Get a GPU-switching Mac with no external displays and install
   gfxCardStatus
1. Ensure that you are on the integrated GPU (gfxCardStatus should say
   'i')
2. Start Chrome with the FPS counter enabled
3. Open poster circle in one window
   a. It should run at 60 fps
4. Open a WebGL demo (San Angeles) in another window
   a. This should trigger a switch to the dGPU (gfxCardStatus should say
      'd')
   b. Both windows should stay at 60 fps
5. Close the WebGL demo window
   a. After 10 seconds the you will automatically switch to the
      integrated GPU (gfxCardStatus should switch to saying 'i' again)
   b. The poster circle window should stay at 60 fps
The critical parts of this test are the 60 fps parts in 4.b and 5.b. It
will be the case that there will be a pretty hard hiccup for up to a
second, but after 2-3 seconds, it should stabilize back to 60 fps.

Review URL: https://codereview.chromium.org/756413003

Cr-Commit-Position: refs/heads/master@{#305918}
content/common/gpu/image_transport_surface_calayer_mac.h
content/common/gpu/image_transport_surface_calayer_mac.mm
ui/gl/gl_context.cc
ui/gl/gl_context.h
ui/gl/gl_context_cgl.cc
ui/gl/gl_context_cgl.h