aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 21:08:46 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 21:08:46 +0000
commit7542dc8897d151afc0eca7dd73d72ea05f92baad (patch)
tree9491e955b83d65e58b1e6a0896ead7274b276316 /gm
parent11e055518a0cbe5329232a55fe2cd177e83836d8 (diff)
[PDF] Fixes the cases where SkPDFDevice::finishContentEntry is called with empty content.
There are some cases (like drawing a completely transparent image) where the code tries to finish a content entry with no content and an xfermode other than clear. This makes those cases work correctly. This is likely what was happening in chromium:316546, but it wasn't clear what the core problem was. desk_techcrunch.skp tripped a debug only assert that exposed the core issue. BUG=skia:1868,chromium:316546 R=reed@google.com, bungeman@google.com Author: vandebo@chromium.org Review URL: https://codereview.chromium.org/92453002 git-svn-id: http://skia.googlecode.com/svn/trunk@12473 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r--gm/xfermodes.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index 02cdd61927..6e1de3eb67 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -12,7 +12,8 @@
namespace skiagm {
-static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
+static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst,
+ SkBitmap* transparent) {
src->setConfig(SkBitmap::kARGB_8888_Config, w, h);
src->allocPixels();
src->eraseColor(SK_ColorTRANSPARENT);
@@ -41,6 +42,10 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
r.set(ww/3, hh/3, ww*19/20, hh*19/20);
c.drawRect(r, p);
}
+
+ transparent->setConfig(SkBitmap::kARGB_8888_Config, w, h);
+ transparent->allocPixels();
+ transparent->eraseColor(SK_ColorTRANSPARENT);
}
static uint16_t gData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF };
@@ -59,13 +64,15 @@ class XfermodesGM : public GM {
kQuarterClear_SrcType = 0x10,
//! kQuarterClear_SrcType in a layer.
kQuarterClearInLayer_SrcType = 0x20,
+ //! A W/2xH/2 transparent image.
+ kSmallTransparentImage_SrcType = 0x40,
- kAll_SrcType = 0x3F, //!< All the source types.
+ kAll_SrcType = 0x7F, //!< All the source types.
kBasic_SrcType = 0x03, //!< Just basic source types.
};
SkBitmap fBG;
- SkBitmap fSrcB, fDstB;
+ SkBitmap fSrcB, fDstB, fTransparent;
/* The srcType argument indicates what to draw for the source part. Skia
* uses the implied shape of the drawing command and these modes
@@ -81,6 +88,10 @@ class XfermodesGM : public GM {
canvas->drawBitmapMatrix(fSrcB, m, &p);
p.setXfermode(mode);
switch (srcType) {
+ case kSmallTransparentImage_SrcType:
+ m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
+ canvas->drawBitmapMatrix(fTransparent, m, &p);
+ break;
case kQuarterClearInLayer_SrcType: {
SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W),
SkIntToScalar(H));
@@ -132,7 +143,7 @@ class XfermodesGM : public GM {
fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4, kOpaque_SkAlphaType);
fBG.setPixels(gData);
- make_bitmaps(W, H, &fSrcB, &fDstB);
+ make_bitmaps(W, H, &fSrcB, &fDstB, &fTransparent);
}
public:
@@ -146,7 +157,7 @@ protected:
}
virtual SkISize onISize() {
- return make_isize(1590, 640);
+ return make_isize(1990, 640);
}
virtual void onDraw(SkCanvas* canvas) {