1 // 2 // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Image.h: Defines the egl::Image class representing the EGLimage object. 8 9 #ifndef LIBANGLE_IMAGE_H_ 10 #define LIBANGLE_IMAGE_H_ 11 12 #include "common/angleutils.h" 13 #include "libANGLE/AttributeMap.h" 14 #include "libANGLE/Error.h" 15 #include "libANGLE/RefCountObject.h" 16 #include "libANGLE/formatutils.h" 17 18 #include <set> 19 20 namespace rx 21 { 22 class ImageImpl; 23 } 24 25 namespace egl 26 { 27 class Image; 28 29 class ImageSibling : public RefCountObject 30 { 31 public: 32 ImageSibling(GLuint id); 33 virtual ~ImageSibling(); 34 35 protected: 36 // Set the image target of this sibling 37 void setTargetImage(egl::Image *imageTarget); 38 39 // Orphan all EGL image sources and targets 40 gl::Error orphanImages(); 41 42 private: 43 friend class Image; 44 45 // Called from Image only to add a new source image 46 void addImageSource(egl::Image *imageSource); 47 48 // Called from Image only to remove a source image when the Image is being deleted 49 void removeImageSource(egl::Image *imageSource); 50 51 std::set<Image *> mSourcesOf; 52 BindingPointer<Image> mTargetOf; 53 }; 54 55 class Image final : public RefCountObject 56 { 57 public: 58 Image(rx::ImageImpl *impl, EGLenum target, ImageSibling *buffer, const AttributeMap &attribs); 59 ~Image(); 60 61 const gl::Format &getFormat() const; 62 size_t getWidth() const; 63 size_t getHeight() const; 64 size_t getSamples() const; 65 66 rx::ImageImpl *getImplementation(); 67 const rx::ImageImpl *getImplementation() const; 68 69 private: 70 friend class ImageSibling; 71 72 // Called from ImageSibling only notify the image that a new target sibling exists for state 73 // tracking. 74 void addTargetSibling(ImageSibling *sibling); 75 76 // Called from ImageSibling only to notify the image that a sibling (source or target) has 77 // been respecified and state tracking should be updated. 78 gl::Error orphanSibling(ImageSibling *sibling); 79 80 rx::ImageImpl *mImplementation; 81 82 gl::Format mFormat; 83 size_t mWidth; 84 size_t mHeight; 85 size_t mSamples; 86 87 BindingPointer<ImageSibling> mSource; 88 std::set<ImageSibling *> mTargets; 89 }; 90 } 91 92 #endif // LIBANGLE_IMAGE_H_ 93