Merge "Retire glMapBufferRange special path for GLDirectMem"
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.h b/shared/OpenglCodecCommon/GLSharedGroup.h
index 8a35a89..9ef92ea 100755
--- a/shared/OpenglCodecCommon/GLSharedGroup.h
+++ b/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -39,7 +39,6 @@
 #include <utils/threads.h>
 #include "FixedBuffer.h"
 #include "auto_goldfish_dma_context.h"
-#include "goldfish_address_space.h"
 #include "IndexRangeCache.h"
 #include "SmartPtr.h"
 
@@ -64,8 +63,6 @@
 
     // DMA support
     AutoGoldfishDmaContext dma_buffer;
-    // Direct memory access support
-    GoldfishAddressSpaceBlock shared_block;
 };
 
 class ProgramData {
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index d8ea74e..44264d9 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -3041,42 +3041,6 @@
                 buf->m_guest_paddr);
 
         return reinterpret_cast<void*>(buf->dma_buffer.get().mapped_addr);
-    } else if (ctx->hasExtension("ANDROID_EMU_direct_mem_v2")) {
-        GoldfishAddressSpaceBlock new_shared_block;
-
-        if (new_shared_block.allocate(&ctx->m_goldfish_address_block_provider, length)) {
-            uint64_t gpu_addr =
-                ctx->glMapBufferRangeDirect(ctx,
-                                            target,
-                                            offset,
-                                            length,
-                                            access,
-                                            new_shared_block.physAddr());
-            if (gpu_addr) {
-                void *user_ptr = new_shared_block.mmap(gpu_addr);
-                if (user_ptr) {
-                    buf->shared_block.replace(&new_shared_block);
-                    return user_ptr;
-                } else {
-                    GLboolean host_res = GL_TRUE;
-
-                    ctx->glUnmapBufferDirect(
-                        ctx, target,
-                        offset,
-                        length,
-                        access,
-                        new_shared_block.physAddr(),
-                        gpu_addr,
-                        &host_res);
-
-                    return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf);
-                }
-            } else {
-                return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf);
-            }
-        } else {
-            return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf);
-        }
     } else {
         return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf);
     }
@@ -3119,23 +3083,6 @@
             buf->m_mappedAccess,
             goldfish_dma_guest_paddr(&buf->dma_buffer.get()),
             &host_res);
-    } else if (buf->shared_block.guestPtr()) {
-        GoldfishAddressSpaceBlock *shared_block = &buf->shared_block;
-
-        memcpy(static_cast<char*>(buf->m_fixedBuffer.ptr()) + buf->m_mappedOffset,
-               shared_block->guestPtr(),
-               buf->m_mappedLength);
-
-        ctx->glUnmapBufferDirect(
-                ctx, target,
-                buf->m_mappedOffset,
-                buf->m_mappedLength,
-                buf->m_mappedAccess,
-                shared_block->physAddr(),
-                shared_block->hostAddr(),
-                &host_res);
-
-        shared_block->replace(NULL);
     } else {
         ctx->glUnmapBufferAEMU(
                 ctx, target,
@@ -3176,20 +3123,12 @@
 
     buf->m_indexRangeCache.invalidateRange(totalOffset, length);
 
-    if (buf->shared_block.guestPtr()) {
-        ctx->glFlushMappedBufferRangeDirect(
-                ctx, target,
-                offset,
-                length,
-                buf->m_mappedAccess);
-    } else {
-        ctx->glFlushMappedBufferRangeAEMU(
-                ctx, target,
-                totalOffset,
-                length,
-                buf->m_mappedAccess,
-                (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
-    }
+    ctx->glFlushMappedBufferRangeAEMU(
+            ctx, target,
+            totalOffset,
+            length,
+            buf->m_mappedAccess,
+            (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
 }
 
 void GL2Encoder::s_glCompressedTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) {
diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h
index fc444c5..c617a36 100644
--- a/system/GLESv2_enc/GL2Encoder.h
+++ b/system/GLESv2_enc/GL2Encoder.h
@@ -104,8 +104,6 @@
     GLSharedGroupPtr m_shared;
     GLenum  m_error;
 
-    GoldfishAddressSpaceBlockProvider m_goldfish_address_block_provider;
-
     GLint *m_compressedTextureFormats;
     GLint m_num_compressedTextureFormats;
     GLint *getCompressedTextureFormats();