Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_ViewerOperation.h « operations « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7fc5ae36ad9e24659d493a1a13cb469840c17eae (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Copyright 2011, Blender Foundation.
 */

#pragma once

#include "BKE_global.h"
#include "BLI_rect.h"
#include "COM_MultiThreadedOperation.h"
#include "DNA_image_types.h"

namespace blender::compositor {

class ViewerOperation : public MultiThreadedOperation {
 private:
  /* TODO(manzanilla): To be removed together with tiled implementation. */
  float *output_buffer_;
  float *depth_buffer_;

  Image *image_;
  ImageUser *image_user_;
  bool active_;
  float center_x_;
  float center_y_;
  ChunkOrdering chunk_order_;
  bool do_depth_buffer_;
  ImBuf *ibuf_;
  bool use_alpha_input_;
  const RenderData *rd_;
  const char *view_name_;

  const ColorManagedViewSettings *view_settings_;
  const ColorManagedDisplaySettings *display_settings_;

  SocketReader *image_input_;
  SocketReader *alpha_input_;
  SocketReader *depth_input_;

  int display_width_;
  int display_height_;

 public:
  ViewerOperation();
  void init_execution() override;
  void deinit_execution() override;
  void execute_region(rcti *rect, unsigned int tile_number) override;
  void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
  bool is_output_operation(bool /*rendering*/) const override
  {
    if (G.background) {
      return false;
    }
    return is_active_viewer_output();
  }
  void set_image(Image *image)
  {
    image_ = image;
  }
  void set_image_user(ImageUser *image_user)
  {
    image_user_ = image_user;
  }
  bool is_active_viewer_output() const override
  {
    return active_;
  }
  void set_active(bool active)
  {
    active_ = active;
  }
  void setCenterX(float centerX)
  {
    center_x_ = centerX;
  }
  void setCenterY(float centerY)
  {
    center_y_ = centerY;
  }
  void set_chunk_order(ChunkOrdering tile_order)
  {
    chunk_order_ = tile_order;
  }
  float getCenterX() const
  {
    return center_x_;
  }
  float getCenterY() const
  {
    return center_y_;
  }
  ChunkOrdering get_chunk_order() const
  {
    return chunk_order_;
  }
  eCompositorPriority get_render_priority() const override;
  void set_use_alpha_input(bool value)
  {
    use_alpha_input_ = value;
  }
  void set_render_data(const RenderData *rd)
  {
    rd_ = rd;
  }
  void set_view_name(const char *view_name)
  {
    view_name_ = view_name;
  }

  void set_view_settings(const ColorManagedViewSettings *view_settings)
  {
    view_settings_ = view_settings;
  }
  void set_display_settings(const ColorManagedDisplaySettings *display_settings)
  {
    display_settings_ = display_settings;
  }

  void update_memory_buffer_partial(MemoryBuffer *output,
                                    const rcti &area,
                                    Span<MemoryBuffer *> inputs) override;

  void clear_display_buffer();

 private:
  void update_image(const rcti *rect);
  void init_image();
};

}  // namespace blender::compositor