static nsresult GetDeviceHeight(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { nsSize size = GetDeviceSize(aPresContext); float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height); aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel); return NS_OK; }
BOOL CWinPrint::StartPage() { // Get print dc HDC hDc = GetPrintHdc(); if ( !hDc ) return FALSE; // Start the print job m_nPageId = ::StartPage( hDc ); if ( 0 >= m_nPageId ) return FALSE; // Update device size GetDeviceSize(); return TRUE; }
static nsresult GetDeviceOrientation(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { nsSize size = GetDeviceSize(aPresContext); PRInt32 orientation; if (size.width > size.height) { orientation = NS_STYLE_ORIENTATION_LANDSCAPE; } else { // Per spec, square viewports should be 'portrait' orientation = NS_STYLE_ORIENTATION_PORTRAIT; } aResult.SetIntValue(orientation, eCSSUnit_Enumerated); return NS_OK; }
HostDeviceList CoreFreeBSD::GetHostDevices (bool pathListOnly) const { HostDeviceList devices; #ifdef TC_MACOSX const string busType = "rdisk"; #else foreach (const string &busType, StringConverter::Split ("ad da")) #endif { for (int devNumber = 0; devNumber < 64; devNumber++) { stringstream devPath; devPath << "/dev/" << busType << devNumber; if (FilesystemPath (devPath.str()).IsBlockDevice() || FilesystemPath (devPath.str()).IsCharacterDevice()) { make_shared_auto (HostDevice, device); device->Path = devPath.str(); if (!pathListOnly) { try { device->Size = GetDeviceSize (device->Path); } catch (...) { device->Size = 0; } device->MountPoint = GetDeviceMountPoint (device->Path); device->SystemNumber = 0; } devices.push_back (device); for (int partNumber = 1; partNumber < 32; partNumber++) { #ifdef TC_MACOSX const string partLetter = ""; #else foreach (const string &partLetter, StringConverter::Split (",a,b,c,d,e,f,g,h", ",", true)) #endif { stringstream partPath; partPath << devPath.str() << "s" << partNumber << partLetter; if (FilesystemPath (partPath.str()).IsBlockDevice() || FilesystemPath (partPath.str()).IsCharacterDevice()) { make_shared_auto (HostDevice, partition); partition->Path = partPath.str(); if (!pathListOnly) { try { partition->Size = GetDeviceSize (partition->Path); } catch (...) { partition->Size = 0; } partition->MountPoint = GetDeviceMountPoint (partition->Path); partition->SystemNumber = 0; } device->Partitions.push_back (partition); } } } } } }
void GSRendererSW::VSync(int field) { Sync(0); // IncAge might delete a cached texture in use if(0) if(LOG) { fprintf(s_fp, "%lld\n", m_perfmon.GetFrame()); GSVector4i dr = GetDisplayRect(); GSVector4i fr = GetFrameRect(); GSVector2i ds = GetDeviceSize(); fprintf(s_fp, "dr %d %d %d %d, fr %d %d %d %d, ds %d %d\n", dr.x, dr.y, dr.z, dr.w, fr.x, fr.y, fr.z, fr.w, ds.x, ds.y); for(int i = 0; i < 2; i++) { if(i == 0 && !m_regs->PMODE.EN1) continue; if(i == 1 && !m_regs->PMODE.EN2) continue; fprintf(s_fp, "DISPFB[%d] BP=%05x BW=%d PSM=%d DBX=%d DBY=%d\n", i, m_regs->DISP[i].DISPFB.Block(), m_regs->DISP[i].DISPFB.FBW, m_regs->DISP[i].DISPFB.PSM, m_regs->DISP[i].DISPFB.DBX, m_regs->DISP[i].DISPFB.DBY ); fprintf(s_fp, "DISPLAY[%d] DX=%d DY=%d DW=%d DH=%d MAGH=%d MAGV=%d\n", i, m_regs->DISP[i].DISPLAY.DX, m_regs->DISP[i].DISPLAY.DY, m_regs->DISP[i].DISPLAY.DW, m_regs->DISP[i].DISPLAY.DH, m_regs->DISP[i].DISPLAY.MAGH, m_regs->DISP[i].DISPLAY.MAGV ); } fprintf(s_fp, "PMODE EN1=%d EN2=%d CRTMD=%d MMOD=%d AMOD=%d SLBG=%d ALP=%d\n", m_regs->PMODE.EN1, m_regs->PMODE.EN2, m_regs->PMODE.CRTMD, m_regs->PMODE.MMOD, m_regs->PMODE.AMOD, m_regs->PMODE.SLBG, m_regs->PMODE.ALP ); fprintf(s_fp, "SMODE1 CLKSEL=%d CMOD=%d EX=%d GCONT=%d LC=%d NVCK=%d PCK2=%d PEHS=%d PEVS=%d PHS=%d PRST=%d PVS=%d RC=%d SINT=%d SLCK=%d SLCK2=%d SPML=%d T1248=%d VCKSEL=%d VHP=%d XPCK=%d\n", m_regs->SMODE1.CLKSEL, m_regs->SMODE1.CMOD, m_regs->SMODE1.EX, m_regs->SMODE1.GCONT, m_regs->SMODE1.LC, m_regs->SMODE1.NVCK, m_regs->SMODE1.PCK2, m_regs->SMODE1.PEHS, m_regs->SMODE1.PEVS, m_regs->SMODE1.PHS, m_regs->SMODE1.PRST, m_regs->SMODE1.PVS, m_regs->SMODE1.RC, m_regs->SMODE1.SINT, m_regs->SMODE1.SLCK, m_regs->SMODE1.SLCK2, m_regs->SMODE1.SPML, m_regs->SMODE1.T1248, m_regs->SMODE1.VCKSEL, m_regs->SMODE1.VHP, m_regs->SMODE1.XPCK ); fprintf(s_fp, "SMODE2 INT=%d FFMD=%d DPMS=%d\n", m_regs->SMODE2.INT, m_regs->SMODE2.FFMD, m_regs->SMODE2.DPMS ); fprintf(s_fp, "SRFSH %08x_%08x\n", m_regs->SRFSH.u32[0], m_regs->SRFSH.u32[1] ); fprintf(s_fp, "SYNCH1 %08x_%08x\n", m_regs->SYNCH1.u32[0], m_regs->SYNCH1.u32[1] ); fprintf(s_fp, "SYNCH2 %08x_%08x\n", m_regs->SYNCH2.u32[0], m_regs->SYNCH2.u32[1] ); fprintf(s_fp, "SYNCV %08x_%08x\n", m_regs->SYNCV.u32[0], m_regs->SYNCV.u32[1] ); fprintf(s_fp, "CSR %08x_%08x\n", m_regs->CSR.u32[0], m_regs->CSR.u32[1] ); fflush(s_fp); } /* int draw[8], sum = 0; for(size_t i = 0; i < countof(draw); i++) { draw[i] = m_perfmon.CPU(GSPerfMon::WorkerDraw0 + i); sum += draw[i]; } printf("CPU %d Sync %d W %d %d %d %d %d %d %d %d (%d)\n", m_perfmon.CPU(GSPerfMon::Main), m_perfmon.CPU(GSPerfMon::Sync), draw[0], draw[1], draw[2], draw[3], draw[4], draw[5], draw[6], draw[7], sum); // */ GSRenderer::VSync(field); m_tc->IncAge(); // if((m_perfmon.GetFrame() & 255) == 0) m_rl->PrintStats(); }
HostDeviceList CoreSolaris::GetHostDevices (bool pathListOnly) const { HostDeviceList devices; foreach_ref (const FilePath &devPath, Directory::GetFilePaths ("/dev/rdsk", false)) { string drivePath = devPath; if (drivePath.rfind ("p0") == drivePath.size() - 2) { make_shared_auto (HostDevice, device); device->Path = drivePath; try { device->Size = GetDeviceSize (device->Path); } catch (...) { device->Size = 0; } if (device->Size == 0) continue; device->MountPoint = GetDeviceMountPoint (device->Path); device->SystemNumber = 0; devices.push_back (device); for (int partNumber = 1; partNumber <= 32; partNumber++) { stringstream partPath; partPath << drivePath.substr (0, drivePath.size() - 1) << partNumber; if (FilesystemPath (partPath.str()).IsBlockDevice() || FilesystemPath (partPath.str()).IsCharacterDevice()) { make_shared_auto (HostDevice, partition); partition->Path = partPath.str(); try { partition->Size = GetDeviceSize (partition->Path); } catch (...) { partition->Size = 0; } if (partition->Size == 0) continue; partition->MountPoint = GetDeviceMountPoint (partition->Path); partition->SystemNumber = 0; device->Partitions.push_back (partition); } } } } return devices; }
bool GSRenderer::Merge(int field) { bool en[2]; GSVector4i fr[2]; GSVector4i dr[2]; int baseline = INT_MAX; for(int i = 0; i < 2; i++) { en[i] = IsEnabled(i); if(en[i]) { fr[i] = GetFrameRect(i); dr[i] = GetDisplayRect(i); baseline = min(dr[i].top, baseline); //printf("[%d]: %d %d %d %d, %d %d %d %d\n", i, fr[i].x,fr[i].y,fr[i].z,fr[i].w , dr[i].x,dr[i].y,dr[i].z,dr[i].w); } } if(!en[0] && !en[1]) { return false; } // try to avoid fullscreen blur, could be nice on tv but on a monitor it's like double vision, hurts my eyes (persona 4, guitar hero) // // NOTE: probably the technique explained in graphtip.pdf (Antialiasing by Supersampling / 4. Reading Odd/Even Scan Lines Separately with the PCRTC then Blending) bool samesrc = en[0] && en[1] && m_regs->DISP[0].DISPFB.FBP == m_regs->DISP[1].DISPFB.FBP && m_regs->DISP[0].DISPFB.FBW == m_regs->DISP[1].DISPFB.FBW && m_regs->DISP[0].DISPFB.PSM == m_regs->DISP[1].DISPFB.PSM; // bool blurdetected = false; if(samesrc /*&& m_regs->PMODE.SLBG == 0 && m_regs->PMODE.MMOD == 1 && m_regs->PMODE.ALP == 0x80*/) { if(fr[0].eq(fr[1] + GSVector4i(0, -1, 0, 0)) && dr[0].eq(dr[1] + GSVector4i(0, 0, 0, 1)) || fr[1].eq(fr[0] + GSVector4i(0, -1, 0, 0)) && dr[1].eq(dr[0] + GSVector4i(0, 0, 0, 1))) { // persona 4: // // fr[0] = 0 0 640 448 // fr[1] = 0 1 640 448 // dr[0] = 159 50 779 498 // dr[1] = 159 50 779 497 // // second image shifted up by 1 pixel and blended over itself // // god of war: // // fr[0] = 0 1 512 448 // fr[1] = 0 0 512 448 // dr[0] = 127 50 639 497 // dr[1] = 127 50 639 498 // // same just the first image shifted int top = min(fr[0].top, fr[1].top); int bottom = max(dr[0].bottom, dr[1].bottom); fr[0].top = top; fr[1].top = top; dr[0].bottom = bottom; dr[1].bottom = bottom; // blurdetected = true; } else if(dr[0].eq(dr[1]) && (fr[0].eq(fr[1] + GSVector4i(0, 1, 0, 1)) || fr[1].eq(fr[0] + GSVector4i(0, 1, 0, 1)))) { // dq5: // // fr[0] = 0 1 512 445 // fr[1] = 0 0 512 444 // dr[0] = 127 50 639 494 // dr[1] = 127 50 639 494 int top = min(fr[0].top, fr[1].top); int bottom = min(fr[0].bottom, fr[1].bottom); fr[0].top = fr[1].top = top; fr[0].bottom = fr[1].bottom = bottom; // blurdetected = true; } //printf("samesrc = %d blurdetected = %d\n",samesrc,blurdetected); } GSVector2i fs(0, 0); GSVector2i ds(0, 0); GSTexture* tex[2] = {NULL, NULL}; if(samesrc && fr[0].bottom == fr[1].bottom) { tex[0] = GetOutput(0); tex[1] = tex[0]; // saves one texture fetch } else { if(en[0]) tex[0] = GetOutput(0); if(en[1]) tex[1] = GetOutput(1); } GSVector4 src[2]; GSVector4 dst[2]; for(int i = 0; i < 2; i++) { if(!en[i] || !tex[i]) continue; GSVector4i r = fr[i]; // overscan hack if(dr[i].height() > 512) // hmm { int y = GetDeviceSize(i).y; if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) y /= 2; r.bottom = r.top + y; } GSVector4 scale = GSVector4(tex[i]->GetScale()).xyxy(); src[i] = GSVector4(r) * scale / GSVector4(tex[i]->GetSize()).xyxy(); GSVector2 o(0, 0); if(dr[i].top - baseline >= 4) // 2? { o.y = tex[i]->GetScale().y * (dr[i].top - baseline); if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) { o.y /= 2; } } dst[i] = GSVector4(o).xyxy() + scale * GSVector4(r.rsize()); fs.x = max(fs.x, (int)(dst[i].z + 0.5f)); fs.y = max(fs.y, (int)(dst[i].w + 0.5f)); } ds = fs; if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) { ds.y *= 2; } bool slbg = m_regs->PMODE.SLBG; bool mmod = m_regs->PMODE.MMOD; if(tex[0] || tex[1]) { if(tex[0] == tex[1] && !slbg && (src[0] == src[1] & dst[0] == dst[1]).alltrue()) { // the two outputs are identical, skip drawing one of them (the one that is alpha blended) tex[0] = NULL; } GSVector4 c = GSVector4((int)m_regs->BGCOLOR.R, (int)m_regs->BGCOLOR.G, (int)m_regs->BGCOLOR.B, (int)m_regs->PMODE.ALP) / 255; m_dev->Merge(tex, src, dst, fs, slbg, mmod, c); if(m_regs->SMODE2.INT && m_interlace > 0) { if (m_interlace == 7 && m_regs->SMODE2.FFMD == 1) // Auto interlace enabled / Odd frame interlace setting { int field2 = 0; int mode = 2; m_dev->Interlace(ds, field ^ field2, mode, tex[1] ? tex[1]->GetScale().y : tex[0]->GetScale().y); } else { int field2 = 1 - ((m_interlace - 1) & 1); int mode = (m_interlace - 1) >> 1; m_dev->Interlace(ds, field ^ field2, mode, tex[1] ? tex[1]->GetScale().y : tex[0]->GetScale().y); } } if(m_shadeboost) { m_dev->ShadeBoost(); } if (m_shaderfx) { m_dev->ExternalFX(); } if(m_fxaa) { m_dev->FXAA(); } } return true; }
static nsresult GetDeviceAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { return MakeArray(GetDeviceSize(aPresContext), aResult); }