1 
2 //
3 // This source file is part of appleseed.
4 // Visit https://appleseedhq.net/ for additional information and resources.
5 //
6 // This software is released under the MIT license.
7 //
8 // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
9 // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28 //
29 
30 #pragma once
31 
32 // appleseed.foundation headers.
33 #include "foundation/core/concepts/iunknown.h"
34 #include "foundation/math/aabb.h"
35 #include "foundation/math/vector.h"
36 #include "foundation/platform/types.h"
37 
38 // Standard headers.
39 #include <cstddef>
40 
41 // Forward declarations.
42 namespace foundation    { class StatisticsVector; }
43 namespace foundation    { class Tile; }
44 namespace renderer      { class AOVAccumulatorContainer; }
45 namespace renderer      { class Frame; }
46 namespace renderer      { class ShadingResultFrameBuffer; }
47 namespace renderer      { class TileStack; }
48 
49 namespace renderer
50 {
51 
52 //
53 // Pixel renderer interface.
54 //
55 
56 class IPixelRenderer
57   : public foundation::IUnknown
58 {
59   public:
60     // Print this component's settings to the renderer's global logger.
61     virtual void print_settings() const = 0;
62 
63     // This method is called before a tile gets rendered.
64     virtual void on_tile_begin(
65         const Frame&                frame,
66         const size_t                tile_x,
67         const size_t                tile_y,
68         foundation::Tile&           tile,
69         TileStack&                  aov_tiles) = 0;
70 
71     // This method is called after a tile has been rendered.
72     virtual void on_tile_end(
73         const Frame&                frame,
74         const size_t                tile_x,
75         const size_t                tile_y,
76         foundation::Tile&           tile,
77         TileStack&                  aov_tiles) = 0;
78 
79     // Render a pixel.
80     virtual void render_pixel(
81         const Frame&                frame,
82         foundation::Tile&           tile,
83         TileStack&                  aov_tiles,
84         const foundation::AABB2i&   tile_bbox,
85         const foundation::uint32    pass_hash,
86         const foundation::Vector2i& pi,               // image-space pixel coordinates
87         const foundation::Vector2i& pt,               // tile-space pixel coordinates
88         AOVAccumulatorContainer&    aov_accumulators,
89         ShadingResultFrameBuffer&   framebuffer) = 0;
90 
91     // Retrieve performance statistics.
92     virtual foundation::StatisticsVector get_statistics() const = 0;
93 
94     // Return the maximum number of samples per pixel.
95     virtual size_t get_max_samples_per_pixel() const = 0;
96 };
97 
98 
99 //
100 // Interface of a IPixelRenderer factory.
101 //
102 
103 class IPixelRendererFactory
104   : public foundation::IUnknown
105 {
106   public:
107     // Return a new pixel renderer instance.
108     virtual IPixelRenderer* create(const size_t thread_index) = 0;
109 };
110 
111 }   // namespace renderer
112