Separate the playback and recording characterizations in the DDLTileHelper

When replaying DDLs w/ offsets it is no longer true that the
dimensions of the recording characterization must match those of
the playback characterization.

Change-Id: I3dba1a91af3d58aaf3619274303f8d2b10a76e24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344016
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tools/DDLTileHelper.cpp b/tools/DDLTileHelper.cpp
index 3ff7699..3ae7215 100644
--- a/tools/DDLTileHelper.cpp
+++ b/tools/DDLTileHelper.cpp
@@ -28,11 +28,11 @@
     fClip = clip;
     fPaddingOutsets = paddingOutsets;
 
-    fCharacterization = dstSurfaceCharacterization.createResized(this->paddedRectSize().width(),
-                                                                 this->paddedRectSize().height());
-    SkASSERT(fCharacterization.isValid());
+    fPlaybackChar  = dstSurfaceCharacterization.createResized(this->paddedRectSize().width(),
+                                                              this->paddedRectSize().height());
+    SkASSERT(fPlaybackChar.isValid());
 
-    GrBackendFormat backendFormat = direct->defaultBackendFormat(fCharacterization.colorType(),
+    GrBackendFormat backendFormat = direct->defaultBackendFormat(fPlaybackChar.colorType(),
                                                                  GrRenderable::kYes);
     SkDEBUGCODE(const GrCaps* caps = direct->priv().caps());
     SkASSERT(caps->isFormatTexturable(backendFormat));
@@ -46,9 +46,12 @@
                                                     const DDLPromiseImageHelper& helper) {
     SkASSERT(!fReconstitutedPicture);
 
+    auto recordingChar = fPlaybackChar.createResized(fClip.width(), fClip.height());
+    SkASSERT(recordingChar.isValid());
+
     // This is bending the DDLRecorder contract! The promise images in the SKP should be
     // created by the same recorder used to create the matching DDL.
-    SkDeferredDisplayListRecorder recorder(fCharacterization);
+    SkDeferredDisplayListRecorder recorder(recordingChar);
 
     fReconstitutedPicture = helper.reinflateSKP(&recorder, compressedPictureData, &fPromiseImages);
 
@@ -64,7 +67,10 @@
 void DDLTileHelper::TileData::createDDL() {
     SkASSERT(!fDisplayList && fReconstitutedPicture);
 
-    SkDeferredDisplayListRecorder recorder(fCharacterization);
+    auto recordingChar = fPlaybackChar.createResized(fClip.width(), fClip.height());
+    SkASSERT(recordingChar.isValid());
+
+    SkDeferredDisplayListRecorder recorder(recordingChar);
 
     // DDL TODO: the DDLRecorder's GrContext isn't initialized until getCanvas is called.
     // Maybe set it up in the ctor?
@@ -139,11 +145,11 @@
     // backed by the same backendTexture - unbeknownst to Ganesh.
     return SkSurface::MakeFromBackendTexture(context,
                                              promiseImageTexture->backendTexture(),
-                                             fCharacterization.origin(),
-                                             fCharacterization.sampleCount(),
-                                             fCharacterization.colorType(),
-                                             fCharacterization.refColorSpace(),
-                                             &fCharacterization.surfaceProps());
+                                             fPlaybackChar.origin(),
+                                             fPlaybackChar.sampleCount(),
+                                             fPlaybackChar.colorType(),
+                                             fPlaybackChar.refColorSpace(),
+                                             &fPlaybackChar.surfaceProps());
 }
 
 void DDLTileHelper::TileData::drawSKPDirectly(GrRecordingContext* context) {
@@ -198,9 +204,9 @@
                                          this->paddedRectSize().height(),
                                          GrMipmapped::kNo,
                                          GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin,
-                                         fCharacterization.colorType(),
+                                         fPlaybackChar.colorType(),
                                          kPremul_SkAlphaType,
-                                         fCharacterization.refColorSpace(),
+                                         fPlaybackChar.refColorSpace(),
                                          PromiseImageCallbackContext::PromiseImageFulfillProc,
                                          PromiseImageCallbackContext::PromiseImageReleaseProc,
                                          (void*)this->refCallbackContext().release());
@@ -211,7 +217,8 @@
 
 void DDLTileHelper::TileData::CreateBackendTexture(GrDirectContext* direct, TileData* tile) {
     SkASSERT(tile->fCallbackContext && !tile->fCallbackContext->promiseImageTexture());
-    const SkSurfaceCharacterization& c = tile->fCharacterization;
+
+    const SkSurfaceCharacterization& c = tile->fPlaybackChar;
     GrBackendTexture beTex = direct->createBackendTexture(c.width(), c.height(), c.colorType(),
                                                           GrMipMapped(c.isMipMapped()),
                                                           GrRenderable::kYes);