1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
8 #import "base/mac/scoped_nsobject.h"
9 #include "content/common/gpu/gpu_command_buffer_stub.h"
10 #include "content/common/gpu/image_transport_surface.h"
11 #include "ui/gl/gl_surface.h"
18 class ImageTransportSurfaceOverlayMac
: public gfx::GLSurface
,
19 public ImageTransportSurface
{
21 ImageTransportSurfaceOverlayMac(GpuChannelManager
* manager
,
22 GpuCommandBufferStub
* stub
,
23 gfx::PluginWindowHandle handle
);
25 // GLSurface implementation
26 bool Initialize() override
;
27 void Destroy() override
;
28 bool IsOffscreen() override
;
29 gfx::SwapResult
SwapBuffers() override
;
30 gfx::SwapResult
PostSubBuffer(int x
, int y
, int width
, int height
) override
;
31 bool SupportsPostSubBuffer() override
;
32 gfx::Size
GetSize() override
;
33 void* GetHandle() override
;
35 bool ScheduleOverlayPlane(int z_order
,
36 gfx::OverlayTransform transform
,
38 const gfx::Rect
& bounds_rect
,
39 const gfx::RectF
& crop_rect
) override
;
40 bool IsSurfaceless() const override
;
42 // ImageTransportSurface implementation
43 void OnBufferPresented(
44 const AcceleratedSurfaceMsg_BufferPresented_Params
& params
) override
;
45 void OnResize(gfx::Size pixel_size
, float scale_factor
) override
;
46 void SetLatencyInfo(const std::vector
<ui::LatencyInfo
>&) override
;
47 void WakeUpGpu() override
;
50 ~ImageTransportSurfaceOverlayMac() override
;
51 scoped_ptr
<ImageTransportHelper
> helper_
;
52 base::scoped_nsobject
<CAContext
> ca_context_
;
53 base::scoped_nsobject
<CALayer
> layer_
;
55 // A phony NSView handle used to identify this.
56 gfx::AcceleratedWidget widget_
;
58 gfx::Size pixel_size_
;
60 std::vector
<ui::LatencyInfo
> latency_info_
;
62 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is
63 // consumed and reset when SwapBuffers is called. For now, only one overlay
64 // plane is supported.
65 gfx::GLImage
* pending_overlay_image_
;
68 } // namespace content
70 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_