From 710bc535f45570428f0c7b36bb4f20744247cb38 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 24 Oct 2018 07:59:49 -0700 Subject: minui: Remove the default and copy ctors for GRSurface. As well as all the derived classes. Instances must be created with Create(). A default copy ctor would mess up the ownership of the mapped or allocated buffer in these classes, so that has been explicitly removed. Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Test: `Run graphics test` on blueline. Change-Id: I69ce001a9ec9e3ac851edb6ec4d3fa11f4aaea08 --- minui/graphics_drm.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'minui/graphics_drm.cpp') diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp index f81fd9d5c..765e2625a 100644 --- a/minui/graphics_drm.cpp +++ b/minui/graphics_drm.cpp @@ -102,15 +102,15 @@ std::unique_ptr GRSurfaceDrm::Create(int drm_fd, int width, int he return nullptr; } - std::unique_ptr surface = std::make_unique(drm_fd); - surface->handle = create_dumb.handle; + // Cannot use std::make_unique to access non-public ctor. + auto surface = std::unique_ptr(new GRSurfaceDrm( + width, height, create_dumb.pitch, create_dumb.bpp / 8, drm_fd, create_dumb.handle)); uint32_t handles[4], pitches[4], offsets[4]; handles[0] = surface->handle; pitches[0] = create_dumb.pitch; offsets[0] = 0; - if (drmModeAddFB2(drm_fd, width, height, format, handles, pitches, offsets, &surface->fb_id, 0) != 0) { perror("Failed to drmModeAddFB2"); @@ -124,10 +124,6 @@ std::unique_ptr GRSurfaceDrm::Create(int drm_fd, int width, int he return nullptr; } - surface->height = height; - surface->width = width; - surface->row_bytes = create_dumb.pitch; - surface->pixel_bytes = create_dumb.bpp / 8; auto mmapped = mmap(nullptr, surface->height * surface->row_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, drm_fd, map_dumb.offset); if (mmapped == MAP_FAILED) { -- cgit v1.2.3