1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2020 Google LLC
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "include/gpu/GrBackendSurfaceMutableState.h"
9cb93a386Sopenharmony_ci
10cb93a386Sopenharmony_ci#include <new>
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ciGrBackendSurfaceMutableState::GrBackendSurfaceMutableState(const GrBackendSurfaceMutableState& that)
13cb93a386Sopenharmony_ci        : fBackend(that.fBackend), fIsValid(that.fIsValid) {
14cb93a386Sopenharmony_ci    if (!fIsValid) {
15cb93a386Sopenharmony_ci        return;
16cb93a386Sopenharmony_ci    }
17cb93a386Sopenharmony_ci    switch (fBackend) {
18cb93a386Sopenharmony_ci        case GrBackend::kVulkan:
19cb93a386Sopenharmony_ci#ifdef SK_VULKAN
20cb93a386Sopenharmony_ci            SkASSERT(that.fBackend == GrBackend::kVulkan);
21cb93a386Sopenharmony_ci            fVkState = that.fVkState;
22cb93a386Sopenharmony_ci#endif
23cb93a386Sopenharmony_ci            break;
24cb93a386Sopenharmony_ci        default:
25cb93a386Sopenharmony_ci            (void)that;
26cb93a386Sopenharmony_ci            SkUNREACHABLE;
27cb93a386Sopenharmony_ci    }
28cb93a386Sopenharmony_ci}
29cb93a386Sopenharmony_ci
30cb93a386Sopenharmony_ciGrBackendSurfaceMutableState& GrBackendSurfaceMutableState::operator=(
31cb93a386Sopenharmony_ci        const GrBackendSurfaceMutableState& that) {
32cb93a386Sopenharmony_ci    if (this != &that) {
33cb93a386Sopenharmony_ci        this->~GrBackendSurfaceMutableState();
34cb93a386Sopenharmony_ci        new (this) GrBackendSurfaceMutableState(that);
35cb93a386Sopenharmony_ci    }
36cb93a386Sopenharmony_ci    return *this;
37cb93a386Sopenharmony_ci}
38cb93a386Sopenharmony_ci
39