skia2/tests/XfermodeTest.cpp
vandebo@chromium.org 4854327772 [PDF] Add support for xfermodes / blend modes.
- Change SkGraphicState to track and set the blend mode (xfermode) for modes built in to PDF (non porter duff modes + src over).
- Add SkXfermode::asMode() to retrieve xfermode as an enum for non porter duff modes.
- Move SkXfermode.cpp around a bit to support asMode() -- Generally move utility functions toward the top of the file.
- Make SkPDFFormXObject an isolated transparency group, as it used for saveLayer, which draws on transparent, not the device background.
- Set the graphic state in drawDevice and drawBitmap in order to get the right xfermode and alpha.

Review URL: http://codereview.appspot.com/4131043

git-svn-id: http://skia.googlecode.com/svn/trunk@774 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-02-08 19:28:07 +00:00

31 lines
1.0 KiB
C++

#include "Test.h"
#include "SkColor.h"
#include "SkXfermode.h"
SkPMColor bogusXfermodeProc(SkPMColor src, SkPMColor dst) {
return 42;
}
static void test_asMode(skiatest::Reporter* reporter) {
for (int mode = 0; mode <= SkXfermode::kLastMode; mode++) {
SkXfermode* xfer = SkXfermode::Create((SkXfermode::Mode) mode);
SkXfermode::Mode reportedMode = (SkXfermode::Mode) -1;
REPORTER_ASSERT(reporter,
xfer != NULL || mode == SkXfermode::kSrcOver_Mode);
if (xfer) {
REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == mode);
xfer->unref();
}
}
SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc);
SkXfermode::Mode reportedMode = (SkXfermode::Mode) -1;
REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == -1);
bogusXfer->unref();
}
#include "TestClassDef.h"
DEFINE_TESTCLASS("Xfermode", XfermodeTestClass, test_asMode)