Commit 0707401c authored by ccameron's avatar ccameron Committed by Commit bot

Make remote CoreAnimation GPU-switching aware

Send the CGL renderer ID for the context being used by the
CAOpenGLLayer.

Tested with WebGL apps, gfxCardStatus switching.

BUG=312462

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

Cr-Commit-Position: refs/heads/master@{#299204}
parent dc1615b4
......@@ -4,6 +4,8 @@
#include "content/common/gpu/image_transport_surface_calayer_mac.h"
#include <OpenGL/CGLRenderers.h>
#include "base/command_line.h"
#include "base/mac/sdk_forward_declarations.h"
#include "content/common/gpu/surface_handle_types_mac.h"
......@@ -291,6 +293,14 @@ void CALayerStorageProvider::LayerDoDraw() {
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable(GL_TEXTURE_RECTANGLE_ARB);
GLint current_renderer_id = 0;
if (CGLGetParameter(CGLGetCurrentContext(),
kCGLCPCurrentRendererID,
&current_renderer_id) == kCGLNoError) {
current_renderer_id &= kCGLRendererIDMatchingMask;
transport_surface_->SetRendererID(current_renderer_id);
}
// Allow forward progress in the context now that the swap is complete.
UnblockBrowserIfNeeded();
}
......
......@@ -82,6 +82,7 @@ class ImageTransportSurfaceFBO
void SendSwapBuffers(uint64 surface_handle,
const gfx::Size pixel_size,
float scale_factor);
void SetRendererID(int renderer_id);
protected:
// ImageTransportSurface implementation
......
......@@ -138,6 +138,11 @@ void ImageTransportSurfaceFBO::SendSwapBuffers(uint64 surface_handle,
is_swap_buffers_send_pending_ = false;
}
void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) {
if (renderer_id)
context_->share_group()->SetRendererID(renderer_id);
}
bool ImageTransportSurfaceFBO::PostSubBuffer(
int x, int y, int width, int height) {
// Mac does not support sub-buffer swaps.
......@@ -163,7 +168,7 @@ void* ImageTransportSurfaceFBO::GetDisplay() {
void ImageTransportSurfaceFBO::OnBufferPresented(
const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
context_->share_group()->SetRendererID(params.renderer_id);
SetRendererID(params.renderer_id);
storage_provider_->SwapBuffersAckedByBrowser(params.disable_throttling);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment