修复 LUT 浏览器帧比例和会话内排序
这个提交包含在:
1 父节点
5c0f177bde
当前提交
b7c2e291ec
18 个文件已更改
+205
-139
没有与搜索条件相匹配的文件
@@ -26,12 +26,23 @@ int main(int argc,const char **argv){@autoreleasepool{
|
||||
require([[[browser valueForKey:@"visibleEntries"]valueForKey:@"path"]isEqual:@[alpha,zulu,middle]],@"all LUTs also put recent uses before unused names");
|
||||
id tile=[[browser valueForKey:@"tiles"]objectForKey:middle];[tile setEnabled:YES];[browser thumbnailClicked:tile];require([library.recentPaths isEqual:@[alpha,zulu]],@"loading does not update recent history");ack([NSError errorWithDomain:@"host" code:1 userInfo:nil]);require([library.recentPaths isEqual:@[alpha,zulu]],@"host rejection does not update history");
|
||||
[browser thumbnailClicked:tile];ack(nil);require([library.recentPaths isEqual:@[middle,alpha,zulu]],@"only successful host application records recent use");
|
||||
NSSearchField *search=[browser valueForKey:@"search"];search.stringValue=@"Zulu";[browser rebuildGrid];require([[browser valueForKey:@"visibleEntries"]count]==1,@"search respects recent-first ordering");search.stringValue=@"";[browser rebuildGrid];
|
||||
require([[[browser valueForKey:@"visibleEntries"]valueForKey:@"path"]isEqual:@[alpha,zulu,middle]]&&[tile isEqual:[[browser valueForKey:@"tiles"]objectForKey:middle]]&&[[tile valueForKey:@"chosen"]boolValue],@"selecting a LUT keeps the tiles in place and updates selection");
|
||||
NSSearchField *search=[browser valueForKey:@"search"];search.stringValue=@"Zulu";[browser rebuildGrid];require([[browser valueForKey:@"visibleEntries"]count]==1,@"search respects recent-first ordering");search.stringValue=@"";[browser rebuildGrid];require([[[browser valueForKey:@"visibleEntries"]valueForKey:@"path"]isEqual:@[alpha,zulu,middle]],@"clearing a search still uses the opening order");
|
||||
for(NSButton *button in [browser valueForKey:@"folderButtons"])if([button.identifier isEqual:@"@recent"])[browser folderClicked:button];
|
||||
require([[[browser valueForKey:@"visibleEntries"]valueForKey:@"path"]isEqual:@[alpha,zulu]],@"recent folder also uses the opening order");[browser folderClicked:all];
|
||||
NSView *view=[browser valueForKey:@"root"];[view setFrameSize:NSMakeSize(1200,760)];[browser layoutBrowser];NSInteger wide=[[browser valueForKey:@"columns"]integerValue];[view setFrameSize:NSMakeSize(720,420)];[browser layoutBrowser];require(wide>[[browser valueForKey:@"columns"]integerValue],@"grid reflows when the browser size changes");
|
||||
NSPopUpButton *layout=[browser valueForKey:@"layoutMenu"];[layout selectItemAtIndex:1];[browser layoutChanged:nil];require([[browser valueForKey:@"columns"]integerValue]==1&&[[browser valueForKey:@"tileHeight"]doubleValue]==70,@"list layout has full-width rows");
|
||||
NSSplitView *split=[browser valueForKey:@"splitView"];[split setPosition:240 ofDividerAtIndex:0];[browser layoutBrowser];NSScrollView *folders=[browser valueForKey:@"folderScroll"],*grid=[browser valueForKey:@"gridScroll"];require(fabs(folders.frame.size.width-240)<2&&NSMaxX(folders.frame)<=NSMinX(grid.frame),@"sidebar divider changes folder width without overlapping previews");
|
||||
[browser close];[browser release];browser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:nil palette:@{} selection:nil];pump(^{return [browser valueForKey:@"libraryTask"]==nil;});require([(NSPopUpButton*)[browser valueForKey:@"layoutMenu"]indexOfSelectedItem]==1&&fabs([[browser valueForKey:@"sidebarWidth"]doubleValue]-240)<2,@"layout and sidebar width survive reopening");
|
||||
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;});
|
||||
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");
|
||||
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");
|
||||
|
||||
@@ -235,7 +235,7 @@ static BOOL DYWorkspaceEnabled(DYUniforms u,NSString *type){if([type isEqual:@"b
|
||||
_status.stringValue=[NSString stringWithFormat:@"%@\n%@ · 有效 %@ · 透明 %@ · 非有限 %@ · 超出 −10%%/110%% %@/%@",([data[@"converted"]boolValue]?@"最终画面 · sRGB 显示参考;非 HDR / IRE 精密测量":@"空间未知:显示宿主 RGB 数值参考;不用于 HDR / IRE 测量"),frame,data[@"valid"],data[@"transparent"],data[@"nonfinite"],data[@"below"],data[@"above"]];
|
||||
}else _status.stringValue=@"示波器采集当前效果的最终输出。播放、移动时间线或调整颜色后更新;透明像素不计入。";
|
||||
}
|
||||
- (void)previewChanged:(NSNotification *)notification{if(_visible&&_editorMode==2){NSDictionary *frames=[_renderer lookLUTPreviewFrames];[_browser updatePreview:frames[@"standard"] highResolution:frames[@"high"]];}}
|
||||
- (void)previewChanged:(NSNotification *)notification{if(_visible&&_editorMode==2)[_browser updatePreview:[_renderer lookLUTPreviewFrames]];}
|
||||
- (void)themeChanged:(NSNotification *)notification{[self updatePalette];}
|
||||
- (void)updatePalette{
|
||||
[_root setNeedsDisplay:YES];for(NSTextField *label in @[_heading,_description,_status,_lutExplanation])label.textColor=DYThemeColor(label==_heading?@"text":@"secondary");[_browser updatePalette:DYWorkspacePalette()];
|
||||
@@ -244,8 +244,7 @@ static BOOL DYWorkspaceEnabled(DYUniforms u,NSString *type){if([type isEqual:@"b
|
||||
if(_browser.visible)return;[_browser release];_browser=nil;id<FxCustomParameterActionAPI_v4> action=[[self lutManager] apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!action){[self reportError:@"宿主暂时无法读取风格1"];return;}
|
||||
NSString *selected=nil;[action startAction:self];@try{selected=[DYReadAssets([self lutManager],action.currentTime).paths[@"look0"]copy];}@finally{[action endAction:self];}
|
||||
DYWorkspaceLifetime *token=_lifetime;
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreview] selectedPath:selected palette:DYWorkspacePalette() selection:^NSProgress *(NSString *path,void(^completion)(NSError *)){DYColorWorkspace *owner=token.owner;if(owner&&!owner->_closed)return [owner selectLUT:path completion:completion];if(completion)completion([NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]);return nil;}];[selected release];
|
||||
NSDictionary *frames=[_renderer lookLUTPreviewFrames];[_browser updatePreview:frames[@"standard"] highResolution:frames[@"high"]];
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreviewFrames] selectedPath:selected palette:DYWorkspacePalette() selection:^NSProgress *(NSString *path,void(^completion)(NSError *)){DYColorWorkspace *owner=token.owner;if(owner&&!owner->_closed)return [owner selectLUT:path completion:completion];if(completion)completion([NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]);return nil;}];[selected release];
|
||||
[_browser embedInView:_lutPane close:^{DYColorWorkspace *owner=token.owner;if(owner&&!owner->_closing&&!owner->_closed){owner->_editorMode=0;[owner pageChanged:nil];}}];
|
||||
}
|
||||
- (NSDictionary *)selectionContextAtTime:(CMTime)time{
|
||||
|
||||
+33
-18
@@ -14,7 +14,6 @@
|
||||
#import "DYColorTables.h"
|
||||
#import "DYLUTLibrary.h"
|
||||
#import "DYLUTBrowser.h"
|
||||
#include "DYLookPreview.h"
|
||||
#import "DYInspector.h"
|
||||
#import "DYTheme.h"
|
||||
#include "DYSpiderState.h"
|
||||
@@ -411,31 +410,47 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
DYRenderer *orientationRenderer=[[[DYRenderer alloc]init]autorelease];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:marker.data() bytesPerRow:width*8];
|
||||
error=nil;BOOL topRendered=[orientationRenderer renderSource:source destination:destination uniforms:defaults paths:@{} error:&error];
|
||||
NSData *topAnalysis=[orientationRenderer preview],*topLook=[orientationRenderer lookLUTPreview];
|
||||
bool topOrientation=topRendered&&topLook.length==320*180*16&&[topLook isEqualToData:topAnalysis];
|
||||
if(topOrientation){const float*p=(const float*)topLook.bytes;topOrientation=p[0]>p[2]&&p[(179*320)*4+2]>p[(179*320)*4];}
|
||||
run.record(@"look-preview-top-left-is-original-analysis",topOrientation,@{@"error":topRendered?@"":reason(error),@"bytes":@(topLook.length)});
|
||||
NSData *topAnalysis=[orientationRenderer preview];
|
||||
NSDictionary *topFrames=[orientationRenderer lookLUTPreviewFrames];
|
||||
NSData *topLook=topFrames[@"standard"];
|
||||
NSSize standardSize=[topFrames[@"standardSize"] sizeValue];
|
||||
bool topOrientation=topRendered&&NSEqualSizes(standardSize,NSMakeSize(320,240))&&topLook.length==320*240*16;
|
||||
if(topOrientation){const float*p=(const float*)topLook.bytes;topOrientation=p[0]>p[2]&&p[(239*320)*4+2]>p[(239*320)*4];}
|
||||
run.record(@"look-preview-standard-4-by-3-top-first",topOrientation,@{@"error":topRendered?@"":reason(error),@"size":NSStringFromSize(standardSize)});
|
||||
[orientationRenderer invalidatePreview];[source setDiagnosticImageOrigin:kFxImageOrigin_BOTTOM_LEFT];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:bottomFirst.data() bytesPerRow:width*8];
|
||||
error=nil;BOOL bottomRendered=[orientationRenderer renderSource:source destination:destination uniforms:defaults paths:@{} error:&error];
|
||||
NSData *bottomAnalysis=[orientationRenderer preview],*bottomLook=[orientationRenderer lookLUTPreview];
|
||||
bool bottomOrientation=bottomRendered&&bottomAnalysis.length==320*180*16&&bottomLook.length==bottomAnalysis.length;
|
||||
if(bottomOrientation){
|
||||
const float*a=(const float*)bottomAnalysis.bytes,*b=(const float*)bottomLook.bytes;
|
||||
bottomOrientation=a[2]>a[0]&&a[(179*320)*4]>a[(179*320)*4+2]&&b[0]>b[2]&&b[(179*320)*4+2]>b[(179*320)*4];
|
||||
for(NSUInteger y=0;y<180&&bottomOrientation;y++)bottomOrientation=memcmp((const uint8_t*)bottomLook.bytes+y*320*16,(const uint8_t*)bottomAnalysis.bytes+(179-y)*320*16,320*16)==0;
|
||||
}
|
||||
run.record(@"look-preview-bottom-left-flips-only-browser-rows",bottomOrientation,@{@"error":bottomRendered?@"":reason(error),@"analysisKeepsPhysicalRowOrder":@(bottomOrientation),@"all180RowsCompared":@(bottomOrientation)});
|
||||
NSData *high=[orientationRenderer lookLUTPreviewFrames][@"high"];
|
||||
bool highOrientation=high.length==DYLookPreviewHDWidth*DYLookPreviewHDHeight*16;
|
||||
NSData *bottomAnalysis=[orientationRenderer preview];
|
||||
NSDictionary *bottomFrames=[orientationRenderer lookLUTPreviewFrames];
|
||||
NSData *bottomLook=bottomFrames[@"standard"];
|
||||
bool bottomOrientation=bottomRendered&&bottomAnalysis.length==320*180*16&&topAnalysis.length==bottomAnalysis.length&&[bottomLook isEqualToData:topLook];
|
||||
for(NSUInteger y=0;y<180&&bottomOrientation;y++)
|
||||
bottomOrientation=memcmp((const uint8_t*)topAnalysis.bytes+y*320*16,(const uint8_t*)bottomAnalysis.bytes+(179-y)*320*16,320*16)==0;
|
||||
run.record(@"look-preview-bottom-left-flips-only-browser-rows",bottomOrientation,@{@"error":bottomRendered?@"":reason(error)});
|
||||
NSData *high=bottomFrames[@"high"];
|
||||
NSSize highSize=[bottomFrames[@"highSize"] sizeValue];
|
||||
bool highOrientation=NSEqualSizes(highSize,NSMakeSize(640,480))&&high.length==640*480*16;
|
||||
if(highOrientation){
|
||||
const float *p=static_cast<const float*>(high.bytes);
|
||||
const size_t bottom=(DYLookPreviewHDHeight-1)*DYLookPreviewHDWidth*4;
|
||||
const size_t bottom=(480-1)*640*4;
|
||||
highOrientation=p[0]>p[2]&&p[bottom+2]>p[bottom];
|
||||
}
|
||||
run.record(@"look-preview-hd-640x360-top-first",highOrientation,@{@"bytes":@(high.length)});
|
||||
run.record(@"look-preview-high-4-by-3-top-first",highOrientation,@{@"size":NSStringFromSize(highSize)});
|
||||
[orientationRenderer invalidatePreview];
|
||||
run.record(@"preview-invalidation-clears-analysis-and-browser",![orientationRenderer preview]&&![orientationRenderer lookLUTPreview]&&![[orientationRenderer lookLUTPreviewFrames] count]);
|
||||
run.record(@"preview-invalidation-clears-analysis-and-browser",![orientationRenderer preview]&&![[orientationRenderer lookLUTPreviewFrames] count]);
|
||||
const NSUInteger frameSizes[][4]={{64,36,320,180},{36,64,180,320},{64,64,320,320},{84,36,320,137}};
|
||||
for(const auto& size:frameSizes){
|
||||
DYDiagnosticTile *frame=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:size[0] height:size[1]]autorelease];
|
||||
DYDiagnosticTile *output=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:size[0] height:size[1]]autorelease];
|
||||
error=nil;BOOL rendered=[orientationRenderer renderSource:frame destination:output uniforms:defaults paths:@{} error:&error];
|
||||
NSDictionary *frames=[orientationRenderer lookLUTPreviewFrames];
|
||||
NSSize standard=[frames[@"standardSize"] sizeValue],hd=[frames[@"highSize"] sizeValue];
|
||||
BOOL valid=rendered&&NSEqualSizes(standard,NSMakeSize(size[2],size[3]))
|
||||
&&labs((long)hd.width-2*(long)size[2])<=1&&labs((long)hd.height-2*(long)size[3])<=1
|
||||
&&[frames[@"standard"] length]==standard.width*standard.height*16
|
||||
&&[frames[@"high"] length]==hd.width*hd.height*16;
|
||||
run.record([NSString stringWithFormat:@"look-preview-tracks-frame-%lux%lu",(unsigned long)size[0],(unsigned long)size[1]],valid,@{@"standard":NSStringFromSize(standard),@"high":NSStringFromSize(hd),@"error":reason(error)});
|
||||
}
|
||||
[source setDiagnosticImageOrigin:kFxImageOrigin_TOP_LEFT];
|
||||
[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:input.data() bytesPerRow:width*8];
|
||||
DYUniforms cstExport=defaults;cstExport.cm.configured=1;cstExport.cm.exposure=.7f;
|
||||
|
||||
@@ -335,15 +335,14 @@ kernel void dyInputAnalysis(texture2d<half> source [[texture(0)]],
|
||||
outRGBA[pixel.y*320+pixel.x]=dyInputPreviewPixel(source,inputLUT,inputStrength,(float2(pixel)+.5f)/float2(320,180),true);
|
||||
}
|
||||
|
||||
#include "DYLookPreview.h"
|
||||
kernel void dyInputHighPreview(texture2d<half> source [[texture(0)]],
|
||||
kernel void dyInputLookPreview(texture2d<half> source [[texture(0)]],
|
||||
texture3d<float> inputLUT [[texture(1)]], device float4* outRGBA [[buffer(0)]],
|
||||
constant float& inputStrength [[buffer(1)]],constant uint& flip [[buffer(2)]],
|
||||
constant float& inputStrength [[buffer(1)]],constant uint4& geometry [[buffer(2)]],
|
||||
uint2 pixel [[thread_position_in_grid]]) {
|
||||
constexpr uint2 size(DYLookPreviewHDWidth,DYLookPreviewHDHeight);
|
||||
uint2 size=geometry.xy;
|
||||
if(any(pixel>=size))return;
|
||||
uint2 sample=uint2(pixel.x,flip?size.y-1-pixel.y:pixel.y);
|
||||
outRGBA[pixel.y*size.x+pixel.x]=dyInputPreviewPixel(source,inputLUT,inputStrength,(float2(sample)+.5f)/float2(size),false);
|
||||
uint2 sample=uint2(pixel.x,geometry.z?size.y-1-pixel.y:pixel.y);
|
||||
outRGBA[pixel.y*size.x+pixel.x]=dyInputPreviewPixel(source,inputLUT,inputStrength,(float2(sample)+.5f)/float2(size),geometry.w!=0);
|
||||
}
|
||||
|
||||
// CST/BASIS arithmetic is reused verbatim from the versioned dayu-cst source.
|
||||
|
||||
+10
-4
@@ -683,7 +683,14 @@ NSView<DYWorkspaceMaskEditing> *DYCreateWorkspaceMaskEditor(id<PROAPIAccessing>
|
||||
[(DYCurvePanel *)graphic setHistogram:histogram];
|
||||
}
|
||||
}
|
||||
- (void)previewChanged:(NSNotification *)note {[_managedPanel refreshContext];if(_browser.visible){NSDictionary *frames=[_renderer lookLUTPreviewFrames];[_browser updatePreview:frames[@"standard"] highResolution:frames[@"high"]];}if(_recentBrowser.visible)[_recentBrowser updatePreview:[_renderer lookLUTPreview]];}
|
||||
- (void)previewChanged:(NSNotification *)note {
|
||||
[_managedPanel refreshContext];
|
||||
if(_browser.visible||_recentBrowser.visible){
|
||||
NSDictionary *frames=[_renderer lookLUTPreviewFrames];
|
||||
if(_browser.visible)[_browser updatePreview:frames];
|
||||
if(_recentBrowser.visible)[_recentBrowser updatePreview:frames];
|
||||
}
|
||||
}
|
||||
- (void)buildCards {
|
||||
NSInteger index=0;
|
||||
for(NSDictionary *section in _sections) {
|
||||
@@ -799,7 +806,7 @@ NSView<DYWorkspaceMaskEditing> *DYCreateWorkspaceMaskEditor(id<PROAPIAccessing>
|
||||
if(_workspaceEditor){
|
||||
_recentHost=[[DYFlippedView alloc]initWithFrame:NSMakeRect(12,80,600,160)];_recentHost.identifier=@"recentLUTs";[card addSubview:_recentHost];
|
||||
__block DYInspector *owner=self;
|
||||
_recentBrowser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreview] selectedPath:nil palette:DYThemePalette() selection:^NSProgress *(NSString *path,void (^completion)(NSError *)){return [owner setAssetPath:path forKey:@"look0" completion:completion];}];
|
||||
_recentBrowser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreviewFrames] selectedPath:nil palette:DYThemePalette() selection:^NSProgress *(NSString *path,void (^completion)(NSError *)){return [owner setAssetPath:path forKey:@"look0" completion:completion];}];
|
||||
[_recentBrowser embedRecentInView:_recentHost];
|
||||
}
|
||||
}
|
||||
@@ -1265,8 +1272,7 @@ NSView<DYWorkspaceMaskEditing> *DYCreateWorkspaceMaskEditor(id<PROAPIAccessing>
|
||||
[_browser close];[_browser release];_browser=nil;
|
||||
id<FxCustomParameterActionAPI_v4> a=[self actionAPI];if(!a)return;[a startAction:self];NSString *selected=nil;@try{selected=[DYReadAssets(_manager,a.currentTime).paths[sender.identifier]copy];}@finally{[a endAction:self];}
|
||||
__block DYInspector *owner=self;NSString *key=[[sender.identifier copy]autorelease];
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreview] selectedPath:selected palette:DYThemePalette() selection:^NSProgress *(NSString *path,void (^completion)(NSError *)){return [owner setAssetPath:path forKey:key completion:completion];}];[selected release];
|
||||
NSDictionary *frames=[_renderer lookLUTPreviewFrames];[_browser updatePreview:frames[@"standard"] highResolution:frames[@"high"]];
|
||||
_browser=[[DYLUTBrowser alloc]initWithLibrary:_library preview:[_renderer lookLUTPreviewFrames] selectedPath:selected palette:DYThemePalette() selection:^NSProgress *(NSString *path,void (^completion)(NSError *)){return [owner setAssetPath:path forKey:key completion:completion];}];[selected release];
|
||||
// Remote-window APIs must be acquired and invoked inside the custom
|
||||
// parameter action, while the SDK's API permissions are still installed.
|
||||
[a startAction:self];
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef NSProgress * (^DYLUTSelectionHandler)(NSString *path,void (^completion)(
|
||||
+ (NSSize)maximumContentSize;
|
||||
+ (NSSize)preferredContentSize;
|
||||
- (instancetype)initWithLibrary:(DYLUTLibrary *)library
|
||||
preview:(NSData *)rgba
|
||||
preview:(NSDictionary *)frames
|
||||
selectedPath:(NSString *)path
|
||||
palette:(NSDictionary *)palette
|
||||
selection:(DYLUTSelectionHandler)selection;
|
||||
@@ -29,6 +29,5 @@ typedef NSProgress * (^DYLUTSelectionHandler)(NSString *path,void (^completion)(
|
||||
- (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.
|
||||
- (void)updatePreview:(NSData *)rgba;
|
||||
- (void)updatePreview:(NSData *)rgba highResolution:(NSData *)high;
|
||||
- (void)updatePreview:(NSDictionary *)frames;
|
||||
@end
|
||||
+50
-39
@@ -1,5 +1,4 @@
|
||||
#import "DYLUTBrowser.h"
|
||||
#import "DYLookPreview.h"
|
||||
#import "DYLUTLibrary.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include <algorithm>
|
||||
@@ -77,6 +76,16 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
- (void)dealloc{[_palette release];[_fillKey release];[super dealloc];}
|
||||
@end
|
||||
|
||||
static NSSize DYBrowserFitSize(NSSize source,NSSize box) {
|
||||
CGFloat scale=MIN(box.width/source.width,box.height/source.height);
|
||||
return NSMakeSize(source.width*scale,source.height*scale);
|
||||
}
|
||||
|
||||
static NSRect DYBrowserTileImageRect(NSRect bounds,BOOL list) {
|
||||
return list?NSMakeRect(3,3,104,MAX(1,NSHeight(bounds)-6))
|
||||
:NSMakeRect(2,2,MAX(1,NSWidth(bounds)-4),MAX(1,NSHeight(bounds)-27));
|
||||
}
|
||||
|
||||
@interface DYBrowserTile : NSButton
|
||||
@property(retain) NSImage *thumbnail;
|
||||
@property(copy) NSString *displayName;
|
||||
@@ -101,12 +110,12 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
NSRect bounds=NSInsetRect(self.bounds,1,1);
|
||||
NSBezierPath *outline=[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:7 yRadius:7];
|
||||
[DYBrowserColor(_palette,_chosen?@"field":@"card") setFill];[outline fill];
|
||||
NSRect imageRect=_listLayout?NSMakeRect(3,3,104,bounds.size.height-4):NSMakeRect(2,2,MAX(1,bounds.size.width-2),MAX(1,bounds.size.height-25));
|
||||
NSRect imageRect=DYBrowserTileImageRect(self.bounds,_listLayout);
|
||||
if(_thumbnail){
|
||||
[NSGraphicsContext saveGraphicsState];
|
||||
[[NSBezierPath bezierPathWithRoundedRect:imageRect xRadius:4 yRadius:4]addClip];
|
||||
NSSize size=_thumbnail.size;CGFloat scale=MAX(imageRect.size.width/MAX(1,size.width),imageRect.size.height/MAX(1,size.height));
|
||||
NSRect dest=NSMakeRect(NSMidX(imageRect)-size.width*scale/2,NSMidY(imageRect)-size.height*scale/2,size.width*scale,size.height*scale);
|
||||
NSSize size=DYBrowserFitSize(_thumbnail.size,imageRect.size);
|
||||
NSRect dest=NSMakeRect(NSMidX(imageRect)-size.width/2,NSMidY(imageRect)-size.height/2,size.width,size.height);
|
||||
[_thumbnail drawInRect:dest fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
}else{
|
||||
@@ -201,7 +210,7 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
|
||||
@interface DYLUTBrowser () <NSWindowDelegate,NSPopoverDelegate,NSSearchFieldDelegate,NSSplitViewDelegate> {
|
||||
DYLUTLibrary *_library;
|
||||
NSData *_preview,*_previewHD;
|
||||
NSDictionary *_previewFrames;
|
||||
NSString *_selectedPath,*_folder;
|
||||
NSDictionary *_palette;
|
||||
DYLUTSelectionHandler _selection;
|
||||
@@ -246,13 +255,13 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
}
|
||||
static NSTextField *BrowserLabel(NSString *title,CGFloat size){NSTextField *label=[NSTextField labelWithString:title];label.font=[NSFont systemFontOfSize:size];label.lineBreakMode=NSLineBreakByTruncatingTail;return label;}
|
||||
static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *button=[NSButton buttonWithTitle:title target:target action:action];button.font=[NSFont systemFontOfSize:11];button.bezelStyle=NSBezelStyleRounded;return button;}
|
||||
- (instancetype)initWithLibrary:(DYLUTLibrary *)library preview:(NSData *)rgba selectedPath:(NSString *)path palette:(NSDictionary *)palette selection:(DYLUTSelectionHandler)selection{
|
||||
- (instancetype)initWithLibrary:(DYLUTLibrary *)library preview:(NSDictionary *)frames selectedPath:(NSString *)path palette:(NSDictionary *)palette selection:(DYLUTSelectionHandler)selection{
|
||||
NSPanel *panel=[[[NSPanel alloc]initWithContentRect:NSMakeRect(0,0,760,560) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];
|
||||
if((self=[super initWithWindow:panel])){
|
||||
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];_preview=[rgba copy];_selectedPath=[path copy];_folder=[(savedFolder?:@"*") copy];_selection=[selection copy];
|
||||
_library=[library retain];_previewFrames=[frames copy];_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;
|
||||
@@ -316,7 +325,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
_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];[_preview release];[_previewHD release];[_selectedPath release];[_folder release];[_palette release];[_selection release];[_closeAction release];
|
||||
[_library release];[_previewFrames 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];
|
||||
@@ -363,7 +372,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
[_layoutMenu selectItemAtIndex:0];_sizeSlider.doubleValue=120;
|
||||
for(NSView *view in @[_search,_importFiles,_importFolder,_reveal,_refresh,_none,_done,_hd,_comparePanel,_sizeLabel,_sizeSlider,_layoutMenu,_splitView])view.hidden=YES;
|
||||
[_root addSubview:_gridScroll];_gridScroll.hasHorizontalScroller=NO;_gridScroll.scrollerStyle=NSScrollerStyleOverlay;
|
||||
[self showInRemoteParent:parent close:nil];[self refreshRecentSelection:_selectedPath];
|
||||
[self showInRemoteParent:parent close:nil];[self rebuildGrid];[self refreshRecentSelection:_selectedPath];
|
||||
}
|
||||
- (void)refreshRecentSelection:(NSString *)path{
|
||||
if(!_compactRecent||_closed)return;
|
||||
@@ -505,9 +514,12 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
if(!_compactRecent){CGFloat fw=MAX(100,_folderScroll.contentSize.width);
|
||||
_folderDocument.frame=NSMakeRect(0,0,fw,MAX(_folderPaths.count*35+4,_folderScroll.contentSize.height));
|
||||
[self updateVisibleFolders];}
|
||||
CGFloat available=MAX(80,_gridScroll.contentSize.width),tileWidth=_sizeSlider.doubleValue,gap=10;
|
||||
CGFloat available=MAX(80,_gridScroll.contentSize.width),edge=_sizeSlider.doubleValue,gap=10;
|
||||
NSSize source=[self previewSize],preferred=DYBrowserFitSize(source,NSMakeSize(edge-4,edge-4));
|
||||
CGFloat tileWidth=MAX(70,ceil(preferred.width)+4);
|
||||
BOOL list=_layoutMenu.indexOfSelectedItem==1;NSInteger columns=list?1:MAX(1,(NSInteger)floor((available+gap)/(tileWidth+gap)));tileWidth=list?MAX(110,available-14):MIN(tileWidth,(available-gap*(columns-1)-14)/columns);tileWidth=MAX(70,tileWidth);
|
||||
_columns=columns;_tileWidth=tileWidth;_tileHeight=list?70:ceil(tileWidth*9/16)+24;
|
||||
_columns=columns;_tileWidth=tileWidth;
|
||||
_tileHeight=list?70:ceil(DYBrowserFitSize(source,NSMakeSize(tileWidth-4,edge-4)).height)+27;
|
||||
NSInteger rows=(_visibleEntries.count+columns-1)/columns;CGFloat contentHeight=MAX(_gridScroll.contentSize.height,rows*(_tileHeight+gap)+12);
|
||||
_gridDocument.frame=NSMakeRect(0,0,available,contentHeight);_emptyLabel.frame=NSMakeRect(20,MAX(36,_gridScroll.contentSize.height/2-45),MAX(50,available-40),90);
|
||||
_layingOut=NO;[self updateVisibleTiles];
|
||||
@@ -552,19 +564,16 @@ 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];
|
||||
}
|
||||
- (void)updatePreview:(NSData *)rgba{[self updatePreview:rgba highResolution:nil];}
|
||||
- (void)updatePreview:(NSData *)rgba highResolution:(NSData *)high{
|
||||
if(_closed||(rgba&&rgba.length!=320*180*16)||(high&&high.length!=DYLookPreviewHDWidth*DYLookPreviewHDHeight*16))return;
|
||||
BOOL standardChanged=_preview!=rgba&&![_preview isEqualToData:rgba];
|
||||
BOOL highChanged=_previewHD!=high&&![_previewHD isEqualToData:high];
|
||||
if(!standardChanged&&!highChanged)return;
|
||||
[_preview release];_preview=[rgba retain];
|
||||
[_previewHD release];_previewHD=[high retain];
|
||||
if(standardChanged||(highChanged&&_hd.state==NSControlStateValueOn)){
|
||||
[_thumbnailCache removeAllObjects];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(refreshThumbnailSize) object:nil];
|
||||
[self refreshThumbnailSize];
|
||||
}
|
||||
- (NSSize)previewSize {
|
||||
NSValue *size=_previewFrames[@"standardSize"]?:_previewFrames[@"highSize"];
|
||||
return size?size.sizeValue:NSMakeSize(320,180);
|
||||
}
|
||||
- (void)updatePreview:(NSDictionary *)frames{
|
||||
if(_closed||_previewFrames==frames||[_previewFrames isEqual:frames])return;
|
||||
[_previewFrames release];_previewFrames=[frames copy];
|
||||
[_thumbnailCache removeAllObjects];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(refreshThumbnailSize) object:nil];
|
||||
[self refreshThumbnailSize];
|
||||
[self refreshComparison];
|
||||
}
|
||||
- (void)qualityChanged:(id)sender{
|
||||
@@ -576,17 +585,17 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (void)refreshComparison{
|
||||
if(_closed||_compactRecent||!self.visible)return;
|
||||
_compareWork.cancelled=YES;_compareWork.owner=nil;[_compareWork release];_compareWork=nil;
|
||||
NSData *frame=_previewHD?:_preview;
|
||||
NSData *frame=_previewFrames[@"high"]?:_previewFrames[@"standard"];
|
||||
if(!frame){[_compareView setOriginal:nil styled:nil];_compareSlider.enabled=NO;_compareStatus.stringValue=@"等待播放头画面";return;}
|
||||
NSUInteger w=_previewHD?DYLookPreviewHDWidth:320,h=_previewHD?DYLookPreviewHDHeight:180;
|
||||
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{
|
||||
if(work.cancelled)return;
|
||||
NSImage *original=DYLUTThumbnail(nil,frame,w,h,NSMakeSize(w,h),nil);
|
||||
NSImage *original=DYLUTThumbnail(nil,frame,size.width,size.height,size,nil);
|
||||
if(work.cancelled)return;
|
||||
NSImage *styled=path.length?DYLUTThumbnail(path,frame,w,h,NSMakeSize(w,h),nil):nil;
|
||||
NSImage *styled=path.length?DYLUTThumbnail(path,frame,size.width,size.height,size,nil):nil;
|
||||
dispatch_async(dispatch_get_main_queue(),^{
|
||||
DYLUTBrowser *owner=work.owner;if(work.cancelled||!owner)return;
|
||||
owner->_compareSlider.enabled=styled!=nil&&original!=nil;
|
||||
@@ -656,29 +665,31 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
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 generateVisibleThumbnails];
|
||||
[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;
|
||||
NSUInteger width=MAX((NSUInteger)64,(NSUInteger)llround(_sizeSlider.doubleValue)),height=MAX((NSUInteger)40,(NSUInteger)llround(width*9./16));
|
||||
if(hd){width*=2;height*=2;}
|
||||
NSData *frame=hd&&_previewHD?_previewHD:_preview;
|
||||
NSUInteger sourceWidth=hd&&_previewHD?DYLookPreviewHDWidth:320,sourceHeight=hd&&_previewHD?DYLookPreviewHDHeight:180;
|
||||
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|%lu|%@",hd,(unsigned long)width,path];
|
||||
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,sourceWidth,sourceHeight,NSMakeSize(width,height),&error);NSString *failure=error.localizedDescription;
|
||||
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];
|
||||
@@ -694,14 +705,14 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
[self resetThumbnailWork];
|
||||
for(NSView *tile in _tiles.allValues)[tile removeFromSuperview];[_tiles removeAllObjects];
|
||||
NSString *query=[_search.stringValue stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];NSMutableArray *entries=[NSMutableArray array];
|
||||
BOOL recent=[_folder isEqual:DYBrowserRecentFolder];NSArray *history=_library.recentPaths;
|
||||
for(NSDictionary *entry in (recent?_library.recentEntries:_library.entries)){
|
||||
BOOL recent=[_folder isEqual:DYBrowserRecentFolder];NSArray *history=_recentSnapshot;
|
||||
for(NSDictionary *entry in (recent?[_library recentEntriesForPaths:history]:_library.entries)){
|
||||
NSString *folder=entry[@"relativeFolder"]?:@"";
|
||||
BOOL folderMatch=recent||[_folder isEqualToString:@"*"]||[folder isEqualToString:_folder]||(_folder.length&&[folder hasPrefix:[_folder stringByAppendingString:@"/"]]);
|
||||
if(folderMatch&&(!query.length||[entry[@"name"]localizedCaseInsensitiveContainsString:query]||[entry[@"relativePath"]localizedCaseInsensitiveContainsString:query]))[entries addObject:entry];
|
||||
}
|
||||
if(!recent)[entries sortUsingComparator:^NSComparisonResult(NSDictionary *a,NSDictionary *b){NSUInteger i=[history indexOfObject:a[@"path"]],j=[history indexOfObject:b[@"path"]];if(i==j)return [a[@"relativePath"]localizedStandardCompare:b[@"relativePath"]];return i<j?NSOrderedAscending:NSOrderedDescending;}];
|
||||
_emptyLabel.stringValue=recent?@"尚未使用 LUT。成功应用后会在这里按最近使用排序。":@"此文件夹还没有 LUT。\n点“导入文件”或“导入文件夹”添加 .cube 文件。";
|
||||
_emptyLabel.stringValue=recent?@"尚未使用 LUT。应用后,下次打开会显示最近使用记录。":@"此文件夹还没有 LUT。\n点“导入文件”或“导入文件夹”添加 .cube 文件。";
|
||||
[_visibleEntries release];_visibleEntries=[entries copy];_countLabel.stringValue=[NSString stringWithFormat:@"%lu 个 LUT",(unsigned long)entries.count];_emptyLabel.hidden=entries.count>0;
|
||||
[_gridScroll.contentView scrollToPoint:NSZeroPoint];[self layoutBrowser];[_gridScroll reflectScrolledClipView:_gridScroll.contentView];
|
||||
NSAccessibilityPostNotification(_gridDocument,NSAccessibilityLayoutChangedNotification);
|
||||
@@ -713,7 +724,7 @@ 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 rebuildGrid];[self refreshComparison];
|
||||
[_selectedPath release];_selectedPath=[path copy];[_library recordUsedPath:path];[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];
|
||||
};
|
||||
|
||||
@@ -51,6 +51,7 @@ FOUNDATION_EXPORT NSImage * _Nullable DYLUTThumbnail(NSString * _Nullable path,
|
||||
/// Most recently acknowledged applications, newest first, scoped to this library.
|
||||
@property(nonatomic,readonly,copy) NSArray<NSString *> *recentPaths;
|
||||
@property(nonatomic,readonly,copy) NSArray<NSDictionary<NSString *,NSString *> *> *recentEntries;
|
||||
- (NSArray<NSDictionary<NSString *,NSString *> *> *)recentEntriesForPaths:(NSArray<NSString *> *)paths;
|
||||
- (void)recordUsedPath:(NSString *)path;
|
||||
+ (NSURL *)defaultRootURL;
|
||||
- (instancetype)init;
|
||||
|
||||
@@ -406,9 +406,10 @@ static BOOL DYLUTEnsureDirectory(NSURL *directory,NSURL *root,NSError **error) {
|
||||
}
|
||||
return [[paths copy]autorelease];
|
||||
}
|
||||
- (NSArray *)recentEntries {
|
||||
- (NSArray *)recentEntries {return [self recentEntriesForPaths:self.recentPaths];}
|
||||
- (NSArray *)recentEntriesForPaths:(NSArray *)paths {
|
||||
NSMutableDictionary *known=[NSMutableDictionary dictionary];for(NSDictionary *entry in self.entries)known[entry[@"path"]]=entry;
|
||||
NSMutableArray *entries=[NSMutableArray array];for(NSString *path in self.recentPaths){
|
||||
NSMutableArray *entries=[NSMutableArray array];for(NSString *path in paths){
|
||||
NSDictionary *entry=known[path];
|
||||
if(!entry)entry=@{@"name":path.lastPathComponent.stringByDeletingPathExtension,@"path":path,@"relativePath":path,@"relativeFolder":@""};
|
||||
[entries addObject:entry];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
// Full browser source sampling. The 320×180 auto-grade buffer stays separate.
|
||||
enum { DYLookPreviewHDWidth=640, DYLookPreviewHDHeight=360 };
|
||||
|
||||
// Long-edge limits for the LUT browser. Auto-grade has its own fixed sample.
|
||||
enum { DYLookPreviewStandardEdge=320, DYLookPreviewHighEdge=640 };
|
||||
@@ -26,11 +26,11 @@ kernel void dyManagedCarrier(texture2d<float,access::read> a [[texture(0)]],text
|
||||
fragment float4 dyManagedCopyFragment(DYRaster in [[stage_in]],texture2d<float> source [[texture(0)]]){constexpr sampler f(coord::normalized,address::clamp_to_edge,filter::linear);return source.sample(f,in.uv);}
|
||||
|
||||
kernel void dyManagedPreview(texture2d<float> a [[texture(0)]],device float4* out [[buffer(0)]],uint2 p [[thread_position_in_grid]]){if(any(p>=uint2(320,180)))return;constexpr sampler s(coord::normalized,address::clamp_to_edge,filter::linear);float4 c=a.sample(s,(float2(p)+.5f)/float2(320,180));out[p.y*320+p.x]=float4(c.a>0?dyEncode(c.rgb/c.a):float3(0),c.a);}
|
||||
kernel void dyManagedHighPreview(texture2d<float> a [[texture(0)]],device float4* out [[buffer(0)]],
|
||||
constant uint& flip [[buffer(2)]],uint2 p [[thread_position_in_grid]]){
|
||||
constexpr uint2 size(DYLookPreviewHDWidth,DYLookPreviewHDHeight);
|
||||
kernel void dyManagedLookPreview(texture2d<float> a [[texture(0)]],device float4* out [[buffer(0)]],
|
||||
constant uint4& geometry [[buffer(2)]],uint2 p [[thread_position_in_grid]]){
|
||||
uint2 size=geometry.xy;
|
||||
if(any(p>=size))return;
|
||||
uint2 sample=uint2(p.x,flip?size.y-1-p.y:p.y);
|
||||
uint2 sample=uint2(p.x,geometry.z?size.y-1-p.y:p.y);
|
||||
constexpr sampler s(coord::normalized,address::clamp_to_edge,filter::linear);
|
||||
float4 c=a.sample(s,(float2(sample)+.5f)/float2(size));
|
||||
out[p.y*size.x+p.x]=float4(c.a>0?dyEncode(c.rgb/c.a):float3(0),c.a);
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
- (void)managedPreview:(id<MTLTexture>)texture origin:(FxImageOrigin)origin entry:(NSMutableDictionary*)entry {
|
||||
@synchronized(_previewLock){if(_exporting||CACurrentMediaTime()-_lastPreview<=.5)return;}
|
||||
- (void)managedPreview:(id<MTLTexture>)texture source:(FxImageTile*)source entry:(NSMutableDictionary*)entry {
|
||||
NSSize size=DYLookSampleSize(texture,source.pixelAspect,DYLookPreviewStandardEdge);
|
||||
@synchronized(_previewLock){if(_exporting||(NSEqualSizes(size,_lastLookPreviewSize)&&CACurrentMediaTime()-_lastPreview<=.5))return;}
|
||||
id<MTLComputePipelineState>p=[self computePipeline:@"dyManagedPreview" entry:entry error:nil];if(!p)return;
|
||||
id<MTLBuffer>b=[entry[@"device"]newBufferWithLength:320*180*16 options:MTLResourceStorageModeShared];if(!b)return;
|
||||
id<MTLBuffer>b=[[entry[@"device"]newBufferWithLength:320*180*16 options:MTLResourceStorageModeShared]autorelease];if(!b)return;
|
||||
id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:p];[ce setTexture:texture atIndex:0];[ce setBuffer:b offset:0 atIndex:0];[ce dispatchThreads:MTLSizeMake(320,180,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];[ce endEncoding];
|
||||
id<MTLBuffer>lookHD=[self encodeLookHD:texture inputLUT:nil strength:0 origin:origin entry:entry commands:cb];
|
||||
FxImageOrigin origin=source.imageOrigin;
|
||||
id<MTLBuffer>standard=NSEqualSizes(size,NSMakeSize(320,180))?nil:[self encodeLookPreview:texture inputLUT:nil strength:0 size:size standard:YES origin:origin entry:entry commands:cb];
|
||||
NSSize highSize=DYLookSampleSize(texture,source.pixelAspect,DYLookPreviewHighEdge);
|
||||
id<MTLBuffer>high=[self encodeLookPreview:texture inputLUT:nil strength:0 size:highSize standard:NO origin:origin entry:entry commands:cb];
|
||||
[cb commit];[cb waitUntilCompleted];
|
||||
if(cb.status==MTLCommandBufferStatusCompleted){@synchronized(_previewLock){[_preview release];_preview=[[NSData alloc]initWithBytes:b.contents length:b.length];[_lookLUTPreview release];if(origin==kFxImageOrigin_BOTTOM_LEFT){NSMutableData *flipped=[NSMutableData dataWithLength:b.length];for(NSUInteger y=0;y<180;y++)memcpy((uint8_t*)flipped.mutableBytes+y*320*16,(uint8_t*)b.contents+(179-y)*320*16,320*16);_lookLUTPreview=[flipped copy];}else _lookLUTPreview=[_preview retain];[self replaceLookHDBuffer:lookHD];_lastPreview=CACurrentMediaTime();}dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:@"DYPreviewDidChange" object:self];});}[b release];
|
||||
if(cb.status==MTLCommandBufferStatusCompleted)[self publishPreview:b standard:standard size:size high:high highSize:highSize origin:origin];
|
||||
}
|
||||
// Included in DYRenderer. V1 callers and their ABI remain on renderSource:...tools:error:.
|
||||
- (NSDictionary*)colorContext {@synchronized(_previewLock){return [[_colorContext copy]autorelease];}}
|
||||
@@ -142,7 +146,7 @@
|
||||
NSDictionary *finishPaths=DYVisibleBaseToolPaths(paths,finishing);
|
||||
NSArray *activeFinish=DYManagedActiveFinishing(u,finishPaths,spider,finishing);
|
||||
if(((mode!=1&&(output==6||output==7))||(mode==1&&primaries==kFxColorPrimaries_Rec2020))&&activeFinish.count)return fail(error,@"HDR 输出或跟随 Rec.2020 宿主时,目前支持一级调色与印片。请关闭 SDR 修饰工具;需要这些工具时,请明确选择 SDR 输出。");
|
||||
[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
[self managedPreview:current source:src entry:entry];
|
||||
if(activeFinish.count){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配显示域修饰缓冲区。");_managedFinishing=YES;BOOL ok=NO;@try{ok=[self renderSource:tile(current) destination:tile(out) uniforms:u paths:finishPaths spider:spider tools:finishing error:error];}@finally{_managedFinishing=NO;}if(!ok)return NO;current=out;}
|
||||
DYColorProfile*returnProfile=[[[DYColorProfile alloc]initWithSource:linear709 target:dstSpace error:error]autorelease];if(!profile(returnProfile))return NO;
|
||||
_managedFinishing=YES;@try{return [self copyTile:tile(current) to:dst entry:entry error:error];}@finally{_managedFinishing=NO;}
|
||||
|
||||
+2
-4
@@ -24,10 +24,8 @@
|
||||
- (NSData*)outputSpiderScope;
|
||||
/// Exact-time final output for the OSC, cached per sample.
|
||||
- (NSData*)canvasSpiderScopeAtTime:(CMTime)time;
|
||||
/// Display-encoded float RGBA, 320×180, with the visually top row first.
|
||||
/// Analysis preview retains the host texture's original row order separately.
|
||||
- (NSData*)lookLUTPreview;
|
||||
/// Standard and HD samples from the same capture, under one lock.
|
||||
/// Display-encoded float RGBA ("standard", "high") and matching NSSize values
|
||||
/// ("standardSize", "highSize") from one capture, with the visual top row first.
|
||||
- (NSDictionary*)lookLUTPreviewFrames;
|
||||
- (void)invalidatePreview;
|
||||
/// Conversion/statistics run while visible; retain one small final-output
|
||||
|
||||
+57
-42
@@ -140,7 +140,9 @@ struct DYScopeReadback {
|
||||
dispatch_queue_t _lutPreparationQueue;
|
||||
DYColorTables *_tables;
|
||||
NSObject *_previewLock;
|
||||
NSData *_preview,*_lookLUTPreview,*_lookLUTPreviewHD;
|
||||
NSData *_preview;
|
||||
NSDictionary *_lookLUTPreviewFrames;
|
||||
NSSize _lastLookPreviewSize;
|
||||
CFTimeInterval _lastPreview;
|
||||
BOOL _exporting;
|
||||
NSDictionary *_toolDocument,*_colorContext,*_exportManagedState;
|
||||
@@ -184,39 +186,64 @@ struct DYScopeReadback {
|
||||
#include "DYPrimaryRender.inc.h"
|
||||
#include "DYUnifiedRender.inc.h"
|
||||
#include "DYMosaicRender.inc.h"
|
||||
// HD is rendered alongside the existing throttled source sample. Its
|
||||
// immutable shared buffer stays available when the playhead is paused.
|
||||
- (id<MTLBuffer>)encodeLookHD:(id<MTLTexture>)texture inputLUT:(id<MTLTexture>)lut strength:(float)strength
|
||||
origin:(FxImageOrigin)origin entry:(NSMutableDictionary*)entry commands:(id<MTLCommandBuffer>)commands {
|
||||
NSString *name=lut?@"dyInputHighPreview":@"dyManagedHighPreview";
|
||||
// Use the display shape of the full source texture supplied by FxPlug.
|
||||
static NSSize DYLookSampleSize(id<MTLTexture> texture, double pixelAspect, NSUInteger edge) {
|
||||
if(!std::isfinite(pixelAspect)||pixelAspect<=0)pixelAspect=1;
|
||||
double aspect=double(texture.width)/texture.height*pixelAspect;
|
||||
return NSMakeSize(MAX(1,round(edge*fmin(1,aspect))),MAX(1,round(edge*fmin(1,1/aspect))));
|
||||
}
|
||||
- (id<MTLBuffer>)encodeLookPreview:(id<MTLTexture>)texture inputLUT:(id<MTLTexture>)lut strength:(float)strength
|
||||
size:(NSSize)size standard:(BOOL)standard origin:(FxImageOrigin)origin
|
||||
entry:(NSMutableDictionary*)entry commands:(id<MTLCommandBuffer>)commands {
|
||||
NSString *name=lut?@"dyInputLookPreview":@"dyManagedLookPreview";
|
||||
id<MTLComputePipelineState> pipeline=[self computePipeline:name entry:entry error:nil];
|
||||
if(!pipeline)return nil;
|
||||
id<MTLBuffer> buffer=[[entry[@"device"] newBufferWithLength:DYLookPreviewHDWidth*DYLookPreviewHDHeight*16 options:MTLResourceStorageModeShared]autorelease];
|
||||
NSUInteger width=size.width,height=size.height;
|
||||
id<MTLBuffer> buffer=[[entry[@"device"] newBufferWithLength:width*height*16 options:MTLResourceStorageModeShared]autorelease];
|
||||
id<MTLComputeCommandEncoder> encoder=buffer?[commands computeCommandEncoder]:nil;
|
||||
if(!encoder)return nil;
|
||||
[encoder setComputePipelineState:pipeline];[encoder setTexture:texture atIndex:0];
|
||||
[encoder setBuffer:buffer offset:0 atIndex:0];
|
||||
if(lut){[encoder setTexture:lut atIndex:1];[encoder setBytes:&strength length:sizeof(strength) atIndex:1];}
|
||||
uint32_t flip=origin==kFxImageOrigin_BOTTOM_LEFT;
|
||||
[encoder setBytes:&flip length:sizeof(flip) atIndex:2];
|
||||
[encoder dispatchThreads:MTLSizeMake(DYLookPreviewHDWidth,DYLookPreviewHDHeight,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];
|
||||
vector_uint4 geometry={(uint32_t)width,(uint32_t)height,origin==kFxImageOrigin_BOTTOM_LEFT,(uint32_t)standard};
|
||||
[encoder setBytes:&geometry length:sizeof(geometry) atIndex:2];
|
||||
[encoder dispatchThreads:MTLSizeMake(width,height,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];
|
||||
[encoder endEncoding];
|
||||
return buffer;
|
||||
}
|
||||
- (void)replaceLookHDBuffer:(id<MTLBuffer>)buffer {
|
||||
[_lookLUTPreviewHD release];_lookLUTPreviewHD=nil;
|
||||
if(!buffer)return;
|
||||
// Each capture owns a different buffer. NSData retains this one until the
|
||||
// browser's asynchronous image work has finished reading it.
|
||||
static NSData *DYLookBufferData(id<MTLBuffer> buffer) {
|
||||
if(!buffer)return nil;
|
||||
// The asynchronous browser can keep a capture alive across later renders.
|
||||
[buffer retain];
|
||||
_lookLUTPreviewHD=[[NSData alloc]initWithBytesNoCopy:buffer.contents length:buffer.length
|
||||
deallocator:^(void *bytes,NSUInteger length){[buffer release];}];
|
||||
return [[[NSData alloc]initWithBytesNoCopy:buffer.contents length:buffer.length
|
||||
deallocator:^(void *bytes,NSUInteger length){[buffer release];}]autorelease];
|
||||
}
|
||||
- (void)publishPreview:(id<MTLBuffer>)analysis standard:(id<MTLBuffer>)standard size:(NSSize)size
|
||||
high:(id<MTLBuffer>)high highSize:(NSSize)highSize origin:(FxImageOrigin)origin {
|
||||
@synchronized(_previewLock){
|
||||
[_preview release];_preview=[[NSData alloc]initWithBytes:analysis.contents length:analysis.length];
|
||||
NSData *look=DYLookBufferData(standard);
|
||||
if(NSEqualSizes(size,NSMakeSize(320,180))){
|
||||
look=_preview;
|
||||
if(origin==kFxImageOrigin_BOTTOM_LEFT){
|
||||
NSUInteger rowBytes=320*16;NSMutableData *flipped=[NSMutableData dataWithLength:_preview.length];
|
||||
for(NSUInteger y=0;y<180;y++)memcpy((uint8_t*)flipped.mutableBytes+y*rowBytes,(const uint8_t*)_preview.bytes+(179-y)*rowBytes,rowBytes);
|
||||
look=flipped;
|
||||
}
|
||||
}
|
||||
NSMutableDictionary *frames=[NSMutableDictionary dictionary];
|
||||
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];
|
||||
_lastLookPreviewSize=size;_lastPreview=CACurrentMediaTime();
|
||||
}
|
||||
[self notifyPreviewChanged];
|
||||
}
|
||||
#include "DYManagedRender.inc.h"
|
||||
#include "DYFaceRender.inc.h"
|
||||
#include "DYToolRender.inc.h"
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_scopeProfileLock=[NSObject new];_scopeQueue=dispatch_queue_create("com.dayu.color.final-output-scopes",DISPATCH_QUEUE_SERIAL);_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_mosaicRaster release];[_mosaicEntries release];[_mosaicFaceSnapshot release];[_faceEntries release];[_faceInput release];[_faceCachedEntries release];[_faceContext release];[_scopePending release];[_scopeLatest release];[_spiderScopeRaster release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];[_scopeProfileLock release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreview release];[_lookLUTPreviewHD release];[_colorContext release];[_previewLock release];[super dealloc];}
|
||||
- (void)dealloc{[_mosaicRaster release];[_mosaicEntries release];[_mosaicFaceSnapshot release];[_faceEntries release];[_faceInput release];[_faceCachedEntries release];[_faceContext release];[_scopePending release];[_scopeLatest release];[_spiderScopeRaster release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];[_scopeProfileLock release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreviewFrames release];[_colorContext release];[_previewLock release];[super dealloc];}
|
||||
- (void)trimPreparedLUTsKeeping:(NSString *)path {
|
||||
if(_preparedLUTs.count<=12)return;
|
||||
for(NSString *key in _preparedLUTs.allKeys)if(![_activeLUTPaths containsObject:key]&&![key isEqualToString:path])[_preparedLUTs removeObjectForKey:key];
|
||||
@@ -240,14 +267,9 @@ struct DYScopeReadback {
|
||||
}});return progress;
|
||||
}
|
||||
- (void)notifyPreviewChanged{dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:@"DYPreviewDidChange" object:self];});}
|
||||
- (void)invalidatePreview{@synchronized(_previewLock){[_preview release];_preview=nil;[_lookLUTPreview release];_lookLUTPreview=nil;[_lookLUTPreviewHD release];_lookLUTPreviewHD=nil;_lastPreview=0;}dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:@"DYPreviewDidChange" object:self];});}
|
||||
- (void)invalidatePreview{@synchronized(_previewLock){[_preview release];_preview=nil;[_lookLUTPreviewFrames release];_lookLUTPreviewFrames=nil;_lastPreview=0;}[self notifyPreviewChanged];}
|
||||
- (NSData*)preview{@synchronized(_previewLock){return [[_preview retain]autorelease];}}
|
||||
- (NSData*)lookLUTPreview{@synchronized(_previewLock){return [[_lookLUTPreview retain]autorelease];}}
|
||||
- (NSDictionary*)lookLUTPreviewFrames {@synchronized(_previewLock){
|
||||
NSMutableDictionary *frames=[NSMutableDictionary dictionary];
|
||||
frames[@"standard"]=_lookLUTPreview;frames[@"high"]=_lookLUTPreviewHD;
|
||||
return frames;
|
||||
}}
|
||||
- (NSDictionary*)lookLUTPreviewFrames {@synchronized(_previewLock){return [[_lookLUTPreviewFrames retain]autorelease];}}
|
||||
- (NSMutableDictionary*)device:(uint64_t)registry error:(NSError**)err{
|
||||
NSNumber*k=@(registry);NSMutableDictionary*entry=_devices[k];if(entry)return entry;
|
||||
uint64_t beta=DYBetaSpanBegin(@"device_prepare",nil);@try{
|
||||
@@ -318,8 +340,9 @@ struct DYScopeReadback {
|
||||
}
|
||||
BOOL faceOnly=u.skinProtection.x>.5&&(u.skinProtection.y>0||u.skinVisualize>.5)&&u.skinFaceOnly>.5;
|
||||
DYToolMaskHeader maskHeader{};id<MTLBuffer>maskBuffer=(masks.count||segmented||faceOnly||_faceEntries.length)?[self maskBuffer:masks tile:src device:d header:&maskHeader]:nil;maskHeader.faceOnly=faceOnly;BOOL hasMasks=maskHeader.count>0||maskHeader.faceOnly;if((hasMasks||segmented)&&!maskBuffer)return fail(err,@"无法分配蒙版缓冲区");
|
||||
NSSize lookSize=DYLookSampleSize(input,src.pixelAspect,DYLookPreviewStandardEdge);
|
||||
BOOL preview=NO;
|
||||
@synchronized(_previewLock){preview=(!segmented||stageFirst==0)&&!_exporting&&CACurrentMediaTime()-_lastPreview>.5;}
|
||||
@synchronized(_previewLock){preview=(!segmented||stageFirst==0)&&!_exporting&&(!NSEqualSizes(lookSize,_lastLookPreviewSize)||CACurrentMediaTime()-_lastPreview>.5);}
|
||||
BOOL neutral=!segmented&&!hasMasks&&!spiderBuffer&&u.skinVisualize<.5&&!hasLegacyGrade(u);
|
||||
FxRect s=src.tilePixelBounds,t=dst.tilePixelBounds;
|
||||
BOOL sameGrid=input.width==output.width&&input.height==output.height&&s.left==t.left&&s.right==t.right&&s.top==t.top&&s.bottom==t.bottom;
|
||||
@@ -391,7 +414,8 @@ struct DYScopeReadback {
|
||||
[ce dispatchThreadgroups:MTLSizeMake(1,1,1) threadsPerThreadgroup:MTLSizeMake(256,1,1)];[ce endEncoding];
|
||||
}
|
||||
}
|
||||
id<MTLBuffer> pb=nil,lookHD=nil;
|
||||
id<MTLBuffer> pb=nil,lookStandard=nil,lookHigh=nil;
|
||||
NSSize highSize=NSZeroSize;
|
||||
if(preview){
|
||||
id<MTLComputePipelineState> analysis=[self computePipeline:@"dyInputAnalysis" entry:e error:err];if(!analysis)return NO;
|
||||
pb=[[d newBufferWithLength:320*180*16 options:MTLResourceStorageModeShared]autorelease];
|
||||
@@ -401,8 +425,11 @@ struct DYScopeReadback {
|
||||
float inputStrength=u.inputSectionEnabled>.5?u.preLUTStrength:0;
|
||||
[ce setBytes:&inputStrength length:4 atIndex:1];[ce setBuffer:pb offset:0 atIndex:0];
|
||||
[ce dispatchThreads:MTLSizeMake(320,180,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];[ce endEncoding];
|
||||
lookHD=[self encodeLookHD:straight inputLUT:neutral?e[@"identity"]:ts[0] strength:inputStrength
|
||||
origin:src.imageOrigin entry:e commands:cb];
|
||||
id<MTLTexture> inputLUT=neutral?e[@"identity"]:ts[0];
|
||||
if(!NSEqualSizes(lookSize,NSMakeSize(320,180)))
|
||||
lookStandard=[self encodeLookPreview:straight inputLUT:inputLUT strength:inputStrength size:lookSize standard:YES origin:src.imageOrigin entry:e commands:cb];
|
||||
highSize=DYLookSampleSize(input,src.pixelAspect,DYLookPreviewHighEdge);
|
||||
lookHigh=[self encodeLookPreview:straight inputLUT:inputLUT strength:inputStrength size:highSize standard:NO origin:src.imageOrigin entry:e commands:cb];
|
||||
}
|
||||
MTLRenderPassDescriptor*rp=[MTLRenderPassDescriptor renderPassDescriptor];rp.colorAttachments[0].texture=output;rp.colorAttachments[0].loadAction=MTLLoadActionDontCare;rp.colorAttachments[0].storeAction=MTLStoreActionStore;id<MTLRenderCommandEncoder>re=[cb renderCommandEncoderWithDescriptor:rp];[re setRenderPipelineState:pipeline];
|
||||
float w=output.width,h=output.height;float sw=s.right-s.left,sh=s.top-s.bottom;float l=(t.left-s.left)/sw,r=(t.right-s.left)/sw,top=(s.top-t.top)/sh,bottom=(s.top-t.bottom)/sh;
|
||||
@@ -410,19 +437,7 @@ struct DYScopeReadback {
|
||||
DYVertex2D vs[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};
|
||||
if(dst.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(int i=0;i<4;i++)vs[i].position.y=-vs[i].position.y;
|
||||
vector_uint2 vp={(unsigned)output.width,(unsigned)output.height};[re setVertexBytes:vs length:sizeof(vs) atIndex:0];[re setVertexBytes:&vp length:sizeof(vp) atIndex:1];[re setViewport:(MTLViewport){0,0,w,h,0,1}];[re setFragmentTexture:straight atIndex:0];if(!neutral){for(NSUInteger i=0;i<ts.count;i++)[re setFragmentTexture:ts[i] atIndex:i+1];[re setFragmentBytes:&u length:sizeof(u) atIndex:0];[re setFragmentBuffer:scene offset:0 atIndex:1];DYRenderOptions options={1,bwMix,0,0};[re setFragmentBytes:&options length:sizeof(options) atIndex:2];DYUniforms color=u;color.blackWhiteSectionEnabled=0;[re setFragmentBytes:&color length:sizeof(color) atIndex:3];if(spiderBuffer)[re setFragmentBuffer:spiderBuffer offset:0 atIndex:4];else{float empty[2]={0,0};[re setFragmentBytes:empty length:sizeof(empty) atIndex:4];}[re setFragmentBytes:&spiderSize length:sizeof(spiderSize) atIndex:5];if(hasMasks||segmented){[re setFragmentBuffer:maskBuffer offset:0 atIndex:6];[re setFragmentBytes:&maskHeader length:sizeof(maskHeader) atIndex:7];}if(segmented){DYToolStageRange range={(int)stageFirst,(int)stageLast,(int)suppressBlackWhite};[re setFragmentBytes:&range length:sizeof(range) atIndex:8];[re setFragmentTexture:skinReference?[skinReference metalTextureForDevice:d]:input atIndex:10];[re setFragmentTexture:nativeSource atIndex:11];}}[re drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];[re endEncoding];BOOL ok=[self completeCommands:cb destination:dst texture:output entry:e];
|
||||
if(ok&&pb){@synchronized(_previewLock){
|
||||
[_preview release];_preview=[[NSData alloc]initWithBytes:pb.contents length:320*180*16];
|
||||
// The analysis kernel reads physical texture rows. Its result remains intact
|
||||
// for auto grade; only the browser copy is normalized to top-first bitmap rows.
|
||||
[_lookLUTPreview release];
|
||||
if(src.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){
|
||||
const NSUInteger rowBytes=320*16;NSMutableData*topFirst=[NSMutableData dataWithLength:_preview.length];
|
||||
for(NSUInteger y=0;y<180;y++)memcpy((uint8_t*)topFirst.mutableBytes+y*rowBytes,(const uint8_t*)_preview.bytes+(179-y)*rowBytes,rowBytes);
|
||||
_lookLUTPreview=[topFirst copy];
|
||||
}else _lookLUTPreview=[_preview retain];
|
||||
[self replaceLookHDBuffer:lookHD];
|
||||
_lastPreview=CACurrentMediaTime();[self notifyPreviewChanged];
|
||||
}}
|
||||
if(ok&&pb)[self publishPreview:pb standard:lookStandard size:lookSize high:lookHigh highSize:highSize origin:src.imageOrigin];
|
||||
if(!ok)fail(err,cb.error.localizedDescription);return ok;
|
||||
});}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{return [self exportLUT:url uniforms:u paths:paths spider:nil error:err];}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
// the exact current code domain after the same ordered operations.
|
||||
if(_exporting){if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}
|
||||
else {
|
||||
if(!transform({wg,wt,22,20,0}))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
if(!transform({wg,wt,22,20,0}))return NO;[self managedPreview:current source:src entry:entry];
|
||||
CGColorSpaceRef from=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB),to=DYManagedTileSpace(dst,primaries);
|
||||
DYColorProfile *profile=to?[[[DYColorProfile alloc]initWithSource:from target:to error:error]autorelease]:nil;CGColorSpaceRelease(from);if(to)CGColorSpaceRelease(to);
|
||||
if(!profile)return fail(error,@"宿主未提供明确的目标颜色空间。");id<MTLTexture>out=next();if(!out||![self managedProfile:profile input:current output:out entry:entry error:error])return NO;current=out;
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.4</string>
|
||||
<string>1.21.5</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>121</string>
|
||||
<string>122</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.4</string>
|
||||
<string>1.21.5</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>121</string>
|
||||
<string>122</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
更新于 2026-11-08(Asia/Shanghai)。这是新对话的接手入口。历史设计和实现细节按需查阅专项交接,复现和交付证据以对应版本的报告为准。
|
||||
|
||||
## 1.21.5(122)LUT 帧比例与浏览顺序
|
||||
|
||||
2026-11-08。浏览器的标准与高清预览按宿主帧和像素宽高比取样,最长边分别为 320 与 640。网格、列表与划像使用带尺寸的同帧数据,完整显示画面。自动调色继续使用原 320×180 分析样本。完整浏览器打开时读取最近使用顺序,成功应用时保存历史并更新选中项,重开时按最新历史排序。已加入帧比例、像素行顺序和浏览会话排序回归检查。
|
||||
|
||||
当前为源码检查点。下一步是 Release 构建、签名、公证、正式安装与 FCP 验收,再验包并核验 Release 下载。
|
||||
|
||||
## 1.21.4(121)曲线直方图 Rec.709 电平
|
||||
|
||||
用户在 FCP 的 Rec.709 项目对照同帧 S-Log3 灰片,发现曲线背景分布偏左。本机正式 1.21.3 在同一工程的 00:00:02:24 复现。曲线背景曾直接分箱线性 RGB,约 50% 的 Rec.709 视频电平在线性域约为 0.26,旧图约 66/255。改为对已识别的线性 Rec.709 输出解除透明度预乘、逐通道进行 BT.709 编码再分箱。检查器和画布共用这份结果。其他色彩空间沿用原统计,亮度叠层、320×180 采样及 0–255 坐标保留。[统计入口](大鱼调色/Plugin/DYScopeSample.mm#L10) · [FxPlug 色彩空间](https://developer.apple.com/documentation/professional-video-applications/managing-color-space-and-gamut-in-plug-ins)
|
||||
|
||||
在新工单中引用
屏蔽一个用户