OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" | 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/quads/texture_draw_quad.h" | 8 #include "cc/quads/texture_draw_quad.h" |
9 #include "gpu/command_buffer/client/gles2_interface.h" | 9 #include "gpu/command_buffer/client/gles2_interface.h" |
10 #include "platform/Histogram.h" | 10 #include "platform/Histogram.h" |
11 #include "platform/graphics/gpu/SharedGpuContext.h" | 11 #include "platform/graphics/gpu/SharedGpuContext.h" |
12 #include "public/platform/InterfaceProvider.h" | 12 #include "public/platform/InterfaceProvider.h" |
13 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
14 #include "public/platform/WebGraphicsContext3DProvider.h" | 14 #include "public/platform/WebGraphicsContext3DProvider.h" |
15 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 15 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
16 #include "third_party/khronos/GLES2/gl2.h" | 16 #include "third_party/khronos/GLES2/gl2.h" |
17 #include "third_party/khronos/GLES2/gl2ext.h" | 17 #include "third_party/khronos/GLES2/gl2ext.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
19 #include "third_party/skia/include/core/SkImage.h" | 19 #include "third_party/skia/include/core/SkImage.h" |
20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
21 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
22 #include "wtf/typed_arrays/ArrayBuffer.h" | 22 #include "wtf/typed_arrays/ArrayBuffer.h" |
23 #include "wtf/typed_arrays/Uint8Array.h" | 23 #include "wtf/typed_arrays/Uint8Array.h" |
24 | 24 |
25 namespace blink { | 25 namespace blink { |
26 | 26 |
27 OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl( | 27 OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl( |
| 28 int canvasId, |
28 uint32_t clientId, | 29 uint32_t clientId, |
29 uint32_t sinkId, | 30 uint32_t sinkId, |
30 uint32_t localId, | 31 uint32_t localId, |
31 uint64_t nonce, | 32 uint64_t nonce, |
32 int width, | 33 int width, |
33 int height) | 34 int height) |
34 : m_surfaceId(cc::FrameSinkId(clientId, sinkId), | 35 : m_surfaceId(cc::FrameSinkId(clientId, sinkId), |
35 cc::LocalFrameId(localId, nonce)), | 36 cc::LocalFrameId(localId, nonce)), |
36 m_width(width), | 37 m_width(width), |
37 m_height(height), | 38 m_height(height), |
38 m_nextResourceId(1u), | 39 m_nextResourceId(1u), |
39 m_binding(this) { | 40 m_binding(this) { |
40 DCHECK(!m_sink.is_bound()); | 41 DCHECK(!m_sink.is_bound()); |
41 mojom::blink::OffscreenCanvasCompositorFrameSinkProviderPtr provider; | 42 mojom::blink::OffscreenCanvasCompositorFrameSinkProviderPtr provider; |
42 Platform::current()->interfaceProvider()->getInterface( | 43 Platform::current()->interfaceProvider()->getInterface( |
43 mojo::GetProxy(&provider)); | 44 mojo::GetProxy(&provider)); |
44 provider->CreateCompositorFrameSink(m_surfaceId, | 45 provider->CreateCompositorFrameSink(canvasId, m_surfaceId, |
45 m_binding.CreateInterfacePtrAndBind(), | 46 m_binding.CreateInterfacePtrAndBind(), |
46 mojo::GetProxy(&m_sink)); | 47 mojo::GetProxy(&m_sink)); |
47 } | 48 } |
48 | 49 |
49 void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceToSharedBitmap( | 50 void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceToSharedBitmap( |
50 cc::TransferableResource& resource, | 51 cc::TransferableResource& resource, |
51 RefPtr<StaticBitmapImage> image) { | 52 RefPtr<StaticBitmapImage> image) { |
52 std::unique_ptr<cc::SharedBitmap> bitmap = | 53 std::unique_ptr<cc::SharedBitmap> bitmap = |
53 Platform::current()->allocateSharedBitmap(IntSize(m_width, m_height)); | 54 Platform::current()->allocateSharedBitmap(IntSize(m_width, m_height)); |
54 if (!bitmap) | 55 if (!bitmap) |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 329 } |
329 | 330 |
330 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( | 331 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( |
331 const sk_sp<SkImage>& image) { | 332 const sk_sp<SkImage>& image) { |
332 if (image && image->width() == m_width && image->height() == m_height) | 333 if (image && image->width() == m_width && image->height() == m_height) |
333 return true; | 334 return true; |
334 return false; | 335 return false; |
335 } | 336 } |
336 | 337 |
337 } // namespace blink | 338 } // namespace blink |
OLD | NEW |