Revert "Revert "Add ExternalTexture class into RenderEngine inte..."

Revert submission 14199598-revert-14086921-renderengine-external-tex-QJNBWQMQEU

Reason for revert: Prepare for relanding
Reverted Changes:
I01e65a7f4:Revert "Update WaylandRenderSurface to accomodate ...
I7d58118c1:Revert "Update Readback VTS to align with RenderEn...
I1501890f4:Revert "Add ExternalTexture class into RenderEngin...

Added the following fixes:
1. CachedSet renders to intermediate texture variable rather than
mTexture directly, since mTexture is not guaranteed to be nonnull.
2. Add null check when setting new buffer in BLAST.

Bug: 185524947
Bug: 180767535
Test: builds, boots
Test: librenderengine_test
Change-Id: I52ea82e24336b496d996bbe3e445db0affe1abb8
diff --git a/libs/renderengine/skia/AutoBackendTexture.h b/libs/renderengine/skia/AutoBackendTexture.h
index bb75878..2d61cf8 100644
--- a/libs/renderengine/skia/AutoBackendTexture.h
+++ b/libs/renderengine/skia/AutoBackendTexture.h
@@ -21,9 +21,9 @@
 #include <SkImage.h>
 #include <SkSurface.h>
 #include <sys/types.h>
+#include <ui/GraphicTypes.h>
 
 #include "android-base/macros.h"
-#include "ui/GraphicTypes.h"
 
 namespace android {
 namespace renderengine {
@@ -41,13 +41,18 @@
     // of shared ownership with Skia objects, so we wrap it here instead.
     class LocalRef {
     public:
-        LocalRef() {}
+        LocalRef(AutoBackendTexture* texture) { setTexture(texture); }
 
         ~LocalRef() {
             // Destroying the texture is the same as setting it to null
             setTexture(nullptr);
         }
 
+        AutoBackendTexture* getTexture() const { return mTexture; }
+
+        DISALLOW_COPY_AND_ASSIGN(LocalRef);
+
+    private:
         // Sets the texture to locally ref-track.
         void setTexture(AutoBackendTexture* texture) {
             if (mTexture != nullptr) {
@@ -59,12 +64,6 @@
                 mTexture->ref();
             }
         }
-
-        AutoBackendTexture* getTexture() const { return mTexture; }
-
-        DISALLOW_COPY_AND_ASSIGN(LocalRef);
-
-    private:
         AutoBackendTexture* mTexture = nullptr;
     };