mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Surface IDs are composed of a namespace component and a local identifier component. This splits up the two pieces in the mojom to make it clearer. This also simplifies the path for connecting to the surfaces service. In order to perform any operations with surfaces, each client must know what its id namespace value is. This was done by first connecting to a SurfacesService interface and then calling CreateSurfaceConnection which returned a Surface pointer and the namespace. Having to connect to this extra interface and receive the Surface impl asynchronously complicated startup code for applications by adding extra states in startup. Instead of that, this allows connecting to the Surface interface directly and promises that the ID namespace will be provided as the first message in the pipe directed at the SurfaceClient. Callers can then either block on startup or handle setting the ID namespace asynchronously depending on what other things that thread could be doing at the time. In a follow-up, I plan to define the id namespace value 0 as meaning "the namespace of this connection" which will allow creating surfaces and submitting frames before learning the connection's namespace. The only thing the namespace will be passing surface IDs to other clients for them to embed. This also removes the Size parameter from CreateSurface, which wasn't used by anything. The size of submitted frames is part of the embedder / embedee contract. R=esprehn@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/807733002
27 lines
632 B
C++
27 lines
632 B
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/compositor/surface_allocator.h"
|
|
|
|
#include "base/logging.h"
|
|
|
|
namespace sky {
|
|
|
|
SurfaceAllocator::SurfaceAllocator(uint32_t id_namespace)
|
|
: id_namespace_(id_namespace), next_id_(1) {
|
|
DCHECK(id_namespace);
|
|
}
|
|
|
|
SurfaceAllocator::~SurfaceAllocator() {
|
|
}
|
|
|
|
mojo::SurfaceIdPtr SurfaceAllocator::CreateSurfaceId() {
|
|
auto id = mojo::SurfaceId::New();
|
|
id->local = next_id_++;
|
|
id->id_namespace = id_namespace_;
|
|
return id.Pass();
|
|
}
|
|
|
|
} // namespace sky
|