summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/Image.h
blob: a579beab2749af99a0c9c98e1f9169e85df8ce6a (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// Image.h: Defines the egl::Image class representing the EGLimage object.

#ifndef LIBANGLE_IMAGE_H_
#define LIBANGLE_IMAGE_H_

#include "common/angleutils.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/formatutils.h"

#include <set>

namespace rx
{
class ImageImpl;
}

namespace egl
{
class Image;

class ImageSibling : public RefCountObject
{
  public:
    ImageSibling(GLuint id);
    virtual ~ImageSibling();

  protected:
    // Set the image target of this sibling
    void setTargetImage(egl::Image *imageTarget);

    // Orphan all EGL image sources and targets
    gl::Error orphanImages();

  private:
    friend class Image;

    // Called from Image only to add a new source image
    void addImageSource(egl::Image *imageSource);

    // Called from Image only to remove a source image when the Image is being deleted
    void removeImageSource(egl::Image *imageSource);

    std::set<Image *> mSourcesOf;
    BindingPointer<Image> mTargetOf;
};

class Image final : public RefCountObject
{
  public:
    Image(rx::ImageImpl *impl, EGLenum target, ImageSibling *buffer, const AttributeMap &attribs);
    ~Image();

    const gl::Format &getFormat() const;
    size_t getWidth() const;
    size_t getHeight() const;
    size_t getSamples() const;

    rx::ImageImpl *getImplementation();
    const rx::ImageImpl *getImplementation() const;

  private:
    friend class ImageSibling;

    // Called from ImageSibling only notify the image that a new target sibling exists for state
    // tracking.
    void addTargetSibling(ImageSibling *sibling);

    // Called from ImageSibling only to notify the image that a sibling (source or target) has
    // been respecified and state tracking should be updated.
    gl::Error orphanSibling(ImageSibling *sibling);

    rx::ImageImpl *mImplementation;

    gl::Format mFormat;
    size_t mWidth;
    size_t mHeight;
    size_t mSamples;

    BindingPointer<ImageSibling> mSource;
    std::set<ImageSibling *> mTargets;
};
}

#endif  // LIBANGLE_IMAGE_H_