Tonemap everywhere in PixelCopy

* Hookup tonemap support for PixelCopying a SurfaceView
* Fix issue in PixelCopying a SurfaceView where the wrong dataspace was
  retrieved from the last queued buffer, since the bufferqueue dataspace
  may drift due to another process like camera setting the dataspace
  without being propagated to the app process
* Cleanup LayerDrawable to share code

Bug: 238395777
Test: Switching HDR cameras doesn't color shift
Test: TextureView playback in Photos
Change-Id: I0fd1bd86410630acfbb7de72339874a3d0ecac58
diff --git a/libs/hwui/Tonemapper.h b/libs/hwui/Tonemapper.h
new file mode 100644
index 0000000..c0d5325
--- /dev/null
+++ b/libs/hwui/Tonemapper.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <SkCanvas.h>
+
+namespace android::uirenderer {
+
+// Given a source and destination image info, and the max content luminance, generate a tonemaping
+// shader and tag it on the supplied paint.
+void tonemapPaint(const SkImageInfo& source, const SkImageInfo& destination, float maxLuminanceNits,
+                  SkPaint& paint);
+
+}  // namespace android::uirenderer