aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLExternalTextureData.cpp
blob: 1087830947a87e79dfd1d88dec3c8d94afbee4b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
#include "GrResourceProvider.h"
#include "GrSemaphore.h"
#include "gl/GrGLTypes.h"

GrGLExternalTextureData::GrGLExternalTextureData(const GrGLTextureInfo& info,
                                                 sk_sp<GrSemaphore> semaphore,
                                                 GrContext* context)
        : fInfo(info)
        , fSemaphore(std::move(semaphore)) {
    SkASSERT(fSemaphore->unique());
    context->resourceProvider()->releaseOwnershipOfSemaphore(fSemaphore);
}

void GrGLExternalTextureData::attachToContext(GrContext* context) {
    context->resourceProvider()->takeOwnershipOfSemaphore(fSemaphore);
    // Ideally we don't want to get the Gpu off of the context here. However, eventually this
    // semaphore will live on a GrTexture object and the wait will be called from there. At that
    // point we can use the GrGpu already stored directly on the GrTexture.
    context->getGpu()->waitSemaphore(fSemaphore);
}