Blue Brain BioExplorer
DeflectPixelOp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  * Responsible Author: Daniel Nachbaur <daniel.nachbaur@epfl.ch>
5  *
6  * This file is part of https://github.com/BlueBrain/Core
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License version 3.0 as published
10  * by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #pragma once
23 
24 #include "DeflectParameters.h"
25 
26 #include <deflect/Stream.h>
27 #include <map>
28 #include <ospray/SDK/fb/PixelOp.h>
29 
30 namespace core
31 {
40 class DeflectPixelOp : public ::ospray::PixelOp
41 {
42 public:
43  struct Instance : public ::ospray::PixelOp::Instance
44  {
45  Instance(::ospray::FrameBuffer* fb_, DeflectPixelOp& parent);
47 
48  void beginFrame() final;
49  void endFrame() final;
50  void postAccum(::ospray::Tile& tile) final;
51  std::string toString() const final { return "DeflectPixelOp"; }
53  {
54  void operator()(unsigned char* pixels) { _mm_free(pixels); }
55  };
56  using Pixels = std::unique_ptr<unsigned char, PixelsDeleter>;
57 
58  private:
59  DeflectPixelOp& _parent;
60  std::vector<Pixels> _pixels;
61 
62  unsigned char* _copyPixels(::ospray::Tile& tile, const ::ospray::vec2i& tileSize);
63  };
64 
74  void commit() final;
75 
76  ::ospray::PixelOp::Instance* createInstance(::ospray::FrameBuffer* fb, PixelOp::Instance* prev) final;
77 
78 private:
80  void _finish();
81 
82  std::unique_ptr<deflect::Stream> _deflectStream;
83  std::map<pthread_t, std::shared_future<bool>> _finishFutures;
84  std::mutex _mutex;
85  DeflectParameters _params;
86 };
87 } // namespace core
::ospray::PixelOp::Instance * createInstance(::ospray::FrameBuffer *fb, PixelOp::Instance *prev) final
This class represents a frame buffer for an engine specific code. It provides an API for utilizing an...
Definition: FrameBuffer.h:39
Instance(::ospray::FrameBuffer *fb_, DeflectPixelOp &parent)
std::string toString() const final
void postAccum(::ospray::Tile &tile) final
std::unique_ptr< unsigned char, PixelsDeleter > Pixels