复用 LUT 浏览器位图并消除点击闪黑
这个提交包含在:
1 父节点
a0225404a2
当前提交
e0bd8342c0
9 个文件已更改
+150
-83
没有与搜索条件相匹配的文件
@@ -7,6 +7,7 @@
|
||||
- (void)rebuildGrid;
|
||||
- (void)folderClicked:(NSButton *)button;
|
||||
- (void)thumbnailClicked:(id)tile;
|
||||
- (void)qualityChanged:(id)sender;
|
||||
@end
|
||||
static NSMutableArray *checks;
|
||||
static void require(BOOL pass,NSString *name){[checks addObject:@{@"name":name,@"pass":@(pass)}];if(!pass){fprintf(stderr,"FAIL %s\n",name.UTF8String);exit(1);}}
|
||||
@@ -38,12 +39,39 @@ int main(int argc,const char **argv){@autoreleasepool{
|
||||
require([[[browser valueForKey:@"visibleEntries"]valueForKey:@"path"]isEqual:@[middle,alpha,zulu]],@"reopening places the successful selection first");
|
||||
NSPanel *host=[[[NSPanel alloc]initWithContentRect:NSMakeRect(120,160,900,620) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];__block int closes=0;[browser showInRemoteParent:host.contentView close:^{closes++;}];pump(^{return [browser valueForKey:@"presentationWindow"]==host;});require(!host.visible&&browser.visible,@"remote-parent checks never display a test window");
|
||||
NSData *portrait=[NSMutableData dataWithLength:18*32*16];
|
||||
[browser updatePreview:@{@"standard":portrait,@"standardSize":[NSValue valueWithSize:NSMakeSize(18,32)]}];
|
||||
pump(^{return [[[browser valueForKey:@"tiles"]objectForKey:middle]valueForKey:@"thumbnail"]!=nil;});
|
||||
NSDictionary *portraitFrame=@{@"standard":portrait,@"standardSize":[NSValue valueWithSize:NSMakeSize(18,32)],@"time":@2};
|
||||
[browser updatePreview:portraitFrame];
|
||||
pump(^{NSImage *image=[[[browser valueForKey:@"tiles"]objectForKey:middle]valueForKey:@"thumbnail"];return NSEqualSizes(image.size,NSMakeSize(18,32));});
|
||||
NSImage *thumb=[[[browser valueForKey:@"tiles"]objectForKey:middle]valueForKey:@"thumbnail"];
|
||||
require(thumb.size.height>thumb.size.width&&fabs(thumb.size.width/thumb.size.height-18./32)<.015,@"list thumbnail keeps portrait aspect");
|
||||
[((NSPopUpButton *)[browser valueForKey:@"layoutMenu"]) selectItemAtIndex:0];[browser layoutChanged:nil];
|
||||
require([[browser valueForKey:@"tileHeight"]doubleValue]>[[browser valueForKey:@"tileWidth"]doubleValue],@"portrait grid cards follow frame geometry");
|
||||
|
||||
NSView *comparison=[browser valueForKey:@"compareView"];
|
||||
id (^visibleTile)(void)=^id{return [[browser valueForKey:@"tiles"]objectForKey:middle];};
|
||||
pump(^{return [comparison valueForKey:@"original"]!=nil&&[visibleTile() valueForKey:@"thumbnail"]!=nil;});
|
||||
NSImage *original=[comparison valueForKey:@"original"],*shown=[visibleTile() valueForKey:@"thumbnail"];
|
||||
id work=[browser valueForKey:@"work"];
|
||||
[browser thumbnailClicked:visibleTile()];
|
||||
pump(^{return [comparison valueForKey:@"styled"]!=nil&&[browser valueForKey:@"selectionTask"]==nil;});
|
||||
require([comparison valueForKey:@"original"]==original&&[comparison valueForKey:@"styled"]==shown&&[browser valueForKey:@"work"]==work,@"click reuses the original and selected tile bitmaps without replacing preview work");
|
||||
[browser updatePreview:nil];
|
||||
[browser updatePreview:@{}];
|
||||
require([comparison valueForKey:@"styled"]==shown&&[visibleTile() valueForKey:@"thumbnail"]==shown&&[browser valueForKey:@"work"]==work,@"empty snapshots keep both previews and pending work");
|
||||
NSMutableData *newPixels=[portrait mutableCopy];
|
||||
((float *)newPixels.mutableBytes)[0]=.8f;((float *)newPixels.mutableBytes)[3]=1;
|
||||
NSMutableDictionary *newFrame=[[portraitFrame mutableCopy]autorelease];newFrame[@"standard"]=newPixels;[newPixels release];
|
||||
[browser updatePreview:newFrame];
|
||||
require([comparison valueForKey:@"styled"]==shown&&[visibleTile() valueForKey:@"thumbnail"]==shown&&[browser valueForKey:@"work"]==work,@"same-time host render after selection cannot replace the comparison reference");
|
||||
newFrame[@"time"]=@3;
|
||||
newFrame[@"high"]=[NSMutableData dataWithLength:36*64*16];newFrame[@"highSize"]=[NSValue valueWithSize:NSMakeSize(36,64)];
|
||||
[browser updatePreview:newFrame];
|
||||
require([comparison valueForKey:@"styled"]==shown&&[visibleTile() valueForKey:@"thumbnail"]==shown,@"previous previews stay visible while the next frame renders");
|
||||
pump(^{id fresh=[visibleTile() valueForKey:@"thumbnail"];return fresh&&fresh!=shown&&[comparison valueForKey:@"styled"]==fresh;});
|
||||
require([comparison valueForKey:@"original"]!=original,@"moving the playhead replaces the original and both uses of the LUT bitmap");
|
||||
NSButton *hd=[browser valueForKey:@"hd"];hd.state=NSControlStateValueOn;[browser qualityChanged:hd];
|
||||
pump(^{NSImage *image=[visibleTile() valueForKey:@"thumbnail"];return image.size.width==36&&[comparison valueForKey:@"styled"]==image;});
|
||||
require([(NSImage *)[comparison valueForKey:@"original"] size].height==64,@"the comparison and grid use the same high resolution frame");
|
||||
NSRect desired=NSMakeRect(190,210,1000,680);[host setFrame:desired display:NO];NSString *frameKey=[@"com.dayu.color.lookLUTPreview.windowFrame|" stringByAppendingString:library.rootURL.path];require([NSUserDefaults.standardUserDefaults stringForKey:frameKey]==nil,@"remote window geometry is owned and remembered by the host");[browser close];[browser close];require(closes==1,@"remote close callback runs once");[browser release];[ack release];ack=nil;
|
||||
for(int i=0;i<50;i++)[library recordUsedPath:[root.path stringByAppendingPathComponent:[NSString stringWithFormat:@"History-%d.cube",i]]];require(library.recentPaths.count==40&&[library.recentPaths[0]hasSuffix:@"History-49.cube"],@"recent history stays bounded at 40 newest paths");
|
||||
NSArray *keys=NSUserDefaults.standardUserDefaults.dictionaryRepresentation.allKeys;for(NSString *key in keys)if([key containsString:library.rootURL.path])[NSUserDefaults.standardUserDefaults removeObjectForKey:key];require([fm removeItemAtURL:root error:nil],@"isolated fixtures and preferences cleaned");
|
||||
|
||||
@@ -28,6 +28,6 @@ typedef NSProgress * (^DYLUTSelectionHandler)(NSString *path,void (^completion)(
|
||||
- (void)refreshRecentSelection:(NSString *)path;
|
||||
- (void)updatePalette:(NSDictionary *)palette;
|
||||
/// Replace the source frame after the renderer captures a new playhead image.
|
||||
/// Passing identical bytes keeps the current thumbnail jobs and cache intact.
|
||||
/// Empty snapshots and identical images keep the current browser bitmaps.
|
||||
- (void)updatePreview:(NSDictionary *)frames;
|
||||
@end
|
||||
+99
-74
@@ -88,6 +88,7 @@ static NSRect DYBrowserTileImageRect(NSRect bounds,BOOL list) {
|
||||
|
||||
@interface DYBrowserTile : NSButton
|
||||
@property(retain) NSImage *thumbnail;
|
||||
@property NSUInteger previewGeneration;
|
||||
@property(copy) NSString *displayName;
|
||||
@property(copy) NSString *failure;
|
||||
@property(copy) NSDictionary *palette;
|
||||
@@ -158,6 +159,7 @@ static NSRect DYBrowserTileImageRect(NSRect bounds,BOOL list) {
|
||||
- (BOOL)isFlipped{return YES;}
|
||||
- (void)dealloc{[_original release];[_styled release];[super dealloc];}
|
||||
- (void)setOriginal:(NSImage *)original styled:(NSImage *)styled{
|
||||
if(_original==original&&_styled==styled)return;
|
||||
if(_original!=original){[_original release];_original=[original retain];}
|
||||
if(_styled!=styled){[_styled release];_styled=[styled retain];}
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -210,7 +212,8 @@ static NSRect DYBrowserTileImageRect(NSRect bounds,BOOL list) {
|
||||
|
||||
@interface DYLUTBrowser () <NSWindowDelegate,NSPopoverDelegate,NSSearchFieldDelegate,NSSplitViewDelegate> {
|
||||
DYLUTLibrary *_library;
|
||||
NSDictionary *_previewFrames;
|
||||
NSDictionary *_previewFrames,*_comparisonOriginal;
|
||||
NSNumber *_selectionFrameTime;
|
||||
NSString *_selectedPath,*_folder;
|
||||
NSDictionary *_palette;
|
||||
DYLUTSelectionHandler _selection;
|
||||
@@ -232,12 +235,12 @@ static NSRect DYBrowserTileImageRect(NSRect bounds,BOOL list) {
|
||||
NSMutableSet *_queuedPaths;
|
||||
NSCache *_thumbnailCache;
|
||||
dispatch_queue_t _previewQueue,_compareQueue;
|
||||
DYBrowserWork *_work,*_compareWork;
|
||||
BOOL _closed,_sizing,_visible,_remoteMode,_importing,_layingOut,_detached,_embedded,_compactRecent;
|
||||
DYBrowserWork *_work;
|
||||
BOOL _closed,_visible,_remoteMode,_importing,_layingOut,_detached,_embedded,_compactRecent;
|
||||
NSArray *_recentSnapshot;
|
||||
NSProgress *_libraryTask,*_selectionTask;
|
||||
NSTimer *_progressTimer;
|
||||
NSUInteger _libraryGeneration,_selectionGeneration;
|
||||
NSUInteger _libraryGeneration,_selectionGeneration,_previewGeneration;
|
||||
NSInteger _columns;
|
||||
CGFloat _tileWidth,_tileHeight,_sidebarWidth;
|
||||
}
|
||||
@@ -261,7 +264,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
NSString *savedFolder=[[NSUserDefaults standardUserDefaults]stringForKey:DYBrowserPreference(DYBrowserFolderPreference,library)]?:[[NSUserDefaults standardUserDefaults]stringForKey:DYBrowserFolderPreference];
|
||||
if(!library.recentPaths.count&&path.length)[library recordUsedPath:path];
|
||||
if(!savedFolder)savedFolder=library.recentPaths.count?DYBrowserRecentFolder:@"*";
|
||||
_library=[library retain];_previewFrames=[frames copy];_recentSnapshot=[library.recentPaths copy];_selectedPath=[path copy];_folder=[(savedFolder?:@"*") copy];_selection=[selection copy];
|
||||
_library=[library retain];_previewFrames=[frames copy];_previewGeneration=1;_recentSnapshot=[library.recentPaths copy];_selectedPath=[path copy];_folder=[(savedFolder?:@"*") copy];_selection=[selection copy];
|
||||
_folderButtons=[NSMutableArray new];_tiles=[NSMutableDictionary new];_queuedPaths=[NSMutableSet new];_thumbnailCache=[NSCache new];_thumbnailCache.countLimit=600;_thumbnailCache.totalCostLimit=64*1024*1024;_previewQueue=dispatch_queue_create("com.dayu.color.lut-thumbnails",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_previewQueue,dispatch_get_global_queue(QOS_CLASS_UTILITY,0));
|
||||
panel.title=@"风格 LUT";panel.contentMinSize=self.class.minimumContentSize;panel.contentMaxSize=self.class.maximumContentSize;panel.releasedWhenClosed=NO;panel.hidesOnDeactivate=NO;panel.delegate=self;
|
||||
_root=[[DYBrowserCanvas alloc]initWithFrame:NSMakeRect(0,0,760,560)];_root.accessibilityLabel=@"LUT 缩略图浏览库";panel.contentView=_root;
|
||||
@@ -280,7 +283,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
NSUserDefaults *preferences=NSUserDefaults.standardUserDefaults;
|
||||
_hd=[[NSButton checkboxWithTitle:@"高清预览" target:self action:@selector(qualityChanged:)]retain];
|
||||
_hd.font=[NSFont systemFontOfSize:11];_hd.state=[preferences boolForKey:DYBrowserPreference(DYBrowserHDPreference,library)]?NSControlStateValueOn:NSControlStateValueOff;
|
||||
_hd.toolTip=@"从源帧取样并以双倍像素生成缩略图";
|
||||
_hd.toolTip=@"缩略图与划像共用高清帧预览";
|
||||
_comparePanel=[[DYBrowserCanvas alloc]initWithFrame:NSZeroRect];_comparePanel.fillKey=@"card";
|
||||
_compareTitle=[BrowserLabel(@"原图与 LUT 对比",13)retain];_compareTitle.font=[NSFont systemFontOfSize:13 weight:NSFontWeightSemibold];
|
||||
_compareStatus=[BrowserLabel(@"等待播放头画面",11)retain];
|
||||
@@ -324,8 +327,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
[_libraryTask cancel];[_libraryTask release];[_selectionTask cancel];[_selectionTask release];[_progressTimer invalidate];[_progressTimer release];
|
||||
_work.cancelled=YES;_work.owner=nil;[_work release];self.window.delegate=nil;
|
||||
_popover.delegate=nil;[_popover close];[_popover release];[_root removeFromSuperview];
|
||||
_compareWork.cancelled=YES;_compareWork.owner=nil;[_compareWork release];
|
||||
[_library release];[_previewFrames release];[_selectedPath release];[_folder release];[_palette release];[_selection release];[_closeAction release];
|
||||
[_library release];[_previewFrames release];[_comparisonOriginal release];[_selectionFrameTime release];[_selectedPath release];[_folder release];[_palette release];[_selection release];[_closeAction release];
|
||||
[_root release];[_folderDocument release];[_gridDocument release];[_folderScroll release];[_gridScroll release];
|
||||
[_titleLabel release];[_countLabel release];[_statusLabel release];[_sizeLabel release];[_emptyLabel release];[_search release];
|
||||
[_importFiles release];[_importFolder release];[_reveal release];[_refresh release];[_none release];[_done release];[_sizeSlider release];[_layoutMenu release];_splitView.delegate=nil;[_splitView release];[_presentationWindow release];
|
||||
@@ -453,7 +455,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
// The API owner's completion may release this controller synchronously.
|
||||
[self retain];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
||||
_closed=YES;_visible=NO;_work.cancelled=YES;_work.owner=nil;_compareWork.cancelled=YES;_compareWork.owner=nil;[_libraryTask cancel];[_selectionTask cancel];[_progressTimer invalidate];[_progressTimer release];_progressTimer=nil;
|
||||
_closed=YES;_visible=NO;_work.cancelled=YES;_work.owner=nil;[_libraryTask cancel];[_selectionTask cancel];[_progressTimer invalidate];[_progressTimer release];_progressTimer=nil;
|
||||
_popover.delegate=nil;if(_popover.shown)[_popover close];
|
||||
if(_remoteMode&&_root.superview)for(NSNotificationName name in @[NSViewFrameDidChangeNotification,NSViewBoundsDidChangeNotification])[[NSNotificationCenter defaultCenter]removeObserver:self name:name object:_root.superview];
|
||||
[_root removeFromSuperview];[_queuedPaths removeAllObjects];[_thumbnailCache removeAllObjects];
|
||||
@@ -546,7 +548,8 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
}
|
||||
for(NSString *path in _tiles.allKeys)if(![wanted containsObject:path]){[_tiles[path]removeFromSuperview];[_tiles removeObjectForKey:path];changed=YES;}
|
||||
if(changed||!_work)[self resetThumbnailWork];
|
||||
if(!_sizing)[self generateVisibleThumbnails];
|
||||
[self refreshComparison];
|
||||
[self generateVisibleThumbnails];
|
||||
}
|
||||
|
||||
- (void)updatePalette:(NSDictionary *)palette{
|
||||
@@ -564,47 +567,97 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
for(DYBrowserTile *tile in _tiles.allValues){tile.palette=_palette;[tile setNeedsDisplay:YES];}
|
||||
[_root setNeedsDisplay:YES];[_folderDocument setNeedsDisplay:YES];[_gridDocument setNeedsDisplay:YES];
|
||||
}
|
||||
- (NSString *)previewQualityForFrames:(NSDictionary *)frames {
|
||||
BOOL high=!_compactRecent&&_hd.state==NSControlStateValueOn;
|
||||
return frames[@"high"]&&(high||!frames[@"standard"])?@"high":@"standard";
|
||||
}
|
||||
- (NSSize)previewSize {
|
||||
NSValue *size=_previewFrames[@"standardSize"]?:_previewFrames[@"highSize"];
|
||||
NSString *quality=[self previewQualityForFrames:_previewFrames];
|
||||
NSValue *size=_previewFrames[[quality stringByAppendingString:@"Size"]];
|
||||
return size?size.sizeValue:NSMakeSize(320,180);
|
||||
}
|
||||
- (void)updatePreview:(NSDictionary *)frames{
|
||||
if(_closed||_previewFrames==frames||[_previewFrames isEqual:frames])return;
|
||||
[_previewFrames release];_previewFrames=[frames copy];
|
||||
- (void)invalidatePreviewImages {
|
||||
++_previewGeneration;
|
||||
[_thumbnailCache removeAllObjects];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(refreshThumbnailSize) object:nil];
|
||||
[self refreshThumbnailSize];
|
||||
[self refreshComparison];
|
||||
[_comparisonOriginal release];_comparisonOriginal=nil;
|
||||
[self resetThumbnailWork];
|
||||
}
|
||||
- (void)updatePreview:(NSDictionary *)frames{
|
||||
if(_closed||_previewFrames==frames||(!frames[@"standard"]&&!frames[@"high"]))return;
|
||||
NSString *currentQuality=[self previewQualityForFrames:_previewFrames],*nextQuality=[self previewQualityForFrames:frames];
|
||||
NSValue *currentSize=_previewFrames[[currentQuality stringByAppendingString:@"Size"]];
|
||||
NSValue *nextSize=frames[[nextQuality stringByAppendingString:@"Size"]];
|
||||
BOOL sameSize=[currentSize isEqual:nextSize];
|
||||
// A host render after our LUT write can already contain that LUT. Keep
|
||||
// the browser's pre-click reference until the playhead moves.
|
||||
if(sameSize&&[_selectionFrameTime isEqual:frames[@"time"]])return;
|
||||
[_selectionFrameTime release];_selectionFrameTime=nil;
|
||||
NSData *current=_previewFrames[currentQuality],*next=frames[nextQuality];
|
||||
BOOL unchanged=sameSize&&[current isEqualToData:next];
|
||||
NSDictionary *snapshot=[frames copy];
|
||||
[_previewFrames release];_previewFrames=snapshot;
|
||||
if(unchanged)return;
|
||||
[self invalidatePreviewImages];
|
||||
[self layoutBrowser];
|
||||
}
|
||||
- (void)qualityChanged:(id)sender{
|
||||
[NSUserDefaults.standardUserDefaults setBool:_hd.state==NSControlStateValueOn forKey:DYBrowserPreference(DYBrowserHDPreference,_library)];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(refreshThumbnailSize) object:nil];
|
||||
[self refreshThumbnailSize];
|
||||
[self invalidatePreviewImages];
|
||||
[self layoutBrowser];
|
||||
}
|
||||
- (void)comparePositionChanged:(id)sender{_compareView.position=_compareSlider.doubleValue;}
|
||||
- (void)refreshComparison{
|
||||
if(_closed||_compactRecent||!self.visible)return;
|
||||
_compareWork.cancelled=YES;_compareWork.owner=nil;[_compareWork release];_compareWork=nil;
|
||||
NSData *frame=_previewFrames[@"high"]?:_previewFrames[@"standard"];
|
||||
if(!frame){[_compareView setOriginal:nil styled:nil];_compareSlider.enabled=NO;_compareStatus.stringValue=@"等待播放头画面";return;}
|
||||
NSSize size=[(_previewFrames[@"highSize"]?:_previewFrames[@"standardSize"]) sizeValue];
|
||||
NSString *path=_selectedPath;
|
||||
NSString *name=path.lastPathComponent.stringByDeletingPathExtension;
|
||||
_compareWork=[DYBrowserWork new];_compareWork.owner=self;DYBrowserWork *work=_compareWork;
|
||||
dispatch_async(_compareQueue,^{@autoreleasepool{
|
||||
- (NSDictionary *)previewResultForPath:(NSString *)path{
|
||||
DYBrowserTile *tile=_tiles[path];
|
||||
if(tile.previewGeneration==_previewGeneration){
|
||||
if(tile.thumbnail)return @{@"image":tile.thumbnail};
|
||||
if(tile.failure.length)return @{@"error":tile.failure};
|
||||
}
|
||||
return [_thumbnailCache objectForKey:path];
|
||||
}
|
||||
- (void)displayPreviewResult:(NSDictionary *)result inTile:(DYBrowserTile *)tile{
|
||||
tile.previewGeneration=_previewGeneration;
|
||||
tile.thumbnail=result[@"image"];tile.failure=result[@"error"];
|
||||
tile.enabled=tile.thumbnail!=nil;
|
||||
tile.toolTip=tile.failure?:tile.identifier;
|
||||
[tile setNeedsDisplay:YES];
|
||||
}
|
||||
- (void)requestPreviewForPath:(NSString *)path comparison:(BOOL)comparison{
|
||||
if(!_work||[_queuedPaths containsObject:path])return;
|
||||
[_queuedPaths addObject:path];
|
||||
NSData *frame=_previewFrames[[self previewQualityForFrames:_previewFrames]];
|
||||
NSSize size=[self previewSize];
|
||||
DYBrowserWork *work=_work;
|
||||
dispatch_async(comparison?_compareQueue:_previewQueue,^{@autoreleasepool{
|
||||
if(work.cancelled)return;
|
||||
NSImage *original=DYLUTThumbnail(nil,frame,size.width,size.height,size,nil);
|
||||
if(work.cancelled)return;
|
||||
NSImage *styled=path.length?DYLUTThumbnail(path,frame,size.width,size.height,size,nil):nil;
|
||||
NSError *error=nil;
|
||||
NSImage *image=DYLUTThumbnail(path,frame,size.width,size.height,size,&error);
|
||||
NSDictionary *result=image?@{@"image":image}:@{@"error":error.localizedDescription?:@"无法预览此 LUT"};
|
||||
dispatch_async(dispatch_get_main_queue(),^{
|
||||
DYLUTBrowser *owner=work.owner;if(work.cancelled||!owner)return;
|
||||
owner->_compareSlider.enabled=styled!=nil&&original!=nil;
|
||||
[owner->_compareView setOriginal:original styled:styled];
|
||||
owner->_compareStatus.stringValue=path.length?(styled?name:@"无法预览当前 LUT"):@"选择一个 LUT 查看对比";
|
||||
owner->_compareStatus.toolTip=owner->_compareStatus.stringValue;
|
||||
[owner->_queuedPaths removeObject:path];
|
||||
if(path.length){
|
||||
[owner->_thumbnailCache setObject:result forKey:path cost:image?(NSUInteger)(size.width*size.height)*4:128];
|
||||
DYBrowserTile *tile=owner->_tiles[path];
|
||||
if(tile)[owner displayPreviewResult:result inTile:tile];
|
||||
}else owner->_comparisonOriginal=[result retain];
|
||||
if(!path.length||[path isEqualToString:owner->_selectedPath])[owner refreshComparison];
|
||||
});
|
||||
}});
|
||||
}
|
||||
- (void)refreshComparison{
|
||||
if(_closed||_compactRecent||!self.visible||!_previewFrames.count)return;
|
||||
NSString *path=_selectedPath;
|
||||
NSDictionary *original=_comparisonOriginal,*styled=path.length?[self previewResultForPath:path]:nil;
|
||||
if(!original)[self requestPreviewForPath:@"" comparison:YES];
|
||||
if(path.length&&!styled)[self requestPreviewForPath:path comparison:YES];
|
||||
if(!original||(path.length&&!styled))return;
|
||||
|
||||
NSImage *source=original[@"image"],*look=styled[@"image"];
|
||||
_compareSlider.enabled=source!=nil&&look!=nil;
|
||||
[_compareView setOriginal:source styled:look];
|
||||
_compareStatus.stringValue=path.length?(look?path.lastPathComponent.stringByDeletingPathExtension:@"无法预览当前 LUT"):@"选择一个 LUT 查看对比";
|
||||
_compareStatus.toolTip=_compareStatus.stringValue;
|
||||
}
|
||||
- (void)setStatus:(NSString *)status{_statusLabel.stringValue=status?:@"";_statusLabel.toolTip=status;}
|
||||
- (void)rebuildFolders{
|
||||
NSMutableArray *paths=[NSMutableArray arrayWithObjects:DYBrowserRecentFolder,@"*",nil];NSMutableSet *seen=[NSMutableSet setWithArray:paths];
|
||||
@@ -641,7 +694,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
}
|
||||
- (void)reloadLibrary:(id)sender{
|
||||
if(_libraryTask){[_libraryTask cancel];[self setStatus:@"正在取消…"];return;}
|
||||
[_thumbnailCache removeAllObjects];NSUInteger generation=++_libraryGeneration;
|
||||
[self invalidatePreviewImages];NSUInteger generation=++_libraryGeneration;
|
||||
NSProgress *task=[_library reloadAsync:^(NSError *error){
|
||||
if(_closed||generation!=_libraryGeneration)return;[self endLibraryTask];
|
||||
[self rebuildFolders];[self rebuildGrid];[self refreshComparison];[self setStatus:error?error.localizedDescription:@"单击缩略图应用 LUT"];
|
||||
@@ -657,48 +710,18 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (void)controlTextDidChange:(NSNotification *)notification{if(notification.object==_search)[self rebuildGrid];}
|
||||
- (void)sizeChanged:(id)sender{
|
||||
[[NSUserDefaults standardUserDefaults]setDouble:_sizeSlider.doubleValue forKey:DYBrowserPreference(DYBrowserSizePreference,_library)];
|
||||
_sizing=YES;[self layoutBrowser];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(refreshThumbnailSize) object:nil];
|
||||
[self performSelector:@selector(refreshThumbnailSize) withObject:nil afterDelay:.22];
|
||||
}
|
||||
- (void)refreshThumbnailSize{
|
||||
if(_closed)return;_sizing=NO;
|
||||
_work.cancelled=YES;_work.owner=nil;[_work release];_work=[DYBrowserWork new];_work.owner=self;[_queuedPaths removeAllObjects];
|
||||
for(DYBrowserTile *tile in _tiles.allValues){tile.thumbnail=nil;tile.failure=nil;tile.enabled=YES;[tile setNeedsDisplay:YES];}
|
||||
[self layoutBrowser];
|
||||
}
|
||||
- (void)gridScrolled:(NSNotification *)notification{[self updateVisibleTiles];}
|
||||
- (void)generateVisibleThumbnails{
|
||||
if(_closed||!_work)return;
|
||||
NSRect visible=NSInsetRect(_gridScroll.contentView.bounds,-30,-180);
|
||||
BOOL hd=!_compactRecent&&_hd.state==NSControlStateValueOn;
|
||||
BOOL useHigh=_previewFrames[@"high"]&&(hd||!_previewFrames[@"standard"]);
|
||||
NSData *frame=_previewFrames[useHigh?@"high":@"standard"];
|
||||
NSSize source=useHigh?[_previewFrames[@"highSize"] sizeValue]:[self previewSize];
|
||||
NSSize box=DYBrowserTileImageRect(NSMakeRect(0,0,_tileWidth,_tileHeight),_layoutMenu.indexOfSelectedItem==1).size;
|
||||
NSSize target=DYBrowserFitSize([self previewSize],box);
|
||||
NSUInteger width=MAX(1,llround(target.width*(hd?2:1))),height=MAX(1,llround(target.height*(hd?2:1)));
|
||||
for(NSString *path in _tiles.allKeys){
|
||||
DYBrowserTile *tile=_tiles[path];
|
||||
if(!NSIntersectsRect(tile.frame,visible)){if(tile.thumbnail){tile.thumbnail=nil;tile.enabled=NO;}continue;}
|
||||
if(tile.thumbnail||tile.failure.length)continue;
|
||||
NSString *cacheKey=[NSString stringWithFormat:@"%d|%lux%lu|%@",hd,(unsigned long)width,(unsigned long)height,path];
|
||||
NSDictionary *cached=[_thumbnailCache objectForKey:cacheKey];
|
||||
if(cached){tile.thumbnail=cached[@"image"];tile.failure=cached[@"error"];tile.enabled=tile.thumbnail!=nil;if(tile.failure.length)tile.toolTip=tile.failure;[tile setNeedsDisplay:YES];continue;}
|
||||
if([_queuedPaths containsObject:cacheKey])continue;[_queuedPaths addObject:cacheKey];
|
||||
DYBrowserWork *work=_work;
|
||||
dispatch_async(_previewQueue,^{@autoreleasepool{
|
||||
if(work.cancelled)return;
|
||||
NSError *error=nil;NSImage *image=DYLUTThumbnail(path,frame,source.width,source.height,NSMakeSize(width,height),&error);NSString *failure=error.localizedDescription;
|
||||
dispatch_async(dispatch_get_main_queue(),^{
|
||||
DYLUTBrowser *owner=work.owner;if(work.cancelled||!owner)return;
|
||||
[owner->_queuedPaths removeObject:cacheKey];
|
||||
NSDictionary *result=image?@{@"image":image}:@{@"error":failure?:@"无法预览此 LUT"};
|
||||
[owner->_thumbnailCache setObject:result forKey:cacheKey cost:image?width*height*4:128];
|
||||
DYBrowserTile *current=owner->_tiles[path];if(!current||!NSIntersectsRect(current.frame,NSInsetRect(owner->_gridScroll.contentView.bounds,-30,-180)))return;
|
||||
current.thumbnail=image;current.failure=failure;current.enabled=image!=nil;if(failure.length)current.toolTip=failure;[current setNeedsDisplay:YES];
|
||||
});
|
||||
}});
|
||||
if(!NSIntersectsRect(tile.frame,visible)||tile.previewGeneration==_previewGeneration)continue;
|
||||
NSDictionary *cached=[self previewResultForPath:path];
|
||||
if(cached)[self displayPreviewResult:cached inTile:tile];
|
||||
else [self requestPreviewForPath:path comparison:NO];
|
||||
}
|
||||
}
|
||||
- (void)rebuildGrid{
|
||||
@@ -724,7 +747,8 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
void (^applied)(NSError *)=^(NSError *error){
|
||||
if(_closed||generation!=_selectionGeneration)return;[_selectionTask release];_selectionTask=nil;
|
||||
if(error){[self setStatus:error.localizedDescription];return;}
|
||||
[_selectedPath release];_selectedPath=[path copy];[_library recordUsedPath:path];[self refreshComparison];
|
||||
[_selectedPath release];_selectedPath=[path copy];[_library recordUsedPath:path];
|
||||
[_selectionFrameTime release];_selectionFrameTime=[_previewFrames[@"time"] retain];[self refreshComparison];
|
||||
for(DYBrowserTile *tile in _tiles.allValues){tile.chosen=[tile.identifier isEqualToString:path];[tile setNeedsDisplay:YES];}
|
||||
[self setStatus:[@"已选择 " stringByAppendingString:name]];if(closeAfter)[self close];
|
||||
};
|
||||
@@ -736,7 +760,8 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
void (^cleared)(NSError *)=^(NSError *error){
|
||||
if(_closed||generation!=_selectionGeneration)return;[_selectionTask release];_selectionTask=nil;
|
||||
if(error){[self setStatus:error.localizedDescription];return;}
|
||||
[_selectedPath release];_selectedPath=nil;[self refreshComparison];
|
||||
[_selectedPath release];_selectedPath=nil;
|
||||
[_selectionFrameTime release];_selectionFrameTime=[_previewFrames[@"time"] retain];[self refreshComparison];
|
||||
for(DYBrowserTile *tile in _tiles.allValues){tile.chosen=NO;[tile setNeedsDisplay:YES];}
|
||||
[self setStatus:@"已移除 LUT"];
|
||||
};
|
||||
@@ -749,7 +774,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
NSProgress *task=[_library importURLsAsync:urls completion:^(NSArray *imported,NSError *error){
|
||||
if(_closed||generation!=_libraryGeneration)return;[self endLibraryTask];
|
||||
if(!imported){[self showImportError:error];return;}
|
||||
[_thumbnailCache removeAllObjects];[self rebuildFolders];[self rebuildGrid];[self setStatus:[NSString stringWithFormat:@"已导入 %lu 个 LUT",(unsigned long)imported.count]];
|
||||
[self invalidatePreviewImages];[self rebuildFolders];[self rebuildGrid];[self setStatus:[NSString stringWithFormat:@"已导入 %lu 个 LUT",(unsigned long)imported.count]];
|
||||
}];[self beginLibraryTask:task];
|
||||
}
|
||||
- (void)importPanelForFolders:(BOOL)folders{
|
||||
|
||||
@@ -303,6 +303,10 @@ static NSData *DYLUTFallback(void) {
|
||||
});return chart;
|
||||
}
|
||||
|
||||
static inline uint8_t DYLUTPreviewByte(float value) {
|
||||
return (uint8_t)lroundf(std::max(0.f,std::min(1.f,value))*255);
|
||||
}
|
||||
|
||||
NSImage *DYLUTThumbnail(NSString *path,NSData *source,NSUInteger sourceWidth,NSUInteger sourceHeight,NSSize outputSize,NSError **error) {
|
||||
if(!std::isfinite(outputSize.width)||!std::isfinite(outputSize.height)||outputSize.width<1||outputSize.height<1||outputSize.width>2048||outputSize.height>2048) {
|
||||
DYLUTFail(error,@"缩略图尺寸无效");return nil;
|
||||
@@ -315,7 +319,9 @@ NSImage *DYLUTThumbnail(NSString *path,NSData *source,NSUInteger sourceWidth,NSU
|
||||
bitmapFormat:NSBitmapFormatAlphaNonpremultiplied bytesPerRow:width*4 bitsPerPixel:32]autorelease];
|
||||
if(!bitmap){DYLUTFail(error,@"无法分配缩略图位图");return nil;}
|
||||
const float *p=(const float *)transformed.bytes;uint8_t *q=bitmap.bitmapData;
|
||||
for(NSUInteger y=0;y<height;y++)for(NSUInteger x=0;x<width;x++) {
|
||||
if(width==sourceWidth&&height==sourceHeight){
|
||||
for(NSUInteger i=0;i<width*height*4;i++)q[i]=DYLUTPreviewByte(p[i]);
|
||||
}else for(NSUInteger y=0;y<height;y++)for(NSUInteger x=0;x<width;x++) {
|
||||
// Center-aligned bilinear scaling, independent of NSGraphicsContext.
|
||||
float fx=(float(x)+.5f)*sourceWidth/width-.5f,fy=(float(y)+.5f)*sourceHeight/height-.5f;
|
||||
fx=std::max(0.f,std::min(float(sourceWidth-1),fx));fy=std::max(0.f,std::min(float(sourceHeight-1),fy));
|
||||
@@ -324,7 +330,7 @@ NSImage *DYLUTThumbnail(NSString *path,NSData *source,NSUInteger sourceWidth,NSU
|
||||
for(int c=0;c<4;c++) {
|
||||
float v=(p[(y0*sourceWidth+x0)*4+c]*(1-tx)+p[(y0*sourceWidth+x1)*4+c]*tx)*(1-ty)
|
||||
+(p[(y1*sourceWidth+x0)*4+c]*(1-tx)+p[(y1*sourceWidth+x1)*4+c]*tx)*ty;
|
||||
q[(y*width+x)*4+c]=(uint8_t)lroundf(std::max(0.f,std::min(1.f,v))*255);
|
||||
q[(y*width+x)*4+c]=DYLUTPreviewByte(v);
|
||||
}
|
||||
}
|
||||
NSImage *image=[[[NSImage alloc]initWithSize:NSMakeSize(width,height)]autorelease];[image addRepresentation:bitmap];return image;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
- (NSData*)canvasSpiderScopeAtTime:(CMTime)time;
|
||||
/// Display-encoded float RGBA ("standard", "high") and matching NSSize values
|
||||
/// ("standardSize", "highSize") from one capture, with the visual top row first.
|
||||
/// Host captures also carry the playhead time in seconds as "time".
|
||||
- (NSDictionary*)lookLUTPreviewFrames;
|
||||
- (void)invalidatePreview;
|
||||
/// Conversion/statistics run while visible; retain one small final-output
|
||||
|
||||
@@ -232,6 +232,7 @@ static NSData *DYLookBufferData(id<MTLBuffer> buffer) {
|
||||
}
|
||||
}
|
||||
NSMutableDictionary *frames=[NSMutableDictionary dictionary];
|
||||
if(_scopeDestination&&CMTIME_IS_NUMERIC(_scopeRenderTime))frames[@"time"]=@(CMTimeGetSeconds(_scopeRenderTime));
|
||||
if(look){frames[@"standard"]=look;frames[@"standardSize"]=[NSValue valueWithSize:size];}
|
||||
if(high){frames[@"high"]=DYLookBufferData(high);frames[@"highSize"]=[NSValue valueWithSize:highSize];}
|
||||
[_lookLUTPreviewFrames release];_lookLUTPreviewFrames=[frames copy];
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.5</string>
|
||||
<string>1.21.6</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>123</string>
|
||||
<string>124</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.5</string>
|
||||
<string>1.21.6</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>123</string>
|
||||
<string>124</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
更新于 2026-11-08(Asia/Shanghai)。这是新对话的接手入口。历史设计和实现细节按需查阅专项交接,复现和交付证据以对应版本的报告为准。
|
||||
|
||||
## 1.21.6(124)LUT 预览复用
|
||||
|
||||
2026-11-08。缩略图与右侧划像共用当前画质下的同一张 LUT 位图。点击已生成的缩略图后,等待宿主确认应用,划像左侧保留原图,右侧直接使用该缩略图。浏览器忽略参数更新期间的空快照,同一播放头位置沿用点选前的取样,避免某些色彩管理路径把新应用的 LUT 带入下一轮预览。移到新帧时后台生成新图,生成期间保留上一次完整画面。
|
||||
|
||||
40 项隔离浏览器检查通过,覆盖位图对象复用、空快照、同一时刻的新渲染、移到下一帧、高清切换、顺序与列表。接下来从正式安装路径完成宿主验收、验包和 Release 下载校验。
|
||||
|
||||
## 2026-11-08 点选 LUT 时的预览闪黑排查
|
||||
|
||||
用户在正式 1.21.5(123)观察到缩略图与右侧划像同时闪一下,缩略图短暂显示生成提示。选择写入宿主 LUT 参数后,参数变化回调清空渲染器的预览缓存并通知界面。浏览器收到空快照时将可见缩略图置空,右侧划像也移除原图和应用 LUT 的图层。缩略图此时绘制「生成预览…」,划像只绘制黑底。宿主送出下一帧、后台完成位图后,两个区域重新显示。[参数回调](大鱼调色/Plugin/DYPlugIn.mm#L41) · [缓存失效](大鱼调色/Plugin/DYRenderer.mm#L270) · [浏览器更新](大鱼调色/Plugin/DYLUTBrowser.mm#L571)
|
||||
|
||||
在新工单中引用
屏蔽一个用户