QCanvasOffscreenCanvas Class
QCanvasOffscreenCanvas は、QCanvasPainter がターゲットできるオフスクリーンキャンバスを表します。詳細...
| ヘッダー | #include <QCanvasOffscreenCanvas> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter) |
| 以来: | Qt 6.11 |
| ステータス | テクニカルプレビュー |
パブリックな型
パブリック関数
| QCanvasOffscreenCanvas(const QCanvasOffscreenCanvas &canvas) | |
| ~QCanvasOffscreenCanvas() | |
| void | detach() |
| QColor | fillColor() const |
| QCanvasOffscreenCanvas::Flags | flags() const |
| bool | isNull() const |
| void | setFillColor(const QColor &color) |
| QRhiTexture * | texture() const |
| QCanvasOffscreenCanvas & | operator=(const QCanvasOffscreenCanvas &canvas) |
関連する非メンバー
| bool | operator!=(const QCanvasOffscreenCanvas &lhs, const QCanvasOffscreenCanvas &rhs) |
| bool | operator==(const QCanvasOffscreenCanvas &lhs, const QCanvasOffscreenCanvas &rhs) |
詳細な説明
オフスクリーンキャンバスは、基本的にカラーバッファ(QRhiTexture )と、場合によってはその他の関連グラフィックリソースです。コンテンツが canvas のカラーバッファにレンダリングされた後、canvas をペインターにregistered してQCanvasImage を取得し、drawImage() 呼び出しまたはimage pattern として使用することができます。
オフスクリーン・キャンバスを作成するには、QCanvasPainter::createCanvas() を呼び出します。描画コマンドを使用してオフスクリーンキャンバスをターゲットにするには、低レベル API を使用している場合はQCanvasRhiPaintDriver::beginPaint() オーバーロードを、便利なウィジェットやQt Quick アイテムクラスを使用している場合はQCanvasPainterWidget::beginCanvasPainting() またはQCanvasPainterItemRenderer::beginCanvasPainting() を呼び出します。
QCanvasImage およびQCanvasBrush と同様に、QCanvasOffscreenCanvas は明示的に共有されます。詳細については、暗黙的データ共有およびQSharedDataPointer を参照してください。
注意: QCanvasImage と同様に、QCanvasOffscreenCanvas は、単にハンドルを含むオブジェクトと見なすことができます。デタッチが発生した場合でも、実際のリソース、たとえば、基礎となるテクスチャやその中の画像データが実際にコピーされたり複製されたりすることはありません。実際のグラフィックス・リソース(たとえば、QRhiTexture )の実際の所有者は、createCanvas ()を介してQCanvasOffscreenCanvasを引き渡したQCanvasPainter 。
キャンバスは常に、それを作成したQCanvasPainter に属します。キャンバスを手動で破棄するには、destroyCanvas() を呼び出します。ペインターは、キャンバスを破棄する際に自動的にキャンバスを破棄するからです。
メンバ型ドキュメント
enum class QCanvasOffscreenCanvas::Flag
flags QCanvasOffscreenCanvas::Flags
キャンバスのフラグを指定します。
| 定数 | 値 | 説明 |
|---|---|---|
QCanvasOffscreenCanvas::Flag::PreserveContents | 0x01 | キャンバスにペイントするときに、キャンバスの内容が保持されることを示します。これは、GPU アーキテクチャーによってはパフォーマンスに悪影響を及ぼす可能性があります。詳細はQRhiTextureRenderTarget::PreserveColorContents を参照してください。サンプルカウントが 1 より大きい場合、このフラグの設定はサポートされません。 |
QCanvasOffscreenCanvas::Flag::MipMaps | 0x02 | canvas のバッキングテクスチャのミップマッピングを有効にすることを示します。このフラグの設定は、サンプルカウントが 1 より大きい場合はサポートされません。GenerateMipmaps フラグが設定された状態でaddImage() を呼び出すと、ミップマップシーケンスが生成されることに注意してください。つまり、canvas の内容が変更されるたびに addImage() を呼び出して、ミップマップ・チェインを再生成する必要があります。頻繁にミップマップを生成すると、パフォーマンスに悪影響を及ぼす可能性があります。 |
Flags 型はQFlags<Flag> の typedef である。Flagの値のORの組み合わせを格納する。
メンバ関数ドキュメント
QCanvasOffscreenCanvas::QCanvasOffscreenCanvas(const QCanvasOffscreenCanvas &canvas)
コピーコンストラクタ。
[noexcept] QCanvasOffscreenCanvas::~QCanvasOffscreenCanvas()
破壊者。
void QCanvasOffscreenCanvas::detach()
複数のキャンバスが共通のデータを共有している場合、この画像はデータのコピーを作成し、共有メカニズムから自身を切り離し、この画像だけがデータを参照していることを確認します。
参照が 1 つだけの場合は何もしません。
注意: キャンバスには、基礎となるグラフィックス・リソースへのハンドルと、塗りつぶしの色などのデータしか含まれていません。QRhiTexture のようなグラフィックス・リソースそのものがコピーされたり複製されたりすることはありません。
QColor QCanvasOffscreenCanvas::fillColor() const
現在の塗りつぶし色を返します。
setFillColor()も参照 ください。
QCanvasOffscreenCanvas::Flags QCanvasOffscreenCanvas::flags() const
キャンバスが作成されたフラグを返します。
フラグは不変で、一度キャンバスが作成されると変更できません。
bool QCanvasOffscreenCanvas::isNull() const
このキャンバスに有効なデータがある場合に true を返します。
通常は常に true です。
texture()も参照 ください。
void QCanvasOffscreenCanvas::setFillColor(const QColor &color)
塗りつぶし(クリア)色をcolor に設定します。
デフォルトでは、これはcreateCanvas() に渡された値に設定されます。
fillColor()も参照 。
QRhiTexture *QCanvasOffscreenCanvas::texture() const
このオフスクリーンキャンバスのテクスチャを返します。
isNull()も参照してください 。
QCanvasOffscreenCanvas &QCanvasOffscreenCanvas::operator=(const QCanvasOffscreenCanvas &canvas)
与えられたcanvas のシャローコピーをこの canvas に割り当て、この canvas への参照を返します。シャローコピーの詳細については、暗黙的データ共有のドキュメントを参照してください。
注: 基礎となるリソース、QRhiTexture などのグラフィック リソースがコピーされたり複製されたりすることはありません。
関連する非会員
[noexcept] bool operator!=(const QCanvasOffscreenCanvas &lhs, const QCanvasOffscreenCanvas &rhs)
キャンバスハンドルlhs がrhs と異なる場合はtrue を返し、そうでない場合はfalse を返します。
operator==()も参照 。
[noexcept] bool operator==(const QCanvasOffscreenCanvas &lhs, const QCanvasOffscreenCanvas &rhs)
キャンバスハンドルlhs がrhs と等しければtrue を返し、そうでなければfalse を返します。
注意: 等しいとは、2つのキャンバスオブジェクトの塗りつぶしの色が同じで、同じグラフィックリソースを参照していることを意味します。内容(ピクセルデータ)は比較されません。
operator!=()も参照してください 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.