const char * MmapWrapperWriteAndReadMemoryAccess()
{
#if defined(TARGET_MAC)
    return reinterpret_cast<const char *> (mmap(0, GetPageSize(), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0));
#else
   return reinterpret_cast<const char *> (mmap(0, GetPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0));
#endif
}
void CRoundSliderCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	const int nMin = GetRangeMin();
	const int nMax = GetRangeMax()+1;

	switch(nChar)
	{
	case VK_LEFT:
	case VK_UP:
		{
			int nNewPos = GetPos()-GetLineSize();
			while(nNewPos < nMin) nNewPos += (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_LINEUP);
		}
		break;
	
	case VK_RIGHT:
	case VK_DOWN:
		{
			int nNewPos = GetPos()+GetLineSize();
			while(nNewPos >= nMax) nNewPos -= (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_LINEDOWN);
		}
		break;

	case VK_PRIOR:
		{
			int nNewPos = GetPos()-GetPageSize();
			while(nNewPos < nMin) nNewPos += (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_PAGEUP);
		}
		break;

	case VK_NEXT:
		{
			int nNewPos = GetPos()+GetPageSize();
			while(nNewPos >= nMax) nNewPos -= (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_PAGEDOWN);
		}
		break;

	case VK_HOME:
	case VK_END:
		// Do nothing (ignore keystroke)
		break;

	default:
		CSliderCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
	}
}
Beispiel #3
0
static int tsk_pagesize(RIOMach *riom) {
#define GetPageSize(x) (host_page_size (riom->task, x) == KERN_SUCCESS)
	static vm_size_t pagesize = 0;
	return pagesize ? pagesize
		: GetPageSize (&pagesize)
			? pagesize : 4096;
}
Beispiel #4
0
bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
{
    // solid background colour overrides themed background drawing
    if ( !UseBgCol() && DoDrawBackground(hDC, child) )
        return true;

    // If we're using a solid colour (for example if we've switched off
    // theming for this notebook), paint it
    if (UseBgCol())
    {
        wxRect r = GetPageSize();
        if ( r.IsEmpty() )
            return false;

        RECT rc;
        wxCopyRectToRECT(r, rc);

        // map rect to the coords of the window we're drawing in
        if ( child )
            ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);

        wxBrush brush(GetBackgroundColour());
        HBRUSH hbr = GetHbrushOf(brush);

        ::FillRect((HDC) hDC, &rc, hbr);

        return true;
    }

    return wxNotebookBase::MSWPrintChild(hDC, child);
}
Beispiel #5
0
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
{
    wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );

    TC_ITEM tcItem;
    tcItem.mask = TCIF_TEXT;
    tcItem.pszText = wxMSW_CONV_LPTSTR(strText);

    if ( !HasFlag(wxNB_MULTILINE) )
        return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;

    // multiline - we need to set new page size if a line is added or removed
    int rows = GetRowCount();
    bool ret = TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0;

    if ( ret && rows != GetRowCount() )
    {
        const wxRect r = GetPageSize();
        const size_t count = m_pages.Count();
        for ( size_t page = 0; page < count; page++ )
            m_pages[page]->SetSize(r);
    }

    return ret;
}
Beispiel #6
0
int main(int nargs, char **args)
{
   size_t pgsz;
   int MaxL1Size;
   int muladd, lat, lbnreg, L1Size, mmnreg, nkflop;
   FILE *fpout;
   char pre;

   if (nargs != 3)
   {
      fprintf(stderr, "USAGE: %s <pre> <file>\n", args[0]);
      exit(-1);
   }
   pre = *args[1];

   L1Size = 1024 * GetL1CacheSize(64);
   if (pre == 'd') L1Size /= ATL_dsize;
   else if (pre == 's') L1Size /= ATL_ssize;
   else if (pre == 'z') L1Size /= ATL_csize;
   else if (pre == 'c') L1Size /= ATL_zsize;
   getfpinfo(pre, &muladd, &lat, &lbnreg, &nkflop);
   pgsz = GetPageSize();
   CreateHeader(pre, args[2], L1Size, muladd, lat, lbnreg, nkflop, 0, pgsz);
   mmnreg = getmmnreg(pre);
   CreateHeader(pre, args[2], L1Size, muladd, lat, lbnreg, nkflop, mmnreg,pgsz);
   return(0);
}
Beispiel #7
0
int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
    TC_HITTESTINFO hitTestInfo;
    hitTestInfo.pt.x = pt.x;
    hitTestInfo.pt.y = pt.y;
    int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo);

    if ( flags )
    {
        *flags = 0;

        if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
            *flags |= wxBK_HITTEST_NOWHERE;
        if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM)
            *flags |= wxBK_HITTEST_ONITEM;
        if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
            *flags |= wxBK_HITTEST_ONICON;
        if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
            *flags |= wxBK_HITTEST_ONLABEL;
        if ( item == wxNOT_FOUND && GetPageSize().Contains(pt) )
            *flags |= wxBK_HITTEST_ONPAGE;
    }

    return item;
}
Beispiel #8
0
PR_IMPLEMENT(PRInt32) PR_GetPageSize(void)
{
    if (!_pr_pageSize) {
	GetPageSize();
    }
    return _pr_pageSize;
}
Beispiel #9
0
/*----------------------------------------------------------------------
 *       Class:  AmayaScrollBar
 *      Method:  OnScroll
 * Description:  
  -----------------------------------------------------------------------*/
void AmayaScrollBar::OnScroll( wxScrollEvent& event )
{
  /* this flag is necessary because 2 events occure when up/down button
     is pressed (it's an optimisation)
     this hack works because OnLineDown is called before OnScroll,
     but becareful the events orders could change in future wxWidgets
     releases or can be platform specific
  */
  if (m_IgnoreNextScrollEvent)
    {
      m_IgnoreNextScrollEvent = FALSE;
      event.Skip();
      return;
    }
  
  if (event.GetOrientation() == wxHORIZONTAL)
    {
      TTALOGDEBUG_3( TTA_LOG_DIALOG, _T("AmayaScrollBar::OnScroll [wxHORIZONTAL][frameid=%d][pos=%d][pagesize=%d]"), m_ParentFrameID, event.GetPosition(), GetPageSize() );
      FrameHScrolledCallback( m_ParentFrameID,
                              event.GetPosition(),
                              GetPageSize() );
    }
  else if (event.GetOrientation() == wxVERTICAL)
    {
      TTALOGDEBUG_3( TTA_LOG_DIALOG, _T("AmayaScrollBar::OnScroll [wxVERTICAL][frameid=%d][pos=%d][pagesize=%d]"), m_ParentFrameID, event.GetPosition(), GetPageSize() );
      FrameVScrolledCallback( m_ParentFrameID,
                              event.GetPosition() );
    }
}
Beispiel #10
0
WXHBRUSH wxNotebook::QueryBgBitmap()
{
    wxRect r = GetPageSize();
    if ( r.IsEmpty() )
        return 0;

    wxUxThemeHandle theme(this, L"TAB");
    if ( !theme )
        return 0;

    RECT rc;
    wxCopyRectToRECT(r, rc);

    WindowHDC hDC(GetHwnd());
    wxUxThemeEngine::Get()->GetThemeBackgroundExtent
                            (
                                theme,
                                (HDC) hDC,
                                9 /* TABP_PANE */,
                                0,
                                &rc,
                                &rc
                            );

    MemoryHDC hDCMem(hDC);
    CompatibleBitmap hBmp(hDC, rc.right, rc.bottom);

    SelectInHDC selectBmp(hDCMem, hBmp);

    if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) )
        return 0;

    return (WXHBRUSH)::CreatePatternBrush(hBmp);
}
Beispiel #11
0
void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt,
                                       const CFX_Rect& rtDisp,
                                       int32_t iRotate) const {
  CFX_SizeF sz = GetPageSize();
  CFX_RectF fdePage;
  fdePage.Set(0, 0, sz.x, sz.y);
  GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0);
}
Beispiel #12
0
/*!
 * Test the PIN_SafeCopy() function in the following scenarios:
 * A. Successful copy of an entire memory region
 * B. Partial copy of a memory region, whose tail is inaccessible
 * C. Failure to copy an inaccessible memory region
 */
VOID SafeCopyTest()
{
    size_t pageSize = GetPageSize();

    CHAR * src = (CHAR *)MemAlloc(2*pageSize);
    ASSERTX(src != 0);
    CHAR * srcBuf = src + 1; // +1 for testing unaligned access


    CHAR * dst = (CHAR *)MemAlloc(2*pageSize);
    ASSERTX(dst != 0);
    CHAR * dstBuf = dst + 1; // +1 for testing unaligned access

    size_t bufSize = 2*pageSize - 1;
    size_t halfBufSize = pageSize - 1;
    size_t copySize;

    //A.
    for (unsigned int i = 0; i < bufSize; ++i)
    {
        src[i] = i/256;
        dst[i] = 0;
    }
    copySize = PIN_SafeCopy(dstBuf, srcBuf, bufSize); 
    ASSERT(((copySize == bufSize) && (memcmp(dstBuf, srcBuf, bufSize) == 0)), "SafeCopy (A) failed.\n");
    out << "SafeCopy (A): Entire buffer has been copied successfully." << endl << flush;

    //B.
    for (unsigned int i = 0; i < pageSize; ++i)
    {
        dst[i] = 0;
    }
    MemProtect(src + pageSize, pageSize, FALSE); // second half of src is inaccessible
    copySize = PIN_SafeCopy(dstBuf, srcBuf, bufSize); 
    ASSERT(((copySize == halfBufSize) && (memcmp(dstBuf, srcBuf, halfBufSize) == 0)), "SafeCopy (B) failed.\n");

    // Check to see that all accessible bytes near the end of the first page are copied successfully
    for (unsigned int sz = 1; sz < 16; ++sz)
    {
        for (unsigned int i = 0; i < sz; ++i)
        {
            dstBuf[i] = 0;
        }
        copySize = PIN_SafeCopy(dstBuf, src + pageSize - sz, pageSize); 
        ASSERT(((copySize == sz) && (memcmp(dstBuf, src + pageSize - sz, sz) == 0)), "SafeCopy (B) failed.\n");
    }

    out << "SafeCopy (B): Accessible part of the buffer has been copied successfully."  << endl << flush;

    //C.
    MemProtect(dst, pageSize, FALSE); // dst is inaccessible
    copySize = PIN_SafeCopy(dstBuf, srcBuf, bufSize); 
    ASSERT((copySize == 0), "SafeCopy (C) failed.\n");
    out << "SafeCopy (C): Inaccessible buffer has not been copied."  << endl << flush;

    MemFree(src, 2*pageSize);
    MemFree(dst, 2*pageSize);
}
Beispiel #13
0
void wxNotebook::AdjustPageSize(wxNotebookPage *page)
{
    wxCHECK_RET( page, wxT("NULL page in wxNotebook::AdjustPageSize") );

    const wxRect r = GetPageSize();
    if ( !r.IsEmpty() )
    {
        page->SetSize(r);
    }
}
Beispiel #14
0
void ScrollBarHorizontal::SetPos(float pos)
{
	ScrollBarBase::SetPos(pos);

	float mult = GetShowButtons() ? 1.0f : 0.0f;
	_btnBox->Resize(std::max(GetScrollPaneLength() * GetPageSize() / GetDocumentSize(), _btnBox->GetTextureWidth()),
		_btnBox->GetHeight());
	_btnBox->Move(floorf(_btnUpLeft->GetWidth() * mult + (GetWidth() - _btnBox->GetWidth()
		- (_btnUpLeft->GetWidth() + _btnDownRight->GetWidth()) * mult) * GetPos() / (GetDocumentSize() - GetPageSize()) + 0.5f), _btnBox->GetY());
}
Beispiel #15
0
bool wxWizard::ResizeBitmap(wxBitmap& bmp)
{
    if (!GetBitmapPlacement())
        return false;

    if (bmp.Ok())
    {
        wxSize pageSize = m_sizerPage->GetSize();
        if (pageSize == wxSize(0,0))
            pageSize = GetPageSize();
        int bitmapWidth = wxMax(bmp.GetWidth(), GetMinimumBitmapWidth());
        int bitmapHeight = pageSize.y;

        if (!m_statbmp->GetBitmap().Ok() || m_statbmp->GetBitmap().GetHeight() != bitmapHeight)
        {
            wxBitmap bitmap(bitmapWidth, bitmapHeight);
            {
                wxMemoryDC dc;
                dc.SelectObject(bitmap);
                dc.SetBackground(wxBrush(m_bitmapBackgroundColour));
                dc.Clear();

                if (GetBitmapPlacement() & wxWIZARD_TILE)
                {
                    TileBitmap(wxRect(0, 0, bitmapWidth, bitmapHeight), dc, bmp);
                }
                else
                {
                    int x, y;

                    if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT)
                        x = 0;
                    else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT)
                        x = bitmapWidth - bmp.GetWidth();
                    else
                        x = (bitmapWidth - bmp.GetWidth())/2;

                    if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP)
                        y = 0;
                    else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM)
                        y = bitmapHeight - bmp.GetHeight();
                    else
                        y = (bitmapHeight - bmp.GetHeight())/2;

                    dc.DrawBitmap(bmp, x, y, true);
                    dc.SelectObject(wxNullBitmap);
                }
            }

            bmp = bitmap;
        }
    }

    return true;
}
/*!
 * The main procedure of the application.
 */
int main(int argc, char *argv[])
{
    cerr << "SMC in the image of the application" << endl;

    // buffer to move foo/bar routines into and execute
    static char staticBuffer[PI_FUNC::MAX_SIZE];
    // Set read-write-execute protection for the buffer 
    size_t pageSize = GetPageSize();
    char * firstPage = (char *)(((size_t)staticBuffer) & ~(pageSize - 1));
    char * endPage = (char *)(((size_t)staticBuffer + sizeof(staticBuffer) + pageSize - 1) & ~(pageSize - 1));
    if (!MemProtect(firstPage, endPage - firstPage, MEM_READ_WRITE_EXEC)) {Abort("MemProtect failed");}

    for (int i = 0; i < 3; ++i)
    {
        FOO_FUNC fooFunc;
        fooFunc.Copy(staticBuffer).Execute().AssertStatus();
        cerr << fooFunc.Name() << ": " << fooFunc.ErrorMessage() << endl;

        BAR_FUNC barFunc;
        barFunc.Copy(staticBuffer).Execute().AssertStatus();
        cerr << barFunc.Name() << ": " << barFunc.ErrorMessage() << endl;
    }

    cerr << "Dynamic code generation" << endl;
    void * dynamicBuffer;
    dynamicBuffer = MemAlloc(PI_FUNC::MAX_SIZE, MEM_READ_WRITE_EXEC);
    if (dynamicBuffer == 0) {Abort("MemAlloc failed");}

    {
        FOO_FUNC fooFunc;
        fooFunc.Copy(dynamicBuffer);
        if (!MemProtect(dynamicBuffer, PI_FUNC::MAX_SIZE, MEM_READ_EXEC)) {Abort("MemProtect failed");}
        for (int i = 0; i < 3; ++i)
        {
            fooFunc.Execute().AssertStatus();
            cerr << fooFunc.Name() << ": " << fooFunc.ErrorMessage() << endl;
        }
    }

    if (!MemProtect(dynamicBuffer, PI_FUNC::MAX_SIZE, MEM_READ_WRITE_EXEC)) {Abort("MemProtect failed");}

    {
        BAR_FUNC barFunc;
        barFunc.Copy(dynamicBuffer);
        if (!MemProtect(dynamicBuffer, PI_FUNC::MAX_SIZE, MEM_READ_EXEC)) {Abort("MemProtect failed");}
        for (int i = 0; i < 3; ++i)
        {
            barFunc.Execute().AssertStatus();
            cerr << barFunc.Name() << ": " << barFunc.ErrorMessage() << endl;
        }
    }

    return 0;
}
Beispiel #17
0
// ////////////////////////////////////////////////////////////////////////////
unsigned int GetPageAllocGranularitySize()
{
#if _Windows
   SYSTEM_INFO system_data;

   ::GetSystemInfo(&system_data);

   return(static_cast<unsigned int>(system_data.dwAllocationGranularity));
#else
   return(GetPageSize());
#endif /* #if _Windows */
}
Beispiel #18
0
// static public
bool ProcessInformation::BlockInMemory (const void* start)
{
    unsigned char x = 0;
    if (mincore (const_cast<void*>(AlignToStartOfPage (start)),
                 GetPageSize (),
                 &x)) {
        LOG (ERROR) << "mincore failed: " << strerror (errno);
        return 1;
    }

    return x & 0x1;
}
Beispiel #19
0
  void MapFile()
  {
    int pagesize = GetPageSize();
    int flag = GetMMapFlag();
    int prot = GetMMapProt();
    mapped_size_ = ((size_  + pagesize - 1) / pagesize) * pagesize;

    ptr_ = mmap(0, mapped_size_, prot, flag, fd_, offset_);
    if(ptr_ == MAP_FAILED){
      close(fd_);
      throw MMapException("mmap", path_);
    }
  }
Beispiel #20
0
static void
init_heap_space(size_t min_size, size_t max_size)
{
	size_t pagesize, alloc_size, reserve_size, freesize_pre, freesize_post;
	unsigned int min_num_segments, max_num_segments, bitmap_bits;
	void *p;

	pagesize = GetPageSize();

	if (SEGMENT_SIZE % pagesize != 0)
		sml_fatal(0, "SEGMENT_SIZE is not aligned in page size.");

	alloc_size = ALIGNSIZE(min_size, SEGMENT_SIZE);
	reserve_size = ALIGNSIZE(max_size, SEGMENT_SIZE);

	if (alloc_size < SEGMENT_SIZE)
		alloc_size = SEGMENT_SIZE;
	if (reserve_size < alloc_size)
		reserve_size = alloc_size;

	min_num_segments = alloc_size / SEGMENT_SIZE;
	max_num_segments = reserve_size / SEGMENT_SIZE;

	p = ReservePage(HEAP_BEGIN_ADDR, SEGMENT_SIZE + reserve_size);
	if (p == ReservePageError)
		sml_fatal(0, "failed to alloc virtual memory.");

	freesize_post = (uintptr_t)p & (SEGMENT_SIZE - 1);
	if (freesize_post == 0) {
		ReleasePage(p + reserve_size, SEGMENT_SIZE);
	} else {
		freesize_pre = SEGMENT_SIZE - freesize_post;
		ReleasePage(p, freesize_pre);
		p = (char*)p + freesize_pre;
		ReleasePage(p + reserve_size, freesize_post);
	}

	heap_space.begin = p;
	heap_space.end = (char*)p + reserve_size;
	heap_space.min_num_segments = min_num_segments;
	heap_space.max_num_segments = max_num_segments;
	heap_space.num_committed = 0;
	heap_space.extend_step = min_num_segments > 0 ? min_num_segments : 1;

	bitmap_bits = ALIGNSIZE(max_num_segments, BITPTR_WORDBITS);
	heap_space.bitmap = xmalloc(bitmap_bits / CHAR_BIT);
	memset(heap_space.bitmap, 0, bitmap_bits / CHAR_BIT);

	extend_heap(min_num_segments);

}
Beispiel #21
0
bool MappedFile::Map( const char* fileName, int startPage, int nBytes )
{
    if (m_hMapping != INVALID_HANDLE_VALUE)
    {
        Unmap();
    }

    m_hFile = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, 0,
                            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
    if (m_hFile == INVALID_HANDLE_VALUE)
    {
        rlog.err( "Could not open file for mapping: %s", fileName );
        return false;
    }

    m_FileSize = ::GetFileSize( m_hFile, NULL );

    //  create mapping name
    char mapName[_MAX_PATH];
    strcpy( mapName, fileName );
    char* pName = mapName;
    while (*pName)
    {
        if (*pName == '\\' || *pName == '/') *pName = '_';
        pName++;
    }

    m_hMapping = CreateFileMapping( m_hFile, NULL, PAGE_READONLY, 0, 0, mapName );
    uint32_t err = GetLastError();
    if (m_hMapping == NULL)
    {
        rlog.err( "Could not memory-map file: %s", fileName );
        m_hMapping = INVALID_HANDLE_VALUE;
        return false;
    }

    m_pBuffer = (uint8_t*)MapViewOfFile( m_hMapping, FILE_MAP_READ, 0, startPage*GetPageSize(), nBytes );
    if (m_pBuffer == NULL)
    {
        uint32_t errCode = GetLastError();
        rlog.err( "Could not memory-map view of file: %s. Error code: %X", fileName );
        return false;
    }
    CloseHandle( m_hFile );
    m_hFile = INVALID_HANDLE_VALUE;

    m_MappedSize        = nBytes;
    m_FirstMappedPage   = startPage;

    return true;
} // MappedFile::Map
    HRESULT TiledTextureFile::Initialize()
    {
        TILEDFILE_HEADER& Header = m_Header;

        if( Header.BaseWidthTexels == 0 || Header.BaseWidthTexels > MAX_WIDTH_TEXELS )
        {
            DisplayUserError( "Texture base width in texels must be between 0 and %d.", MAX_WIDTH_TEXELS );
            return E_INVALIDARG;
        }
        if( Header.BaseHeightTexels == 0 || Header.BaseHeightTexels > MAX_HEIGHT_TEXELS )
        {
            DisplayUserError( "Texture base height in texels must be between 0 and %d.", MAX_HEIGHT_TEXELS );
            return E_INVALIDARG;
        }
        if( Header.ArraySliceCount == 0 )
        {
            DisplayUserError( "Texture must have at least 1 array level." );
            return E_INVALIDARG;
        }

        SIZE PageSize = GetPageSize( Header.Format );
        if( PageSize.cx == 0 || PageSize.cy == 0 )
        {
            DisplayUserError( "Could not create texture with desired format." );
            return E_INVALIDARG;
        }

        Header.PageWidthTexels = (UINT)PageSize.cx;
        Header.PageHeightTexels = (UINT)PageSize.cy;

        UINT MipLevels = Header.MipLevelCount;
        UINT MaxMipLevelCount = 1;
        if( MipLevels == 0 )
        {
            UINT Width = Header.BaseWidthTexels;
            UINT Height = Header.BaseHeightTexels;
            UINT WidthPages = NextWholeQuotient( Width, Header.PageWidthTexels );
            UINT HeightPages = NextWholeQuotient( Height, Header.PageHeightTexels );
            while( WidthPages > 1 || HeightPages > 1 )
            {
                ++MaxMipLevelCount;
                Width = max( 1, Width >> 1 );
                Height = max( 1, Height >> 1 );
                WidthPages = NextWholeQuotient( Width, Header.PageWidthTexels );
                HeightPages = NextWholeQuotient( Height, Header.PageHeightTexels );
            }
            MipLevels = MaxMipLevelCount;
        }
Beispiel #23
0
uint8_t MappedFile::Warmup( int startPage, int nBytes )
{
    if (nBytes == 0)
    {
        nBytes = m_MappedSize;
    }
    const uint8_t* pData = m_pBuffer + startPage*GetPageSize();
    uint8_t res = 0;
    int nTouched = 0;
    while (nTouched < nBytes)
    {
        res      += m_pBuffer[nTouched];
        nTouched += c_WarmupStep;
    }

    return res;
} // MappedFile::Warmup
Beispiel #24
0
WXHBRUSH wxNotebook::QueryBgBitmap()
{
    wxRect r = GetPageSize();
    if ( r.IsEmpty() )
        return 0;

    WindowHDC hDC(GetHwnd());
    MemoryHDC hDCMem(hDC);
    CompatibleBitmap hBmp(hDC, r.x + r.width, r.y + r.height);

    SelectInHDC selectBmp(hDCMem, hBmp);

    if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) )
        return 0;

    return (WXHBRUSH)::CreatePatternBrush(hBmp);
}
Beispiel #25
0
const sf::FloatRect Scale::GetSliderRect() const {
	auto slider_length = Context::Get().GetEngine().GetProperty<float>( "SliderLength", shared_from_this() );
	auto slider_width = (GetOrientation() == Orientation::HORIZONTAL) ? GetAllocation().height : GetAllocation().width;
	auto adjustment = GetAdjustment();
	auto current_value = adjustment->GetValue();
	auto value_range = adjustment->GetUpper() - adjustment->GetLower() - adjustment->GetPageSize();

	if( GetOrientation() == Orientation::HORIZONTAL ) {
		auto slider_x = (GetAllocation().width - slider_length) * (current_value - adjustment->GetLower()) / value_range;
		auto slider_y = (GetAllocation().height - slider_width) / 2.f;

		return sf::FloatRect( slider_x, slider_y, slider_length, slider_width );
	}

	auto slider_x = (GetAllocation().width - slider_width) / 2.f;
	auto slider_y = (GetAllocation().height - slider_length) * (1 - ((current_value - adjustment->GetLower()) / value_range));

	return sf::FloatRect( slider_x, slider_y, slider_width, slider_length );
}
Beispiel #26
0
bool wxNotebook::DoDrawBackground(WXHDC hDC, wxWindow *child)
{
    wxUxThemeHandle theme(child ? child : this, L"TAB");
    if ( !theme )
        return false;

    // get the notebook client rect (we're not interested in drawing tabs
    // themselves)
    wxRect r = GetPageSize();
    if ( r.IsEmpty() )
        return false;

    RECT rc;
    wxCopyRectToRECT(r, rc);

    // map rect to the coords of the window we're drawing in
    if ( child )
        ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);

    // we have the content area (page size), but we need to draw all of the
    // background for it to be aligned correctly
    wxUxThemeEngine::Get()->GetThemeBackgroundExtent
                            (
                                theme,
                                (HDC) hDC,
                                9 /* TABP_PANE */,
                                0,
                                &rc,
                                &rc
                            );
    wxUxThemeEngine::Get()->DrawThemeBackground
                            (
                                theme,
                                (HDC) hDC,
                                9 /* TABP_PANE */,
                                0,
                                &rc,
                                NULL
                            );

    return true;
}
Beispiel #27
0
// Initializes a property page and provides the page with a pointer to the
// IPropertyPageSite interface through which the property page communicates
// with the property frame
STDMETHODIMP CPropertyPageEx::SetPageSite(LPPROPERTYPAGESITE pPageSite)
{
	HRESULT	hres = NOERROR;

	if (pPageSite) {
		assert(!m_pPageSite);
		if (m_pPageSite)
			return ResultFromScode(E_UNEXPECTED);

		m_pPageSite = pPageSite;
		m_pPageSite->AddRef();
		hres = GetPageSize(m_size);

	} else {
		assert(m_pPageSite);
		if (m_pPageSite) {
			m_pPageSite->Release();
			m_pPageSite = NULL;
		}
	}

	return hres;
}
    MemoryChunk::MemoryChunk()
    {
        blocks_ = 0;

#ifdef USE_DIRECT_IO
        int ret_code = posix_memalign(reinterpret_cast<void**>(&blocks_), GetPageSize(), ChunkSize);
        if (ret_code)
        {
            LOG4CPLUS_ERROR(Loggers::Service(), "Failed to allocate aligned memory buffer. ret_code="<<ret_code<<".");
            blocks_ = 0;
        }
#else
        blocks_ = reinterpret_cast<char*>(malloc(ChunkSize));
#endif

        if (blocks_)
        {
            for(size_t i = 0; i < BlocksPerChunk; ++i)
            {
                available_blocks_.push_back(blocks_ + i*BlockData::MaxBlockSize);
            }
        }
    }
	QImage Document::RenderPage (int index, double xRes, double yRes)
	{
		auto page = spectre_document_get_page (SD_, index);

		auto rc = spectre_render_context_new ();
		auto size = GetPageSize (index);
		spectre_render_context_set_scale (rc, xRes, yRes);
		size.rwidth () *= xRes;
		size.rheight () *= yRes;

		unsigned char *data = 0;
		int rowLength = 0;
		spectre_page_render (page, rc, &data, &rowLength);
		spectre_render_context_free (rc);
		spectre_page_free (page);

		const QImage& img = rowLength == size.width () * 4 ?
				QImage (data, size.width (), size.height (), QImage::Format_RGB32) :
				QImage (data, rowLength / 4, size.height (), QImage::Format_RGB32)
					.copy (0, 0, size.width (), size.height ());
		free (data);
		return img;
	}
Beispiel #30
0
void CVolumeCtrl::IncreaseVolume()
{
	AppSettings& s = AfxGetCurrentSettings();
	if(GetPos() > 99 && !s.fAudioNormalize){
		SetPosInternal(GetPos() + 1);
		/*
		DWORD plVolume;
				int WaveOutVol = 100;
		// 		if(MMSYSERR_NOERROR == waveOutGetVolume(0, (DWORD*)plVolume) ){
		// 			WaveOutVol = (HIWORD(plVolume) + LOWORD(plVolume)) * 100 / 2 / 0xFFFF;
		// 		}
				if( WaveOutVol > 90){
					int iBVol = (int)(50.0f*log10(s.AudioBoost));
					iBVol = min(iBVol + 8, 100);
					s.AudioBoost = pow(10.0f, (float)iBVol/50);
					if( s.AudioBoost > 100)
						s.AudioBoost = 100;
				}else{
					//increaseWaveOut
					
					//plVolume = (min( (HIWORD(plVolume) + 0x0FFF), 0xFFFF) << 16) |  min( (LOWORD(plVolume) + 0x0FFF), 0xFFFF) ;
					//waveOutSetVolume(0, plVolume);
					
				}*/
		
	}else{
		if (GetPos() > 95 ){
			SetPosInternal(100);
		}else if (GetPos() > 25 ){
			SetPosInternal(GetPos() + GetPageSize());
		}else if (GetPos() > 15 ){
			SetPosInternal(GetPos() + 3);
		}else{
			SetPosInternal(GetPos() + 1);
		}
	}
}