Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: core/fxge/skia/fx_skia_device.cpp

Issue 2004203003: fix rotated and alpha bitmaps (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/skia/fx_skia_device.cpp
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 177f10c5b97f0fa12ea5e0b9337921affe361079..0edb73acb807814735bd2010c74907513751261b 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -15,6 +15,7 @@
#include "core/fxge/skia/fx_skia_device.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
@@ -1012,8 +1013,6 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
int rowBytes = pSource->GetPitch();
switch (pSource->GetBPP()) {
case 1: {
- uint8_t zero = pSource->IsAlphaMask() ? 0xFF : 0x00;
- uint8_t one = zero ^ 0xFF;
dst8Storage.reset(FX_Alloc2D(uint8_t, width, height));
uint8_t* dst8Pixels = dst8Storage.get();
for (int y = 0; y < height; ++y) {
@@ -1021,11 +1020,12 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
static_cast<const uint8_t*>(buffer) + y * rowBytes;
uint8_t* dstRow = dst8Pixels + y * width;
for (int x = 0; x < width; ++x)
- dstRow[x] = srcRow[x >> 3] & (1 << (~x & 0x07)) ? one : zero;
+ dstRow[x] = srcRow[x >> 3] & (1 << (~x & 0x07)) ? 0xFF : 0x00;
}
buffer = dst8Storage.get();
rowBytes = width;
- colorType = SkColorType::kGray_8_SkColorType;
+ colorType = pSource->IsAlphaMask() ? SkColorType::kAlpha_8_SkColorType
+ : SkColorType::kGray_8_SkColorType;
} break;
case 8:
colorType = SkColorType::kGray_8_SkColorType;
@@ -1051,31 +1051,26 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
default:
colorType = SkColorType::kUnknown_SkColorType;
}
- SkImageInfo imageInfo =
- SkImageInfo::Make(width, height, colorType, kOpaque_SkAlphaType);
+ SkImageInfo imageInfo = SkImageInfo::Make(
+ width, height, colorType,
+ pSource->IsAlphaMask() ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
SkBitmap skBitmap;
skBitmap.installPixels(imageInfo, buffer, rowBytes,
nullptr, /* TODO(caryclark) : set color table */
nullptr, nullptr);
m_pCanvas->save();
- bool landscape = !pMatrix->a;
- if (landscape)
- m_pCanvas->translate(m_pCanvas->imageInfo().width(), 0);
- else
- m_pCanvas->translate(pMatrix->e, pMatrix->f + pMatrix->d);
-
- SkMatrix skMatrix = SkMatrix::MakeScale(1.f / width, 1.f / height);
- m_pCanvas->concat(skMatrix);
+ SkMatrix skMatrix;
const CFX_Matrix& m = *pMatrix;
- // note that PDF's y-axis goes up; Skia's y-axis goes down
- if (landscape)
- skMatrix.setAll(-m.a, -m.b, m.e, m.c, m.d, m.f, 0, 0, 1);
- else
- skMatrix.setAll(m.a, m.b, 0, -m.c, -m.d, 0, 0, 0, 1);
+ skMatrix.setAll(m.a / width, -m.c / height, m.c + m.e, m.b / width,
+ -m.d / height, m.d + m.f, 0, 0, 1);
m_pCanvas->concat(skMatrix);
SkPaint paint;
paint.setAntiAlias(true);
- paint.setFilterQuality(kHigh_SkFilterQuality);
+ if (pSource->IsAlphaMask()) {
+ paint.setColorFilter(
+ SkColorFilter::MakeModeFilter(argb, SkXfermode::kSrc_Mode));
+ }
+ // paint.setFilterQuality(kHigh_SkFilterQuality);
dsinclair 2016/05/25 00:40:18 Remove if not needed.
caryclark 2016/05/25 13:17:20 It's needed some of the time, for some conditions
paint.setXfermodeMode(GetSkiaBlendMode(blend_type));
paint.setAlpha(bitmap_alpha);
m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698