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

Unified Diff: content/browser/renderer_host/compositing_iosurface_mac.mm

Issue 16189012: Add a path to use CALayers to display content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused method Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/compositing_iosurface_mac.mm
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.mm b/content/browser/renderer_host/compositing_iosurface_mac.mm
index e58adcba741a84703061b4383358b1425614a772..11e825764a74df9ce96052212f1c358d794370ab 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.mm
+++ b/content/browser/renderer_host/compositing_iosurface_mac.mm
@@ -18,6 +18,7 @@
#include "content/browser/renderer_host/compositing_iosurface_context_mac.h"
#include "content/browser/renderer_host/compositing_iosurface_shader_programs_mac.h"
#include "content/browser/renderer_host/compositing_iosurface_transformer_mac.h"
+#include "content/browser/renderer_host/render_widget_host_view_mac.h"
#include "content/common/content_constants_internal.h"
#include "content/port/browser/render_widget_host_view_frame_subscriber.h"
#include "gpu/command_buffer/service/gpu_switches.h"
@@ -226,25 +227,36 @@ CompositingIOSurfaceMac* CompositingIOSurfaceMac::Create(
int window_number,
SurfaceOrder surface_order) {
TRACE_EVENT0("browser", "CompositingIOSurfaceMac::Create");
+
+ scoped_refptr<CompositingIOSurfaceContext> context =
+ CompositingIOSurfaceContext::Get(window_number, surface_order);
+ if (!context) {
+ LOG(WARNING) << "Failed to create context for IOSurface";
+ return NULL;
+ }
+
+ return Create(context);
+}
+
+CompositingIOSurfaceMac* CompositingIOSurfaceMac::Create(
+ const scoped_refptr<CompositingIOSurfaceContext>& context) {
IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize();
if (!io_surface_support) {
LOG(WARNING) << "No IOSurface support";
return NULL;
}
- scoped_refptr<CompositingIOSurfaceContext> context =
- CompositingIOSurfaceContext::Get(window_number, surface_order);
-
return new CompositingIOSurfaceMac(io_surface_support,
context);
}
CompositingIOSurfaceMac::CompositingIOSurfaceMac(
IOSurfaceSupport* io_surface_support,
- scoped_refptr<CompositingIOSurfaceContext> context)
+ const scoped_refptr<CompositingIOSurfaceContext>& context)
: io_surface_support_(io_surface_support),
context_(context),
io_surface_handle_(0),
+ scale_factor_(1.f),
texture_(0),
finish_copy_timer_(
FROM_HERE,
@@ -362,8 +374,9 @@ void CompositingIOSurfaceMac::SetIOSurface(uint64 io_surface_handle,
const gfx::Size& size,
float scale_factor) {
pixel_io_surface_size_ = size;
+ scale_factor_ = scale_factor;
dip_io_surface_size_ = gfx::ToFlooredSize(
- gfx::ScaleSize(pixel_io_surface_size_, 1.0 / scale_factor));
+ gfx::ScaleSize(pixel_io_surface_size_, 1.0 / scale_factor_));
CGLSetCurrentContext(context_->cgl_context());
MapIOSurfaceToTexture(io_surface_handle);
CGLSetCurrentContext(0);
@@ -379,28 +392,48 @@ int CompositingIOSurfaceMac::GetRendererID() {
}
void CompositingIOSurfaceMac::DrawIOSurface(
- NSView* view,
- float scale_factor,
- int window_number,
- SurfaceOrder surface_order,
- RenderWidgetHostViewFrameSubscriber* frame_subscriber) {
+ RenderWidgetHostViewMac* render_widget_host_view) {
+ DCHECK(!render_widget_host_view->use_core_animation_);
- if (display_link_ == NULL)
- SetupCVDisplayLink();
+ NSView* view = render_widget_host_view->cocoa_view();
- SwitchToContextOnNewWindow(view, window_number, surface_order);
+ content::CompositingIOSurfaceMac::SurfaceOrder surface_order =
+ render_widget_host_view->allow_overlapping_views_
+ ? content::CompositingIOSurfaceMac::SURFACE_ORDER_BELOW_WINDOW
+ : content::CompositingIOSurfaceMac::SURFACE_ORDER_ABOVE_WINDOW;
+ SwitchToContextOnNewWindow(
+ view,
+ render_widget_host_view->window_number(),
+ surface_order);
CGLSetCurrentContext(context_->cgl_context());
+ [context_->nsgl_context() setView:view];
- bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_);
+ gfx::Size window_size(NSSizeToCGSize([view frame].size));
+
+ DrawIOSurface(
+ window_size,
+ render_widget_host_view->scale_factor(),
+ render_widget_host_view->frame_subscriber());
+
+ CGLSetCurrentContext(context_->cgl_context());
+ CGLFlushDrawable(context_->cgl_context());
+ CGLSetCurrentContext(0);
+}
+void CompositingIOSurfaceMac::DrawIOSurface(
+ const gfx::Size& window_size,
+ float window_scale_factor,
+ RenderWidgetHostViewFrameSubscriber* frame_subscriber) {
+ if (display_link_ == NULL)
+ SetupCVDisplayLink();
+
+ bool has_io_surface = MapIOSurfaceToTexture(io_surface_handle_);
TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface",
"has_io_surface", has_io_surface);
- [context_->nsgl_context() setView:view];
- gfx::Size window_size(NSSizeToCGSize([view frame].size));
gfx::Size pixel_window_size = gfx::ToFlooredSize(
- gfx::ScaleSize(window_size, scale_factor));
+ gfx::ScaleSize(window_size, window_scale_factor));
glViewport(0, 0, pixel_window_size.width(), pixel_window_size.height());
SurfaceQuad quad;
@@ -500,8 +533,6 @@ void CompositingIOSurfaceMac::DrawIOSurface(
}
}
- CGLFlushDrawable(context_->cgl_context());
-
// For latency_tests.cc:
UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "CompositorSwapBuffersComplete",
TRACE_EVENT_SCOPE_THREAD);
@@ -510,8 +541,6 @@ void CompositingIOSurfaceMac::DrawIOSurface(
std::vector<base::Closure> copy_done_callbacks;
FinishAllCopiesWithinContext(&copy_done_callbacks);
- CGLSetCurrentContext(0);
-
if (!copy_done_callback.is_null())
copy_done_callbacks.push_back(copy_done_callback);
for (size_t i = 0; i < copy_done_callbacks.size(); ++i)

Powered by Google App Engine
This is Rietveld 408576698