Revert "[SkContexts] Prefactor SkCPU Code" This reverts commit fd53afd27fa8c482376600eee5ba75e00ce84ee3. Reason for revert: Broke Chrome roller Failure Link: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/2918029/overview Original change's description: > [SkContexts] Prefactor SkCPU Code > > This CL prefactors (pre-refactors) the SkCPU code to make way for the new SkContext work. All of the changes remove SKCPU concepts, but the follow up CLs will add back similar concepts. > > Change-Id: Iec003f5b1573bee967672f5a77196f01ffb6aff3 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1326156 > Commit-Queue: Alexis Cruz-Ayala <alexisdavidc@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I889c2ec2e8c7c047fd6b70d7fce684ae1277865f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1348516 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/bazel/exporter_tool/main.go b/bazel/exporter_tool/main.go index 5c81581..37776d5 100644 --- a/bazel/exporter_tool/main.go +++ b/bazel/exporter_tool/main.go
@@ -189,7 +189,6 @@ {Var: "skia_core_public", Rules: []string{ "//include/core:core_hdrs", - "//include/cpu:core_hdrs", }}, {Var: "skia_core_sources", Rules: []string{
diff --git a/gm/hdr_pip_blur.cpp b/gm/hdr_pip_blur.cpp index 2c47146b..09ea8e2 100644 --- a/gm/hdr_pip_blur.cpp +++ b/gm/hdr_pip_blur.cpp
@@ -5,6 +5,8 @@ * found in the LICENSE file. */ #include "gm/gm.h" + +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkColorFilter.h" #include "include/core/SkPaint.h" @@ -12,7 +14,6 @@ #include "include/core/SkRRect.h" #include "include/core/SkRect.h" #include "include/core/SkSurface.h" -#include "include/cpu/Recorder.h" #include "include/effects/SkColorMatrix.h" #include "include/effects/SkImageFilters.h" #include "tools/DecodeUtils.h"
diff --git a/gn/core.gni b/gn/core.gni index ac39289..f1122e0 100644 --- a/gn/core.gni +++ b/gn/core.gni
@@ -4,7 +4,6 @@ # The sources of truth are: # //include/android/BUILD.bazel # //include/core/BUILD.bazel -# //include/cpu/BUILD.bazel # //include/encode/BUILD.bazel # //include/private/BUILD.bazel # //include/private/chromium/BUILD.bazel @@ -23,9 +22,7 @@ _src = get_path_info("../src", "abspath") _include = get_path_info("../include", "abspath") -# List generated by Bazel rules: -# //include/core:core_hdrs -# //include/cpu:core_hdrs +# Generated by Bazel rule //include/core:core_hdrs skia_core_public = [ "$_include/core/RasterContext.h", "$_include/core/SkAlphaType.h", @@ -36,6 +33,8 @@ "$_include/core/SkBlendMode.h", "$_include/core/SkBlender.h", "$_include/core/SkBlurTypes.h", + "$_include/core/SkCPUContext.h", + "$_include/core/SkCPURecorder.h", "$_include/core/SkCanvas.h", "$_include/core/SkCanvasVirtualEnforcer.h", "$_include/core/SkCapabilities.h", @@ -123,7 +122,6 @@ "$_include/core/SkVertices.h", "$_include/core/SkYUVAInfo.h", "$_include/core/SkYUVAPixmaps.h", - "$_include/cpu/Recorder.h", ] # List generated by Bazel rules: @@ -200,7 +198,6 @@ "$_src/capture/SkCaptureManager.cpp", "$_src/capture/SkCaptureManager.h", "$_src/core/RasterContext.cpp", - "$_src/core/Recorder.cpp", "$_src/core/Sk4px.h", "$_src/core/SkAAClip.cpp", "$_src/core/SkAAClip.h", @@ -268,6 +265,10 @@ "$_src/core/SkBlurMaskFilterImpl.h", "$_src/core/SkBuffer.cpp", "$_src/core/SkBuffer.h", + "$_src/core/SkCPUContext.cpp", + "$_src/core/SkCPUContextImpl.h", + "$_src/core/SkCPURecorder.cpp", + "$_src/core/SkCPURecorderImpl.h", "$_src/core/SkCachedData.cpp", "$_src/core/SkCachedData.h", "$_src/core/SkCanvas.cpp",
diff --git a/include/core/BUILD.bazel b/include/core/BUILD.bazel index dc798d6..bde0c43 100644 --- a/include/core/BUILD.bazel +++ b/include/core/BUILD.bazel
@@ -16,6 +16,8 @@ "SkBlendMode.h", "SkBlender.h", "SkBlurTypes.h", + "SkCPUContext.h", + "SkCPURecorder.h", "SkCanvas.h", "SkCanvasVirtualEnforcer.h", "SkCapabilities.h",
diff --git a/include/core/SkCPUContext.h b/include/core/SkCPUContext.h new file mode 100644 index 0000000..e307bf0 --- /dev/null +++ b/include/core/SkCPUContext.h
@@ -0,0 +1,31 @@ +/* + * Copyright 2025 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef skcpu_Context_DEFINED +#define skcpu_Context_DEFINED + +#include "include/private/SkAPI.h" + +#include <memory> + +namespace skcpu { +class Recorder; + +class SK_API Context { +public: + struct Options {}; + + std::unique_ptr<Recorder> makeRecorder() const; + + static std::unique_ptr<const Context> Make(const Options&); + static std::unique_ptr<const Context> Make(); + +protected: + Context() = default; +}; +} // namespace skcpu + +#endif
diff --git a/include/cpu/Recorder.h b/include/core/SkCPURecorder.h similarity index 98% rename from include/cpu/Recorder.h rename to include/core/SkCPURecorder.h index aada752..8d66b99 100644 --- a/include/cpu/Recorder.h +++ b/include/core/SkCPURecorder.h
@@ -24,8 +24,6 @@ class SK_API Recorder : public SkRecorder { public: - Recorder() = default; - /** Returns a non-null global context. Can be used as a means of transitioning onto * new APIs when a skcpu::Context/Recorder has not been piped down into the code paths */
diff --git a/include/cpu/BUILD.bazel b/include/cpu/BUILD.bazel deleted file mode 100644 index 6ba5c78..0000000 --- a/include/cpu/BUILD.bazel +++ /dev/null
@@ -1,30 +0,0 @@ -load("//bazel:skia_rules.bzl", "generate_cpp_files_for_headers", "skia_filegroup") - -package( - default_applicable_licenses = ["//:license"], -) - -licenses(["notice"]) - -PUBLIC_HEADERS = [ - "Recorder.h", -] - -skia_filegroup( - name = "public_hdrs", - srcs = PUBLIC_HEADERS, - visibility = ["//visibility:public"], -) - -skia_filegroup( - name = "core_hdrs", - srcs = PUBLIC_HEADERS, - visibility = [ - "//src/core:__pkg__", - ], -) - -generate_cpp_files_for_headers( - name = "headers_to_compile", - headers = PUBLIC_HEADERS, -)
diff --git a/include/gpu/ganesh/GrRecordingContext.h b/include/gpu/ganesh/GrRecordingContext.h index fe76deb..9d90de7 100644 --- a/include/gpu/ganesh/GrRecordingContext.h +++ b/include/gpu/ganesh/GrRecordingContext.h
@@ -37,8 +37,9 @@ class SkRecorder; namespace skcpu { +class ContextImpl; class Recorder; -} +} // namespace skcpu namespace sktext::gpu { class SubRunAllocator; @@ -281,6 +282,7 @@ std::unique_ptr<GrProxyProvider> fProxyProvider; // Depends on fProxyProvider (drawing tasks reference proxies). Must be destroyed first. std::unique_ptr<GrDrawingManager> fDrawingManager; + std::unique_ptr<const skcpu::ContextImpl> fCPUContext; std::unique_ptr<SkGaneshRecorder> fRecorder; #if defined(GPU_TEST_UTILS)
diff --git a/include/gpu/graphite/Context.h b/include/gpu/graphite/Context.h index e5ecc3f..13507cd 100644 --- a/include/gpu/graphite/Context.h +++ b/include/gpu/graphite/Context.h
@@ -39,6 +39,7 @@ struct SkImageInfo; namespace skcpu { +class ContextImpl; class Recorder; } // namespace skcpu @@ -411,6 +412,7 @@ std::unique_ptr<ResourceProvider> fResourceProvider; std::unique_ptr<ClientMappedBufferManager> fMappedBufferManager; std::unique_ptr<QueueManager> fQueueManager; + std::unique_ptr<const skcpu::ContextImpl> fCPUContext; PersistentPipelineStorage* fPersistentPipelineStorage;
diff --git a/include/gpu/graphite/Recorder.h b/include/gpu/graphite/Recorder.h index aa595c4..be87a3f 100644 --- a/include/gpu/graphite/Recorder.h +++ b/include/gpu/graphite/Recorder.h
@@ -8,10 +8,10 @@ #ifndef skgpu_graphite_Recorder_DEFINED #define skgpu_graphite_Recorder_DEFINED +#include "include/core/SkCPURecorder.h" #include "include/core/SkRecorder.h" #include "include/core/SkRefCnt.h" #include "include/core/SkSurface.h" -#include "include/cpu/Recorder.h" #include "include/gpu/graphite/GraphiteTypes.h" #include "include/gpu/graphite/Recording.h" #include "include/private/SingleOwner.h"
diff --git a/relnotes/removeskcpu.md b/relnotes/removeskcpu.md deleted file mode 100644 index 08fcd1b..0000000 --- a/relnotes/removeskcpu.md +++ /dev/null
@@ -1 +0,0 @@ -`skcpu::Context`, `skcpu::Recorder`, `GrRecordingContext::makeCPURecorder()`, and `skgpu::graphite::Context::makeCPURecorder()` have been removed. \ No newline at end of file
diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel index d11b98c..590575e 100644 --- a/src/core/BUILD.bazel +++ b/src/core/BUILD.bazel
@@ -75,6 +75,8 @@ "SkBlurMask.h", "SkBlurMaskFilterImpl.h", "SkBuffer.h", + "SkCPUContextImpl.h", + "SkCPURecorderImpl.h", "SkCachedData.h", "SkCanvasPriv.h", "SkChecksum.h", @@ -294,7 +296,6 @@ srcs = [ # Implementation of public and private headers "RasterContext.cpp", - "Recorder.cpp", "SkAAClip.cpp", "SkATrace.cpp", "SkAlphaRuns.cpp", @@ -330,6 +331,8 @@ "SkBlurMask.cpp", "SkBlurMaskFilterImpl.cpp", "SkBuffer.cpp", + "SkCPUContext.cpp", + "SkCPURecorder.cpp", "SkCachedData.cpp", "SkCanvas.cpp", "SkCanvasPriv.cpp", @@ -588,7 +591,6 @@ hdrs = [ "//include/codec:core_hdrs", "//include/core:core_hdrs", - "//include/cpu:core_hdrs", "//include/effects:core_hdrs", "//include/private:private_hdrs", "//include/sksl:core_hdrs",
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 847b6fe..2209808 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp
@@ -9,6 +9,7 @@ #include "include/core/SkAlphaType.h" #include "include/core/SkBlender.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkClipOp.h" #include "include/core/SkColorType.h" #include "include/core/SkImageInfo.h" @@ -26,9 +27,9 @@ #include "include/core/SkSurface.h" #include "include/core/SkSurfaceProps.h" #include "include/core/SkTileMode.h" -#include "include/cpu/Recorder.h" #include "include/private/SkAssert.h" #include "include/private/SkTo.h" +#include "src/core/SkCPURecorderImpl.h" #include "src/core/SkDraw.h" #include "src/core/SkMaskFilterBase.h" #include "src/core/SkMatrixPriv.h" @@ -134,6 +135,9 @@ } fDraw.fProps = &fDevice->surfaceProps(); + if (fDevice->fRecorder) { + fDraw.fCtx = fDevice->fRecorder->ctx(); + } } bool needsTiling() const { return fNeedsTiling; } @@ -227,14 +231,14 @@ } SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) - : SkBitmapDevice(skcpu::Recorder::TODO(), bitmap) {} + : SkBitmapDevice(asRRI(skcpu::Recorder::TODO()), bitmap) {} SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps, SkRasterHandleAllocator::Handle hndl) - : SkBitmapDevice(skcpu::Recorder::TODO(), bitmap, surfaceProps, hndl) {} + : SkBitmapDevice(asRRI(skcpu::Recorder::TODO()), bitmap, surfaceProps, hndl) {} -SkBitmapDevice::SkBitmapDevice(skcpu::Recorder* recorder, const SkBitmap& bitmap) +SkBitmapDevice::SkBitmapDevice(skcpu::RecorderImpl* recorder, const SkBitmap& bitmap) : SkDevice(bitmap.info(), SkSurfaceProps()) , fRecorder(recorder) , fBitmap(bitmap) @@ -243,7 +247,7 @@ SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); } -SkBitmapDevice::SkBitmapDevice(skcpu::Recorder* recorder, +SkBitmapDevice::SkBitmapDevice(skcpu::RecorderImpl* recorder, const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps, SkRasterHandleAllocator::Handle hndl) @@ -256,8 +260,6 @@ SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); } -SkRecorder* SkBitmapDevice::baseRecorder() const { return fRecorder; } - sk_sp<SkBitmapDevice> SkBitmapDevice::Create(const SkImageInfo& origInfo, const SkSurfaceProps& surfaceProps, SkRasterHandleAllocator* allocator) {
diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index 8a119db..e6e36cf 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h
@@ -15,6 +15,7 @@ #include "include/core/SkRefCnt.h" #include "include/core/SkSamplingOptions.h" #include "include/core/SkSpan.h" +#include "src/core/SkCPURecorderImpl.h" #include "src/core/SkDevice.h" #include "src/core/SkGlyphRunPainter.h" #include "src/core/SkRasterClipStack.h" @@ -40,9 +41,6 @@ struct SkImageInfo; struct SkPoint; struct SkRSXform; -namespace skcpu { -class Recorder; -} namespace sktext { class GlyphRunList; } /////////////////////////////////////////////////////////////////////////////// @@ -60,12 +58,11 @@ * valid for the bitmap to have no pixels associated with it. In that case, * any drawing to this device will have no effect. */ - SkBitmapDevice(const SkBitmap& bitmap, - const SkSurfaceProps& surfaceProps, + SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps, void* externalHandle = nullptr); - SkBitmapDevice(skcpu::Recorder* recorder, const SkBitmap& bitmap); - SkBitmapDevice(skcpu::Recorder* recorder, + SkBitmapDevice(skcpu::RecorderImpl*, const SkBitmap& bitmap); + SkBitmapDevice(skcpu::RecorderImpl*, const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps, void* externalHandle = nullptr); @@ -128,7 +125,7 @@ void* getRasterHandle() const override { return fRasterHandle; } - SkRecorder* baseRecorder() const override; + SkRecorder* baseRecorder() const override { return fRecorder; } private: friend class SkDrawTiler; @@ -157,7 +154,7 @@ sk_sp<SkMipmap>); void* fRasterHandle = nullptr; - skcpu::Recorder* fRecorder = nullptr; + skcpu::RecorderImpl* fRecorder = nullptr; SkBitmap fBitmap; SkRasterClipStack fRCStack; skcpu::GlyphRunListPainter fGlyphPainter;
diff --git a/src/core/SkCPUContext.cpp b/src/core/SkCPUContext.cpp new file mode 100644 index 0000000..7a550f6 --- /dev/null +++ b/src/core/SkCPUContext.cpp
@@ -0,0 +1,32 @@ +/* + * Copyright 2025 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "include/core/SkCPUContext.h" + +#include "include/core/SkTypes.h" +#include "src/core/SkCPUContextImpl.h" +#include "src/core/SkCPURecorderImpl.h" + +namespace skcpu { + +std::unique_ptr<const Context> Context::Make(const Context::Options& opts) { + return std::make_unique<ContextImpl>(); +} + +std::unique_ptr<const Context> Context::Make() { + return Context::Make({}); +} + +std::unique_ptr<Recorder> Context::makeRecorder() const { + return std::make_unique<RecorderImpl>(static_cast<const ContextImpl*>(this)); +} + +const ContextImpl* ContextImpl::TODO() { + static const ContextImpl* gContext = static_cast<const ContextImpl*>(Context::Make().release()); + return gContext; +} + +} // namespace skcpu
diff --git a/src/core/SkCPUContextImpl.h b/src/core/SkCPUContextImpl.h new file mode 100644 index 0000000..96ee4d4 --- /dev/null +++ b/src/core/SkCPUContextImpl.h
@@ -0,0 +1,23 @@ +/* + * Copyright 2025 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef skcpu_ContextImpl_DEFINED +#define skcpu_ContextImpl_DEFINED + +#include "include/core/SkCPUContext.h" +#include "include/core/SkSurfaceProps.h" +#include "src/core/SkResourceCache.h" + +namespace skcpu { +class ContextImpl final : public Context { +public: + ContextImpl() = default; + + static const ContextImpl* TODO(); +}; +} // namespace skcpu + +#endif
diff --git a/src/core/Recorder.cpp b/src/core/SkCPURecorder.cpp similarity index 71% rename from src/core/Recorder.cpp rename to src/core/SkCPURecorder.cpp index aa576cd..43711ba 100644 --- a/src/core/Recorder.cpp +++ b/src/core/SkCPURecorder.cpp
@@ -4,17 +4,18 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "include/cpu/Recorder.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkTypes.h" #include "src/capture/SkCaptureManager.h" +#include "src/core/SkCPUContextImpl.h" #include <memory> namespace skcpu { Recorder* Recorder::TODO() { - static Recorder* gRecorder = std::make_unique<Recorder>().release(); + static Recorder* gRecorder = ContextImpl::TODO()->makeRecorder().release(); return gRecorder; }
diff --git a/src/core/SkCPURecorderImpl.h b/src/core/SkCPURecorderImpl.h new file mode 100644 index 0000000..eac6103 --- /dev/null +++ b/src/core/SkCPURecorderImpl.h
@@ -0,0 +1,32 @@ +/* + * Copyright 2025 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef skcpu_RecorderImpl_DEFINED +#define skcpu_RecorderImpl_DEFINED + +#include "include/core/SkCPURecorder.h" +#include "src/core/SkCPUContextImpl.h" + +namespace skcpu { + +class RecorderImpl final : public skcpu::Recorder { +public: + RecorderImpl(const ContextImpl* ctx) : fCtx(ctx) {} + + const ContextImpl* ctx() const { return fCtx; } + +private: + const ContextImpl* const fCtx; +}; + +} // namespace skcpu + +inline skcpu::RecorderImpl* asRRI(skcpu::Recorder* rr) { + return static_cast<skcpu::RecorderImpl*>(rr); +} + +#endif
diff --git a/src/core/SkDraw.h b/src/core/SkDraw.h index 85cf675..221caba 100644 --- a/src/core/SkDraw.h +++ b/src/core/SkDraw.h
@@ -49,6 +49,7 @@ namespace skcpu { class GlyphRunListPainter; +class ContextImpl; /** Helper function that creates a mask from a path and a required maskfilter. @@ -250,6 +251,8 @@ const SkRasterClip* fRC{nullptr}; // required const SkSurfaceProps* fProps{nullptr}; // optional + const ContextImpl* fCtx{nullptr}; // optional for now + #ifdef SK_DEBUG void validate() const; #else
diff --git a/src/core/SkRecordCanvas.h b/src/core/SkRecordCanvas.h index 42b5e18..579b1a6 100644 --- a/src/core/SkRecordCanvas.h +++ b/src/core/SkRecordCanvas.h
@@ -8,6 +8,7 @@ #ifndef SkRecordCanvas_DEFINED #define SkRecordCanvas_DEFINED +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvasVirtualEnforcer.h" #include "include/core/SkColor.h" #include "include/core/SkM44.h" @@ -15,7 +16,6 @@ #include "include/core/SkSamplingOptions.h" #include "include/core/SkScalar.h" #include "include/core/SkTypes.h" -#include "include/cpu/Recorder.h" #include "include/private/SkNoncopyable.h" #include "include/private/SkTDArray.h" #include "include/utils/SkNoDrawCanvas.h" @@ -99,7 +99,10 @@ bool onDoSaveBehind(const SkRect*) override; void willRestore() override {} void didRestore() override; - SkRecorder* baseRecorder() const override { return skcpu::Recorder::TODO(); } + SkRecorder* baseRecorder() const override { + // TODO(kjlubick) this class should implement SkRecorder (or maybe Record should). + return skcpu::Recorder::TODO(); + } void didConcat44(const SkM44&) override; void didSetM44(const SkM44&) override;
diff --git a/src/gpu/ganesh/GrRecordingContext.cpp b/src/gpu/ganesh/GrRecordingContext.cpp index 47e0cea..75dc193 100644 --- a/src/gpu/ganesh/GrRecordingContext.cpp +++ b/src/gpu/ganesh/GrRecordingContext.cpp
@@ -18,6 +18,8 @@ #include "include/private/SkMacros.h" #include "include/private/gpu/ganesh/GrTypesPriv.h" #include "src/core/SkArenaAlloc.h" +#include "src/core/SkCPUContextImpl.h" +#include "src/core/SkCPURecorderImpl.h" #include "src/gpu/ganesh/GrAuditTrail.h" #include "src/gpu/ganesh/GrCaps.h" #include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h" @@ -54,6 +56,7 @@ , fAuditTrail(new GrAuditTrail()) , fArenas(ddlRecording) { fProxyProvider = std::make_unique<GrProxyProvider>(this); + fCPUContext = std::make_unique<skcpu::ContextImpl>(); fRecorder = std::make_unique<SkGaneshRecorder>(this); } @@ -183,7 +186,7 @@ } std::unique_ptr<skcpu::Recorder> GrRecordingContext::makeCPURecorder() { - return std::make_unique<skcpu::Recorder>(); + return std::make_unique<skcpu::RecorderImpl>(fCPUContext.get()); } SkRecorder* GrRecordingContext::asRecorder() {
diff --git a/src/gpu/ganesh/SkGaneshRecorder.h b/src/gpu/ganesh/SkGaneshRecorder.h index 997c6c9..731eb60 100644 --- a/src/gpu/ganesh/SkGaneshRecorder.h +++ b/src/gpu/ganesh/SkGaneshRecorder.h
@@ -8,9 +8,9 @@ #ifndef SkGaneshRecorder_DEFINED #define SkGaneshRecorder_DEFINED +#include "include/core/SkCPURecorder.h" #include "include/core/SkRecorder.h" #include "include/core/SkSurface.h" -#include "include/cpu/Recorder.h" #include "include/gpu/ganesh/GrRecordingContext.h" #include "src/capture/SkCaptureManager.h" @@ -26,7 +26,9 @@ GrDirectContext* directContext() const { return GrAsDirectContext(fGaneshCtx); } - skcpu::Recorder* cpuRecorder() override { return skcpu::Recorder::TODO(); } + skcpu::Recorder* cpuRecorder() override { + return skcpu::Recorder::TODO(); + } private: GrRecordingContext* fGaneshCtx;
diff --git a/src/gpu/graphite/BUILD.bazel b/src/gpu/graphite/BUILD.bazel index 35d2ea3..4f4bdd1 100644 --- a/src/gpu/graphite/BUILD.bazel +++ b/src/gpu/graphite/BUILD.bazel
@@ -199,7 +199,6 @@ ], hdrs = [ ":_graphite_hdrs", - "//include/cpu:public_hdrs", "//include/gpu:shared_gpu_hdrs", "//include/gpu/graphite:public_hdrs", "//src/gpu/graphite/compute:compute_hdrs",
diff --git a/src/gpu/graphite/Context.cpp b/src/gpu/graphite/Context.cpp index 1ba3181..d79bde2 100644 --- a/src/gpu/graphite/Context.cpp +++ b/src/gpu/graphite/Context.cpp
@@ -43,6 +43,8 @@ #include "src/capture/SkCapture.h" #include "src/capture/SkCaptureManager.h" #include "src/core/SkAutoPixmapStorage.h" +#include "src/core/SkCPUContextImpl.h" +#include "src/core/SkCPURecorderImpl.h" #include "src/core/SkColorSpaceXformSteps.h" #include "src/core/SkConvertPixels.h" #include "src/core/SkImageInfoPriv.h" @@ -146,6 +148,7 @@ options.fPipelineCachingCallback, options.fPipelineCallback); + fCPUContext = std::make_unique<skcpu::ContextImpl>(); if (options.fEnableCapture) { fSharedContext->setCaptureManager(sk_make_sp<SkCaptureManager>()); } @@ -227,7 +230,7 @@ std::unique_ptr<skcpu::Recorder> Context::makeCPURecorder() { ASSERT_SINGLE_OWNER - return std::make_unique<skcpu::Recorder>(); + return std::make_unique<skcpu::RecorderImpl>(fCPUContext.get()); } std::unique_ptr<PrecompileContext> Context::makePrecompileContext() {
diff --git a/src/gpu/graphite/ContextPriv.h b/src/gpu/graphite/ContextPriv.h index 75fb725..9a961c9 100644 --- a/src/gpu/graphite/ContextPriv.h +++ b/src/gpu/graphite/ContextPriv.h
@@ -18,6 +18,8 @@ class SkPixmap; struct SkImageInfo; +namespace skcpu { class ContextImpl; } + namespace skgpu::graphite { class Caps; @@ -60,6 +62,7 @@ SharedContext* sharedContext() { return fContext->fSharedContext.get(); } + const skcpu::ContextImpl* cpuContext() const { return fContext->fCPUContext.get(); } #if defined(GPU_TEST_UTILS) void startCapture() {
diff --git a/src/gpu/graphite/Recorder.cpp b/src/gpu/graphite/Recorder.cpp index 8c61ba7..ee70456 100644 --- a/src/gpu/graphite/Recorder.cpp +++ b/src/gpu/graphite/Recorder.cpp
@@ -7,6 +7,7 @@ #include "include/gpu/graphite/Recorder.h" #include "include/core/SkBitmap.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkImage.h" #include "include/core/SkImageInfo.h" @@ -189,7 +190,9 @@ BackendApi Recorder::backend() const { return fSharedContext->backend(); } -skcpu::Recorder* Recorder::cpuRecorder() { return skcpu::Recorder::TODO(); } +skcpu::Recorder* Recorder::cpuRecorder() { + return skcpu::Recorder::TODO(); +} std::unique_ptr<Recording> Recorder::snap() { TRACE_EVENT0_ALWAYS("skia.gpu", TRACE_FUNC);
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 4705635..d1740b8 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp
@@ -8,6 +8,7 @@ #include "src/image/SkImage_Lazy.h" #include "include/core/SkBitmap.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkColorSpace.h" #include "include/core/SkData.h" #include "include/core/SkImageGenerator.h" @@ -16,7 +17,6 @@ #include "include/core/SkSize.h" #include "include/core/SkSurface.h" // IWYU pragma: keep #include "include/core/SkYUVAInfo.h" -#include "include/cpu/Recorder.h" #include "src/core/SkBitmapCache.h" #include "src/core/SkCachedData.h" #include "src/core/SkNextID.h" @@ -206,6 +206,7 @@ sk_sp<SkSurface> SkImage_Lazy::onMakeSurface(SkRecorder* recorder, const SkImageInfo& info) const { if (!recorder) { + // TODO(kjlubick) remove this after old SkImage::makeScaled(image info, sampling) API gone recorder = skcpu::Recorder::TODO(); } const SkSurfaceProps* props = nullptr;
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index bfeb3bb..b5bb20c 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp
@@ -8,6 +8,7 @@ #include "include/core/SkBitmap.h" #include "include/core/SkBlendMode.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkColorSpace.h" #include "include/core/SkData.h" #include "include/core/SkImage.h" @@ -22,7 +23,6 @@ #include "include/core/SkSize.h" #include "include/core/SkSurface.h" #include "include/core/SkTypes.h" -#include "include/cpu/Recorder.h" #include "src/core/SkImageInfoPriv.h" #include "src/core/SkRectMemcpy.h" #include "src/image/SkImage_Base.h" @@ -95,6 +95,7 @@ sk_sp<SkSurface> SkImage_Raster::onMakeSurface(SkRecorder* recorder, const SkImageInfo& info) const { if (!recorder) { + // TODO(kjlubick) remove this after old SkImage::makeScaled(image info, sampling) API gone recorder = skcpu::Recorder::TODO(); } const SkSurfaceProps* props = nullptr;
diff --git a/src/image/SkImage_Raster.h b/src/image/SkImage_Raster.h index 85b184a..99838ec 100644 --- a/src/image/SkImage_Raster.h +++ b/src/image/SkImage_Raster.h
@@ -45,7 +45,13 @@ // From SkImage.h bool isValid(SkRecorder* recorder) const override { - return recorder && recorder->cpuRecorder(); + if (!recorder) { + return false; + } + if (!recorder->cpuRecorder()) { + return false; + } + return true; } sk_sp<SkImage> makeColorTypeAndColorSpace(SkRecorder*, SkColorType targetColorType,
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index f4ee802..823cf47 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp
@@ -7,6 +7,7 @@ #include "src/image/SkSurface_Raster.h" #include "include/core/SkBitmap.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkCapabilities.h" #include "include/core/SkImageInfo.h" @@ -16,11 +17,11 @@ #include "include/core/SkRefCnt.h" #include "include/core/SkScalar.h" #include "include/core/SkSurface.h" -#include "include/cpu/Recorder.h" #include "include/private/SkAssert.h" #include "include/private/SkMath.h" #include "include/private/SkPixelStorage.h" #include "src/core/SkBitmapDevice.h" +#include "src/core/SkCPURecorderImpl.h" #include "src/core/SkDevice.h" #include "src/core/SkImageInfoPriv.h" #include "src/core/SkSurfacePriv.h" @@ -64,14 +65,14 @@ void* context, const SkSurfaceProps* props) : SkSurface_Raster( - skcpu::Recorder::TODO(), info, pixels, rb, releaseProc, context, props) {} + asRRI(skcpu::Recorder::TODO()), info, pixels, rb, releaseProc, context, props) {} SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef> pr, const SkSurfaceProps* props) - : SkSurface_Raster(skcpu::Recorder::TODO(), info, pr, props) {} + : SkSurface_Raster(asRRI(skcpu::Recorder::TODO()), info, pr, props) {} -SkSurface_Raster::SkSurface_Raster(skcpu::Recorder* recorder, +SkSurface_Raster::SkSurface_Raster(skcpu::RecorderImpl* recorder, const SkImageInfo& info, void* pixels, size_t rowBytes, @@ -84,7 +85,7 @@ fWeOwnThePixels = false; // We are "Direct" } -SkSurface_Raster::SkSurface_Raster(skcpu::Recorder* recorder, +SkSurface_Raster::SkSurface_Raster(skcpu::RecorderImpl* recorder, const SkImageInfo& info, sk_sp<SkPixelRef> pr, const SkSurfaceProps* props) @@ -181,7 +182,9 @@ return SkCapabilities::RasterBackend(); } -SkRecorder* SkSurface_Raster::onGetBaseRecorder() const { return fRecorder; } +SkRecorder* SkSurface_Raster::onGetBaseRecorder() const { + return fRecorder; +} /////////////////////////////////////////////////////////////////////////////// namespace SkSurfaces { @@ -250,7 +253,7 @@ SkASSERT(pr->rowBytes() == rowBytes); } - return sk_make_sp<SkSurface_Raster>(this, imageInfo, std::move(pr), surfaceProps); + return sk_make_sp<SkSurface_Raster>(asRRI(this), imageInfo, std::move(pr), surfaceProps); } } // namespace skcpu
diff --git a/src/image/SkSurface_Raster.h b/src/image/SkSurface_Raster.h index f877bb9..0480436 100644 --- a/src/image/SkSurface_Raster.h +++ b/src/image/SkSurface_Raster.h
@@ -28,9 +28,7 @@ class SkSurfaceProps; struct SkIRect; -namespace skcpu { -class Recorder; -} +namespace skcpu { class RecorderImpl; } class SkSurface_Raster : public SkSurface_Base { public: @@ -39,14 +37,14 @@ const SkSurfaceProps*); SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef>, const SkSurfaceProps*); - SkSurface_Raster(skcpu::Recorder* recorder, + SkSurface_Raster(skcpu::RecorderImpl* recorder, const SkImageInfo&, void* pixels, size_t rowBytes, SkSurfaces::PixelsReleaseProc releaseProc, void* context, const SkSurfaceProps*); - SkSurface_Raster(skcpu::Recorder* recorder, + SkSurface_Raster(skcpu::RecorderImpl* recorder, const SkImageInfo&, sk_sp<SkPixelRef>, const SkSurfaceProps*); @@ -68,8 +66,8 @@ SkRecorder* onGetBaseRecorder() const override; private: + skcpu::RecorderImpl* fRecorder; SkBitmap fBitmap; - skcpu::Recorder* fRecorder; bool fWeOwnThePixels; };
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 2c1cda5..f28f510 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h
@@ -8,6 +8,7 @@ #ifndef SkPDFDevice_DEFINED #define SkPDFDevice_DEFINED +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkMatrix.h" #include "include/core/SkRefCnt.h" @@ -15,7 +16,6 @@ #include "include/core/SkScalar.h" #include "include/core/SkSpan.h" #include "include/core/SkStream.h" -#include "include/cpu/Recorder.h" #include "src/core/SkClipStack.h" #include "src/core/SkClipStackDevice.h" #include "src/core/SkTHash.h" @@ -122,7 +122,10 @@ SkPDFParentTreeKey structParentsKey() const { return fMarkManager.structParentsKey(); } - SkRecorder* baseRecorder() const override { return skcpu::Recorder::TODO(); } + SkRecorder* baseRecorder() const override { + // TODO(kjlubick) the creation of this should likely involve a CPU context. + return skcpu::Recorder::TODO(); + } private: // TODO(vandebo): push most of SkPDFDevice's state into a core object in
diff --git a/src/svg/SkSVGDevice.h b/src/svg/SkSVGDevice.h index 3e72b46..a80a814 100644 --- a/src/svg/SkSVGDevice.h +++ b/src/svg/SkSVGDevice.h
@@ -8,10 +8,10 @@ #ifndef SkSVGDevice_DEFINED #define SkSVGDevice_DEFINED +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkRefCnt.h" #include "include/core/SkSpan.h" -#include "include/cpu/Recorder.h" #include "include/private/SkTArray.h" #include "include/private/SkTypeTraits.h" #include "include/svg/SkSVGCanvas.h"
diff --git a/src/xps/SkXPSDevice.h b/src/xps/SkXPSDevice.h index 0fe7a37..5f5472a 100644 --- a/src/xps/SkXPSDevice.h +++ b/src/xps/SkXPSDevice.h
@@ -12,6 +12,10 @@ #ifdef SK_BUILD_FOR_WIN +#include <ObjBase.h> +#include <XpsObjectModel.h> + +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkPaint.h" @@ -20,7 +24,6 @@ #include "include/core/SkShader.h" #include "include/core/SkSize.h" #include "include/core/SkTypeface.h" -#include "include/cpu/Recorder.h" #include "include/docs/SkXPSDocument.h" #include "include/private/SkTArray.h" #include "src/core/SkBitmapDevice.h" @@ -29,9 +32,6 @@ #include "src/utils/win/SkAutoCoInitialize.h" #include "src/utils/win/SkTScopedComPtr.h" -#include <ObjBase.h> -#include <XpsObjectModel.h> - namespace sktext { class GlyphRunList; } @@ -104,7 +104,10 @@ sk_sp<SkDevice> createDevice(const CreateInfo&, const SkPaint*) override; - SkRecorder* baseRecorder() const override { return skcpu::Recorder::TODO(); } + SkRecorder* baseRecorder() const override { + // TODO(kjlubick) the creation of this should likely involve a CPU context. + return skcpu::Recorder::TODO(); + } private: class TypefaceUse {
diff --git a/tests/CPUContextRecorderTest.cpp b/tests/CPUContextRecorderTest.cpp index d256f54..e88833b 100644 --- a/tests/CPUContextRecorderTest.cpp +++ b/tests/CPUContextRecorderTest.cpp
@@ -1,12 +1,14 @@ + /* * Copyright 2025 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - #include "include/core/SkBitmap.h" #include "include/core/SkBlurTypes.h" +#include "include/core/SkCPUContext.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkColorSpace.h" @@ -15,13 +17,13 @@ #include "include/core/SkPaint.h" #include "include/core/SkRRect.h" #include "include/core/SkSurface.h" +#include "src/core/SkCPUContextImpl.h" #include "src/core/SkResourceCache.h" + #include "tests/Test.h" #include <memory> -// TODO(alexisdavidc) Re-enable once the new SkContext / CPU Context & Recorder API is implemented. -#if 0 DEF_TEST(CPUSurface_UsesCPUContextAndRecorderToDraw_DrawsPixels, reporter) { skcpu::Context::Options opts; auto ctx = skcpu::Context::Make(opts); @@ -91,5 +93,3 @@ REPORTER_ASSERT(reporter, legacyAPI->width() == 70); REPORTER_ASSERT(reporter, !legacyAPI->isTextureBacked()); } - -#endif // 0
diff --git a/tests/GaneshContextRecorderTest.cpp b/tests/GaneshContextRecorderTest.cpp index 521397d..54df8ca 100644 --- a/tests/GaneshContextRecorderTest.cpp +++ b/tests/GaneshContextRecorderTest.cpp
@@ -8,11 +8,15 @@ #if defined(SK_GANESH) #include "include/core/SkBitmap.h" +#include "include/core/SkBlurTypes.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkColorSpace.h" #include "include/core/SkImageInfo.h" +#include "include/core/SkMaskFilter.h" #include "include/core/SkPaint.h" +#include "include/core/SkRRect.h" #include "include/core/SkSurface.h" #include "include/gpu/ganesh/GrDirectContext.h" #include "include/gpu/ganesh/SkImageGanesh.h" @@ -22,8 +26,6 @@ #include <memory> -// TODO(alexisdavidc) Re-enable once the new SkContext / CPU Context & Recorder API is implemented. -#if 0 DEF_GANESH_TEST_FOR_ALL_CONTEXTS(CPUSurface_UsesGaneshContextAndRasterRecorderToDraw_DrawsPixels, reporter, ctxInfo, @@ -43,7 +45,6 @@ REPORTER_ASSERT(reporter, surface->peekPixels(&pmap)); REPORTER_ASSERT(reporter, pmap.getColor(25, 25) == SK_ColorRED); } -#endif // 0 DEF_GANESH_TEST_FOR_ALL_CONTEXTS(ImageMakeColorSpace_GaneshImageWithContext_Success, reporter,
diff --git a/tests/GrDDLImageTest.cpp b/tests/GrDDLImageTest.cpp index b670430..1edaf15 100644 --- a/tests/GrDDLImageTest.cpp +++ b/tests/GrDDLImageTest.cpp
@@ -7,6 +7,7 @@ #include "include/core/SkAlphaType.h" #include "include/core/SkBitmap.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkColor.h" #include "include/core/SkColorType.h" #include "include/core/SkImage.h" @@ -15,7 +16,6 @@ #include "include/core/SkRefCnt.h" #include "include/core/SkSurface.h" #include "include/core/SkTypes.h" -#include "include/cpu/Recorder.h" #include "include/gpu/GpuTypes.h" #include "include/gpu/ganesh/GrBackendSurface.h" #include "include/gpu/ganesh/GrDirectContext.h"
diff --git a/tests/graphite/GraphiteContextRecorderTest.cpp b/tests/graphite/GraphiteContextRecorderTest.cpp index 423657c..c9b8631 100644 --- a/tests/graphite/GraphiteContextRecorderTest.cpp +++ b/tests/graphite/GraphiteContextRecorderTest.cpp
@@ -5,11 +5,15 @@ * found in the LICENSE file. */ #include "include/core/SkBitmap.h" +#include "include/core/SkBlurTypes.h" +#include "include/core/SkCPURecorder.h" #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkColorSpace.h" #include "include/core/SkImageInfo.h" +#include "include/core/SkMaskFilter.h" #include "include/core/SkPaint.h" +#include "include/core/SkRRect.h" #include "include/core/SkSurface.h" #include "include/gpu/graphite/Context.h" #include "include/gpu/graphite/Image.h" @@ -18,8 +22,6 @@ #include <memory> -// TODO(alexisdavidc) Re-enable once the new SkContext / CPU Context & Recorder API is implemented. -#if 0 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS( CPUSurface_UsesGraphiteContextAndRasterRecorderToDraw_DrawsPixels, reporter, @@ -42,7 +44,6 @@ REPORTER_ASSERT(reporter, surface->peekPixels(&pmap)); REPORTER_ASSERT(reporter, pmap.getColor(25, 25) == SK_ColorRED); } -#endif // 0 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(ImageMakeColorSpace_GraphiteImageWithRecorder_Success, reporter,
diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 52843b9..9e69a57 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel
@@ -323,7 +323,6 @@ srcs = [ "//include/codec:headers_to_compile", "//include/core:headers_to_compile", - "//include/cpu:headers_to_compile", "//include/docs:headers_to_compile", "//include/effects:headers_to_compile", "//include/encode:headers_to_compile",