| 1 |
/* |
| 2 |
* Copyright 2025 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SkGaneshRecorder_DEFINED |
| 9 |
#define SkGaneshRecorder_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkCPURecorder.h" |
| 12 |
#include "include/core/SkRecorder.h" |
| 13 |
#include "include/core/SkSurface.h" |
| 14 |
#include "include/gpu/ganesh/GrRecordingContext.h" |
| 15 |
|
| 16 |
class GrDirectContext; |
| 17 |
|
| 18 |
class SkGaneshRecorder final : public SkRecorder { |
| 19 |
public: |
| 20 |
SkGaneshRecorder(GrRecordingContext* ctx) : fGaneshCtx(ctx) {} |
| 21 |
|
| 22 |
Type type() const override { return SkRecorder::Type::kGanesh; } |
| 23 |
|
| 24 |
GrRecordingContext* recordingContext() const { return fGaneshCtx; } |
| 25 |
|
| 26 |
GrDirectContext* directContext() const { return GrAsDirectContext(fGaneshCtx); } |
| 27 |
|
| 28 |
skcpu::Recorder* cpuRecorder() override { |
| 29 |
return skcpu::Recorder::TODO(); |
| 30 |
} |
| 31 |
|
| 32 |
private: |
| 33 |
GrRecordingContext* fGaneshCtx; |
| 34 |
|
| 35 |
SkCanvas* makeCaptureCanvas(SkCanvas*) override { return nullptr; } |
| 36 |
void createCaptureBreakpoint(SkSurface*) override {} |
| 37 |
}; |
| 38 |
|
| 39 |
inline SkGaneshRecorder* AsGaneshRecorder(SkRecorder* recorder) { |
| 40 |
if (!recorder) { |
| 41 |
return nullptr; |
| 42 |
} |
| 43 |
if (recorder->type() != SkRecorder::Type::kGanesh) { |
| 44 |
return nullptr; |
| 45 |
} |
| 46 |
return static_cast<SkGaneshRecorder*>(recorder); |
| 47 |
} |
| 48 |
|
| 49 |
#endif |