Closed Bug 210951 Opened 22 years ago Closed 17 years ago

Use a helper class instead of nsImageWin::BlitImage

Categories

(Core Graveyard :: GFX: Win32, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: smontagu, Unassigned)

References

Details

Attachments

(1 file, 3 obsolete files)

Attached patch wip patch (obsolete) — Splinter Review
This is a totally untested work-in-progress patch.
Blocks: 100%CPU-bg
Attached patch Getting closer (obsolete) — Splinter Review
This isn't ready for review without more testing, but I would welcome high-level comments (like "this is a good idea" or "this is a stupid waste of time") already.
Attachment #126782 - Attachment is obsolete: true
Attached patch Patch for review (obsolete) — Splinter Review
Attachment #126869 - Attachment is obsolete: true
Attachment #127061 - Flags: review?(ere)
I guess I was too slow with the review as the patch won't apply anymore. Hunk 4 failed.
I don't quite understand that, since nsImageWin.cpp hasn't changed for about 2 months, and the patch applies for me on a clean tree.
My bad, I managed to somehow break the patch file. Now to the review..
Comment on attachment 127061 [details] [diff] [review] Patch for review Ok, here we go, finally. The code looks basically ok to me, but here are some small things I found. I'm quite sure I wasn't able to find everything :) The classes don't have any safeguards against incorrect use. Looks to me like the code works correctly as it is, but I would like to see some assertions at least against overwriting non-null pointers (like if someone called nsBlitter::CreateImage() twice or didn't call Init() first). Why not do the stuff Cleanup() does in the destructor? That would make it clear it's not supposed to be called by anything else. Otherwise I think it should nullify the variables. > /* Call GetProcAddress() on MaskBlt() */ > PRBool InitMaskBlt(); Why not just call ::MaskBlt()? The version check should be enough. I believe MaskBlt is stubbed at least since Win95. In nsBlitterWithAlpha::CreateTemporary(): > if (mTmpMaskBits) { > mOldTmpMaskBits = (HBITMAP)::SelectObject(mTmpMaskDC, mTmpMaskBits); > } else { > return PR_FALSE; > } How about just "if(!) return"? > if (!mTmpImgBits) { > return PR_FALSE; > } An earlier return (well, two of them) would make it a lot easier to read and and it would also eliminate need for "if (mTmpImgBits) {". Style nits: >class nsBlitter >{ > public: > nsBlitter(); "public:" should not be indented and others just indented once. > void Blit(HDC aDstDC, Other definitions are not indented like this and BlitImageAndMask. > if(0!=memDC){ > if(0 != tmpBitmap){ > if(0!=oldBitmap) { Spaces.. > mMaskBits = ::CreateDIBSection(mHDC, (LPBITMAPINFO)&bmi, > DIB_RGB_COLORS, &screenBits, NULL, 0); Extra space. Incorrect indentations: > PRBool CreateImage(LPBITMAPINFOHEADER aBHead, > PRUint8* aImageBits, PRInt16 aNumColors, > PRInt32 aSrcX, PRInt32 aSrcY, > PRInt32 aWidth, PRInt32 aHeight); >nsBlitter::nsBlitter() >{ > mImgDC = nsnull; Typo: >// Helper class to blit images according to platform capabilites "capabilities"
Attachment #127061 - Flags: review?(ere) → review-
>I believe MaskBlt is stubbed at least since Win95. I have a patch addressing this and your other concerns and will attach it after confirming that it builds on Win9x. If so, do you think we can do the same thing with AlphaBlend()? The #defines for ALPHABLENDPROC in nsImageWin.h are commented /* for compatibility with VC++ 5 */ but VC++ 5 has not been supported for some years.
I think we could get rid of the defines, but as long as Windows 95 is supported, we can't link to msimg32 as it doesn't exist in Windows 95.
I think I have addressed all your comments, though sometimes they are expressed rather briefly and I hope I have understood them correctly. Exceptions: >> if(0!=memDC){ >> if(0 != tmpBitmap){ >> if(0!=oldBitmap) { > >Spaces.. I didn't change these lines...
Attachment #127061 - Attachment is obsolete: true
> I didn't change these lines... Oops, sorry about that. I got distracted.
Comment on attachment 128899 [details] [diff] [review] Patch addressing ere's concerns It all looked good until I noticed it turns scrollbar arrows into black blocks.
Attachment #128899 - Flags: review-
Comment on attachment 128899 [details] [diff] [review] Patch addressing ere's concerns I can get this patch to work by changing: + if (!((nsBlitterWithAlpha*)blitter)->CreateMask(0, mBHead->biWidth, to + if (!((nsBlitterWithAlpha*)blitter)->CreateMask(0, 0, and changing the two location of + MAKEROP4(SRCPAINT, SRCCOPY)); to + MAKEROP4(SRCCOPY, SRCPAINT)); HOWEVER, there's still an issue here in nsMaskBlitter::CreateMask + if (aSrcX == 0 && aSrcY == aHeight) { That line doesn't make sense. Why only use ::CreateBitmap is aSrcY == aHeight? With the changes above, this always returns false, and ::CreateBitmap never gets called. The function falls back to nsBlitterWithAlpha::CreateMask. So unless there's some purpose for using ::CreateBitmap, I would also remove nsMaskingBlitter::CreateMask alltogether
sorry for the bugspam, two typos in my last comment. Re: "two location" means there's two locations in the code that must be changed (in nsMaskingBlitter::ImageToDC and in nsMaskingBlitter::TemporaryToDC) Re: "Why only use ::CreateBitmap is aSrcY == aHeight?" = "Why only use ::CreateBitmap if aSrcY == aHeight?"
Mass reassign my image bugs to nobody@mozilla.org
Assignee: smontagu → nobody
Product: Core → Core Graveyard
nsImageWin doesn't exist any more.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: