Page MenuHome

GHOST: Add GHOST_Bitmap
Needs RevisionPublic

Authored by Jeroen Bakker (jbakker) on Apr 3 2020, 10:30 AM.

Details

Summary

This task is part of a code cleanup. The goal of the clean-up was to
remove any references from ghost to blender by introducing a
GHOST_Bitmap.

This GHOST_Bitmap is used during dragndrop and replaces the usage of
ImBuf in GHOST. The bitmap has been implemented with only the needed
features that were used in that specific situation what means that only
32 bit integer based pixels are supported with a fixed colorspace
(sRGB). This could be modernized, however...

Blender does not do anything with the GHOST_kDragnDropTypeBitmap so
basically this needs a broader discussion on how to proceed:

  1. Remove support for GHOST_kDragnDropTypeBitmap and perhaps GHOST_kDragnDropTypeString
  2. Add support for GHOST_kDragnDropTypeBitmap to blender

Note This patch hasn't been tested on the Mac platform so part of the
review would be if it still compiles.

Diff Detail

Repository
rB Blender
Branch
ghost-bitmap (branched from master)
Build Status
Buildable 7428
Build 7428: arc lint + arc unit

Event Timeline

As explained in D7046#169931, I think GHOST should be able to reuse code from other places in Blender. But if this helps move things forward in the short term then fine.

/Users/brecht/dev/worktree/intern/ghost/intern/GHOST_SystemCocoa.mm:1223:24: error: unknown type name 'GHOST_bitmap'; did you mean 'GHOST_Bitmap'?
          bitmap = new GHOST_bitmap(imgSize.width, imgSize.height);
                       ^~~~~~~~~~~~
                       GHOST_Bitmap
/Users/brecht/dev/worktree/intern/ghost/intern/GHOST_Bitmap.h:31:8: note: 'GHOST_Bitmap' declared here
struct GHOST_Bitmap {
       ^
/Users/brecht/dev/worktree/intern/ghost/intern/GHOST_SystemCocoa.mm:1224:16: error: use of undeclared identifier 'ibuf'
          if (!ibuf.isAllocated()) {
               ^
/Users/brecht/dev/worktree/intern/ghost/intern/GHOST_SystemCocoa.mm:1244:36: error: use of undeclared identifier 'image'
            toBuf = (GHOST_TUns8 *)image->getBuffer();
                                   ^
/Users/brecht/dev/worktree/intern/ghost/intern/GHOST_SystemCocoa.mm:1339:44: error: use of undeclared identifier 'ibuf'
          eventData = (GHOST_TEventDataPtr)ibuf;
                                           ^

Supporting drag & drop of bitmaps from other applications I would consider very low priority, I can't think of important use cases. This of thing likely wouldn't always transfer an image with proper bit depth and color space. So I'm fine with just removing this code too.

Brecht Van Lommel (brecht) requested changes to this revision.Apr 6 2020, 5:13 PM

To be more explicit, my advice is to remove GHOST_kDragnDropTypeBitmap entirely.

This revision now requires changes to proceed.Apr 6 2020, 5:13 PM