| 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 "content/browser/renderer_host/offscreen_canvas_surface_impl.h" | 5 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "cc/surfaces/surface.h" | 8 #include "cc/surfaces/surface.h" |
| 9 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 10 #include "content/browser/compositor/surface_utils.h" | 10 #include "content/browser/compositor/surface_utils.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl() | 16 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl() |
| 17 : id_allocator_(new cc::SurfaceIdAllocator(AllocateFrameSinkId())) {} | 17 : id_allocator_(new cc::SurfaceIdAllocator()) {} |
| 18 | 18 |
| 19 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {} | 19 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {} |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 void OffscreenCanvasSurfaceImpl::Create( | 22 void OffscreenCanvasSurfaceImpl::Create( |
| 23 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) { | 23 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) { |
| 24 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasSurfaceImpl>(), | 24 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasSurfaceImpl>(), |
| 25 std::move(request)); | 25 std::move(request)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void OffscreenCanvasSurfaceImpl::GetSurfaceId( | 28 void OffscreenCanvasSurfaceImpl::GetSurfaceId( |
| 29 const GetSurfaceIdCallback& callback) { | 29 const GetSurfaceIdCallback& callback) { |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 31 | 31 |
| 32 surface_id_ = id_allocator_->GenerateId(); | 32 cc::LocalFrameId local_frame_id = id_allocator_->GenerateId(); |
| 33 surface_id_ = cc::SurfaceId(AllocateFrameSinkId(), local_frame_id); |
| 33 | 34 |
| 34 callback.Run(surface_id_); | 35 callback.Run(surface_id_); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, | 38 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, |
| 38 const cc::SurfaceSequence& sequence) { | 39 const cc::SurfaceSequence& sequence) { |
| 39 cc::SurfaceManager* manager = GetSurfaceManager(); | 40 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 40 cc::Surface* surface = manager->GetSurfaceForId(surface_id); | 41 cc::Surface* surface = manager->GetSurfaceForId(surface_id); |
| 41 if (!surface) { | 42 if (!surface) { |
| 42 DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 43 DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
| 43 return; | 44 return; |
| 44 } | 45 } |
| 45 surface->AddDestructionDependency(sequence); | 46 surface->AddDestructionDependency(sequence); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { | 49 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { |
| 49 std::vector<uint32_t> sequences; | 50 std::vector<uint32_t> sequences; |
| 50 sequences.push_back(sequence.sequence); | 51 sequences.push_back(sequence.sequence); |
| 51 cc::SurfaceManager* manager = GetSurfaceManager(); | 52 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 52 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | 53 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace content | 56 } // namespace content |
| OLD | NEW |