change SkDraw and all Blitters to use pixmap instead of bitmap
BUG=skia: Review URL: https://codereview.chromium.org/1148793007
This commit is contained in:
parent
77dcbdeb19
commit
c31af44336
@ -19,7 +19,7 @@ class DrawPathBench : public Benchmark {
|
||||
SkString fName;
|
||||
SkPath fPath;
|
||||
SkRasterClip fRC;
|
||||
SkBitmap fBitmap;
|
||||
SkAutoPixmapStorage fPixmap;
|
||||
SkMatrix fIdentity;
|
||||
SkDraw fDraw;
|
||||
bool fDrawCoverage;
|
||||
@ -32,12 +32,12 @@ public:
|
||||
fPath.quadTo(500, 0, 500, 500);
|
||||
fPath.quadTo(250, 0, 0, 500);
|
||||
|
||||
fBitmap.allocPixels(SkImageInfo::MakeA8(500, 500));
|
||||
fPixmap.alloc(SkImageInfo::MakeA8(500, 500));
|
||||
|
||||
fIdentity.setIdentity();
|
||||
fRC.setRect(fPath.getBounds().round());
|
||||
|
||||
fDraw.fBitmap = &fBitmap;
|
||||
fDraw.fDst = fPixmap;
|
||||
fDraw.fMatrix = &fIdentity;
|
||||
fDraw.fClip = &fRC.bwRgn();
|
||||
fDraw.fRC = &fRC;
|
||||
|
@ -31,22 +31,17 @@ static void draw_pixel_centers(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_fatpath(SkCanvas* canvas, SkSurface* surface,
|
||||
const SkPath paths[], int count) {
|
||||
static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, const SkPath& path) {
|
||||
SkPaint paint;
|
||||
|
||||
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
surface->getCanvas()->drawPath(paths[i], paint);
|
||||
}
|
||||
surface->getCanvas()->drawPath(path, paint);
|
||||
surface->draw(canvas, 0, 0, NULL);
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
for (int j = 0; j < count; ++j) {
|
||||
canvas->drawPath(paths[j], paint);
|
||||
}
|
||||
canvas->drawPath(path, paint);
|
||||
|
||||
draw_pixel_centers(canvas);
|
||||
}
|
||||
@ -57,15 +52,15 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual SkString onShortName() {
|
||||
SkString onShortName() override {
|
||||
return SkString("fatpathfill");
|
||||
}
|
||||
|
||||
virtual SkISize onISize() {
|
||||
SkISize onISize() override {
|
||||
return SkISize::Make(SMALL_W * ZOOM, SMALL_H * ZOOM * REPEAT_LOOP);
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkAutoTUnref<SkSurface> surface(new_surface(SMALL_W, SMALL_H));
|
||||
|
||||
canvas->scale(ZOOM, ZOOM);
|
||||
@ -76,10 +71,10 @@ protected:
|
||||
|
||||
for (int i = 0; i < REPEAT_LOOP; ++i) {
|
||||
SkPath line, path;
|
||||
line.moveTo(SkIntToScalar(1), SkIntToScalar(2));
|
||||
line.lineTo(SkIntToScalar(4 + i), SkIntToScalar(1));
|
||||
line.moveTo(1, 2);
|
||||
line.lineTo(SkIntToScalar(4 + i), 1);
|
||||
paint.getFillPath(line, &path);
|
||||
draw_fatpath(canvas, surface, &path, 1);
|
||||
draw_fatpath(canvas, surface, path);
|
||||
|
||||
canvas->translate(0, SMALL_H);
|
||||
}
|
||||
|
@ -140,7 +140,8 @@ private:
|
||||
computeConservativeLocalClipBounds(SkRect* bounds) const;
|
||||
|
||||
public:
|
||||
const SkBitmap* fBitmap; // required
|
||||
// const SkBitmap* fBitmap; // required
|
||||
SkPixmap fDst;
|
||||
const SkMatrix* fMatrix; // required
|
||||
const SkRegion* fClip; // DEPRECATED
|
||||
const SkRasterClip* fRC; // required
|
||||
|
@ -1297,7 +1297,7 @@ public:
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override
|
||||
{ unexpected(); }
|
||||
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t*) override {
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t*) override {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2219,6 +2219,6 @@ void SkAAClipBlitter::blitMask(const SkMask& origMask, const SkIRect& clip) {
|
||||
} while (y < stopY);
|
||||
}
|
||||
|
||||
const SkBitmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -110,12 +110,11 @@ public:
|
||||
}
|
||||
|
||||
void blitH(int x, int y, int width) override;
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha[],
|
||||
const int16_t runs[]) override;
|
||||
void blitAntiH(int x, int y, const SkAlpha[], const int16_t runs[]) override;
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override;
|
||||
void blitRect(int x, int y, int width, int height) override;
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
|
||||
private:
|
||||
SkBlitter* fBlitter;
|
||||
|
@ -19,19 +19,19 @@
|
||||
SK_BLITBWMASK_NAME name of function(const SkBitmap& bitmap, const SkMask& mask, const SkIRect& clip, SK_BLITBWMASK_ARGS)
|
||||
SK_BLITBWMASK_ARGS list of additional arguments to SK_BLITBWMASK_NAME, beginning with a comma
|
||||
SK_BLITBWMASK_BLIT8 name of function(U8CPU byteMask, SK_BLITBWMASK_DEVTYPE* dst, int x, int y)
|
||||
SK_BLITBWMASK_GETADDR either getAddr32 or getAddr16 or getAddr8
|
||||
SK_BLITBWMASK_GETADDR either writable_addr[8,16,32]
|
||||
SK_BLITBWMASK_DEVTYPE either U32 or U16 or U8
|
||||
*/
|
||||
|
||||
static void SK_BLITBWMASK_NAME(const SkBitmap& bitmap, const SkMask& srcMask, const SkIRect& clip SK_BLITBWMASK_ARGS)
|
||||
{
|
||||
static void SK_BLITBWMASK_NAME(const SkPixmap& dst, const SkMask& srcMask,
|
||||
const SkIRect& clip SK_BLITBWMASK_ARGS) {
|
||||
SkASSERT(clip.fRight <= srcMask.fBounds.fRight);
|
||||
|
||||
int cx = clip.fLeft;
|
||||
int cy = clip.fTop;
|
||||
int maskLeft = srcMask.fBounds.fLeft;
|
||||
unsigned mask_rowBytes = srcMask.fRowBytes;
|
||||
size_t bitmap_rowBytes = bitmap.rowBytes();
|
||||
size_t bitmap_rowBytes = dst.rowBytes();
|
||||
unsigned height = clip.height();
|
||||
|
||||
SkASSERT(mask_rowBytes != 0);
|
||||
@ -39,7 +39,7 @@ static void SK_BLITBWMASK_NAME(const SkBitmap& bitmap, const SkMask& srcMask, co
|
||||
SkASSERT(height != 0);
|
||||
|
||||
const uint8_t* bits = srcMask.getAddr1(cx, cy);
|
||||
SK_BLITBWMASK_DEVTYPE* device = bitmap.SK_BLITBWMASK_GETADDR(cx, cy);
|
||||
SK_BLITBWMASK_DEVTYPE* device = dst.SK_BLITBWMASK_GETADDR(cx, cy);
|
||||
|
||||
if (cx == maskLeft && clip.fRight == srcMask.fBounds.fRight)
|
||||
{
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef SkBlitMask_DEFINED
|
||||
#define SkBlitMask_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkMask.h"
|
||||
#include "SkPixmap.h"
|
||||
|
||||
class SkBlitMask {
|
||||
public:
|
||||
@ -18,7 +18,7 @@ public:
|
||||
* Returns true if the device config and mask format were supported.
|
||||
* else return false (nothing was drawn)
|
||||
*/
|
||||
static bool BlitColor(const SkBitmap& device, const SkMask& mask,
|
||||
static bool BlitColor(const SkPixmap& device, const SkMask& mask,
|
||||
const SkIRect& clip, SkColor color);
|
||||
|
||||
/**
|
||||
|
@ -147,13 +147,13 @@ SkBlitMask::ColorProc SkBlitMask::ColorFactory(SkColorType ct,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SkBlitMask::BlitColor(const SkBitmap& device, const SkMask& mask,
|
||||
bool SkBlitMask::BlitColor(const SkPixmap& device, const SkMask& mask,
|
||||
const SkIRect& clip, SkColor color) {
|
||||
ColorProc proc = ColorFactory(device.colorType(), mask.fFormat, color);
|
||||
if (proc) {
|
||||
int x = clip.fLeft;
|
||||
int y = clip.fTop;
|
||||
proc(device.getAddr32(x, y), device.rowBytes(), mask.getAddr(x, y),
|
||||
proc(device.writable_addr32(x, y), device.rowBytes(), mask.getAddr(x, y),
|
||||
mask.fRowBytes, color, clip.width(), clip.height());
|
||||
return true;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ SkShader::Context* SkBlitter::getShaderContext() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const SkBitmap* SkBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ void SkNullBlitter::blitRect(int x, int y, int width, int height) {}
|
||||
|
||||
void SkNullBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {}
|
||||
|
||||
const SkBitmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -404,7 +404,7 @@ void SkRectClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
}
|
||||
}
|
||||
|
||||
const SkBitmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
return fBlitter->justAnOpaqueColor(value);
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ void SkRgnClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
}
|
||||
}
|
||||
|
||||
const SkBitmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value) {
|
||||
return fBlitter->justAnOpaqueColor(value);
|
||||
}
|
||||
|
||||
@ -778,7 +778,7 @@ private:
|
||||
|
||||
#include "SkCoreBlitters.h"
|
||||
|
||||
SkBlitter* SkBlitter::Choose(const SkBitmap& device,
|
||||
SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
const SkMatrix& matrix,
|
||||
const SkPaint& origPaint,
|
||||
SkTBlitterAllocator* allocator,
|
||||
@ -944,7 +944,7 @@ private:
|
||||
typedef SkShader::Context INHERITED;
|
||||
};
|
||||
|
||||
SkShaderBlitter::SkShaderBlitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device)
|
||||
, fShader(paint.getShader())
|
||||
|
@ -8,11 +8,11 @@
|
||||
#ifndef SkBlitter_DEFINED
|
||||
#define SkBlitter_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
#include "SkMask.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPixmap.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkShader.h"
|
||||
@ -51,7 +51,7 @@ public:
|
||||
bitmap it draws into, and assign value. If not, return NULL and ignore
|
||||
the value parameter.
|
||||
*/
|
||||
virtual const SkBitmap* justAnOpaqueColor(uint32_t* value);
|
||||
virtual const SkPixmap* justAnOpaqueColor(uint32_t* value);
|
||||
|
||||
// (x, y), (x + 1, y)
|
||||
virtual void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
@ -122,7 +122,7 @@ public:
|
||||
/** @name Factories
|
||||
Return the correct blitter to use given the specified context.
|
||||
*/
|
||||
static SkBlitter* Choose(const SkBitmap& device,
|
||||
static SkBlitter* Choose(const SkPixmap& dst,
|
||||
const SkMatrix& matrix,
|
||||
const SkPaint& paint,
|
||||
SkTBlitterAllocator*,
|
||||
@ -152,7 +152,7 @@ public:
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override;
|
||||
void blitRect(int x, int y, int width, int height) override;
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
bool isNullBlitter() const override;
|
||||
};
|
||||
|
||||
@ -176,7 +176,7 @@ public:
|
||||
virtual void blitAntiRect(int x, int y, int width, int height,
|
||||
SkAlpha leftAlpha, SkAlpha rightAlpha) override;
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
|
||||
int requestRowsPreserved() const override {
|
||||
return fBlitter->requestRowsPreserved();
|
||||
@ -211,7 +211,7 @@ public:
|
||||
virtual void blitAntiRect(int x, int y, int width, int height,
|
||||
SkAlpha leftAlpha, SkAlpha rightAlpha) override;
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
|
||||
|
||||
int requestRowsPreserved() const override {
|
||||
return fBlitter->requestRowsPreserved();
|
||||
|
@ -12,12 +12,11 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
: INHERITED(device) {
|
||||
SkA8_Blitter::SkA8_Blitter(const SkPixmap& device, const SkPaint& paint) : INHERITED(device) {
|
||||
fSrcA = paint.getAlpha();
|
||||
}
|
||||
|
||||
const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
if (255 == fSrcA) {
|
||||
*value = 255;
|
||||
return &fDevice;
|
||||
@ -33,7 +32,7 @@ void SkA8_Blitter::blitH(int x, int y, int width) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
|
||||
if (fSrcA == 255) {
|
||||
memset(device, 0xFF, width);
|
||||
@ -53,7 +52,7 @@ void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
unsigned srcA = fSrcA;
|
||||
|
||||
for (;;) {
|
||||
@ -97,7 +96,7 @@ void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
#define SK_BLITBWMASK_NAME SkA8_BlitBW
|
||||
#define SK_BLITBWMASK_ARGS
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr8
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr8
|
||||
#define SK_BLITBWMASK_DEVTYPE uint8_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -116,7 +115,7 @@ static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa,
|
||||
#define SK_BLITBWMASK_NAME SkA8_BlendBW
|
||||
#define SK_BLITBWMASK_ARGS , U8CPU sa, unsigned dst_scale
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sa, dst_scale)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr8
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr8
|
||||
#define SK_BLITBWMASK_DEVTYPE uint8_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -139,7 +138,7 @@ void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
int y = clip.fTop;
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
const uint8_t* alpha = mask.getAddr8(x, y);
|
||||
unsigned srcA = fSrcA;
|
||||
|
||||
@ -179,7 +178,7 @@ void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
}
|
||||
|
||||
unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha));
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
size_t rowBytes = fDevice.rowBytes();
|
||||
|
||||
if (sa == 0xFF) {
|
||||
@ -206,7 +205,7 @@ void SkA8_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
unsigned srcA = fSrcA;
|
||||
|
||||
if (srcA == 255) {
|
||||
@ -228,9 +227,10 @@ void SkA8_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext) {
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
if ((fXfermode = paint.getXfermode()) != NULL) {
|
||||
fXfermode->ref();
|
||||
SkASSERT(fShaderContext);
|
||||
@ -250,7 +250,7 @@ void SkA8_Shader_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(x >= 0 && y >= 0 &&
|
||||
(unsigned)(x + width) <= (unsigned)fDevice.width());
|
||||
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
|
||||
if ((shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) && !fXfermode) {
|
||||
@ -288,7 +288,7 @@ void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
SkXfermode* mode = fXfermode;
|
||||
uint8_t* aaExpand = fAAExpand;
|
||||
SkPMColor* span = fBuffer;
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
int opaque = shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag;
|
||||
|
||||
for (;;) {
|
||||
@ -329,7 +329,7 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
int y = clip.fTop;
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
const uint8_t* alpha = mask.getAddr8(x, y);
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
|
||||
@ -353,7 +353,7 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkBitmap& device,
|
||||
SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device,
|
||||
const SkPaint& paint) : SkRasterBlitter(device) {
|
||||
SkASSERT(NULL == paint.getShader());
|
||||
SkASSERT(NULL == paint.getXfermode());
|
||||
@ -362,7 +362,7 @@ SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkBitmap& device,
|
||||
|
||||
void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
const int16_t runs[]) {
|
||||
uint8_t* device = fDevice.getAddr8(x, y);
|
||||
uint8_t* device = fDevice.writable_addr8(x, y);
|
||||
SkDEBUGCODE(int totalCount = 0;)
|
||||
|
||||
for (;;) {
|
||||
@ -384,7 +384,7 @@ void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
}
|
||||
|
||||
void SkA8_Coverage_Blitter::blitH(int x, int y, int width) {
|
||||
memset(fDevice.getAddr8(x, y), 0xFF, width);
|
||||
memset(fDevice.writable_addr8(x, y), 0xFF, width);
|
||||
}
|
||||
|
||||
void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
@ -392,7 +392,7 @@ void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* dst = fDevice.getAddr8(x, y);
|
||||
uint8_t* dst = fDevice.writable_addr8(x, y);
|
||||
const size_t dstRB = fDevice.rowBytes();
|
||||
while (--height >= 0) {
|
||||
*dst = alpha;
|
||||
@ -401,7 +401,7 @@ void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
}
|
||||
|
||||
void SkA8_Coverage_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
uint8_t* dst = fDevice.getAddr8(x, y);
|
||||
uint8_t* dst = fDevice.writable_addr8(x, y);
|
||||
const size_t dstRB = fDevice.rowBytes();
|
||||
while (--height >= 0) {
|
||||
memset(dst, 0xFF, width);
|
||||
@ -417,7 +417,7 @@ void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
|
||||
uint8_t* dst = fDevice.getAddr8(x, y);
|
||||
uint8_t* dst = fDevice.writable_addr8(x, y);
|
||||
const uint8_t* src = mask.getAddr8(x, y);
|
||||
const size_t srcRB = mask.fRowBytes;
|
||||
const size_t dstRB = fDevice.rowBytes();
|
||||
@ -429,6 +429,6 @@ void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
}
|
||||
}
|
||||
|
||||
const SkBitmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) {
|
||||
const SkPixmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask,
|
||||
static void SkARGB32_Blit32(const SkPixmap& device, const SkMask& mask,
|
||||
const SkIRect& clip, SkPMColor srcColor) {
|
||||
U8CPU alpha = SkGetPackedA32(srcColor);
|
||||
unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32;
|
||||
@ -28,7 +28,7 @@ static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask,
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
|
||||
SkPMColor* dstRow = device.getAddr32(x, y);
|
||||
SkPMColor* dstRow = device.writable_addr32(x, y);
|
||||
const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr8(x, y));
|
||||
|
||||
do {
|
||||
@ -40,7 +40,7 @@ static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
SkARGB32_Blitter::SkARGB32_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device) {
|
||||
SkColor color = paint.getColor();
|
||||
fColor = color;
|
||||
@ -54,7 +54,7 @@ SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB);
|
||||
}
|
||||
|
||||
const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
if (255 == fSrcA) {
|
||||
*value = fPMColor;
|
||||
return &fDevice;
|
||||
@ -70,7 +70,7 @@ const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
void SkARGB32_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkBlitRow::Color32(device, device, width, fPMColor);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
}
|
||||
|
||||
uint32_t color = fPMColor;
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case
|
||||
|
||||
for (;;) {
|
||||
@ -106,16 +106,16 @@ void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
}
|
||||
|
||||
void SkARGB32_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);)
|
||||
|
||||
device[0] = SkBlendARGB32(fPMColor, device[0], a0);
|
||||
device[1] = SkBlendARGB32(fPMColor, device[1], a1);
|
||||
}
|
||||
|
||||
void SkARGB32_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);)
|
||||
|
||||
device[0] = SkBlendARGB32(fPMColor, device[0], a0);
|
||||
device = (uint32_t*)((char*)device + fDevice.rowBytes());
|
||||
@ -139,7 +139,7 @@ void SkARGB32_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
#define SK_BLITBWMASK_NAME SkARGB32_BlitBW
|
||||
#define SK_BLITBWMASK_ARGS , SkPMColor color
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr32
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr32
|
||||
#define SK_BLITBWMASK_DEVTYPE uint32_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -158,7 +158,7 @@ void SkARGB32_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
#define SK_BLITBWMASK_NAME SkARGB32_BlendBW
|
||||
#define SK_BLITBWMASK_ARGS , uint32_t sc, unsigned dst_scale
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sc, dst_scale)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr32
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr32
|
||||
#define SK_BLITBWMASK_DEVTYPE uint32_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -197,16 +197,16 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
|
||||
}
|
||||
|
||||
void SkARGB32_Opaque_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);)
|
||||
|
||||
device[0] = SkFastFourByteInterp(fPMColor, device[0], a0);
|
||||
device[1] = SkFastFourByteInterp(fPMColor, device[1], a1);
|
||||
}
|
||||
|
||||
void SkARGB32_Opaque_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);)
|
||||
|
||||
device[0] = SkFastFourByteInterp(fPMColor, device[0], a0);
|
||||
device = (uint32_t*)((char*)device + fDevice.rowBytes());
|
||||
@ -220,7 +220,7 @@ void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
uint32_t color = fPMColor;
|
||||
|
||||
if (alpha != 255) {
|
||||
@ -242,7 +242,7 @@ void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
uint32_t color = fPMColor;
|
||||
size_t rowBytes = fDevice.rowBytes();
|
||||
|
||||
@ -260,7 +260,7 @@ void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
|
||||
void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
const int16_t runs[]) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT);
|
||||
|
||||
for (;;) {
|
||||
@ -290,16 +290,16 @@ void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
}
|
||||
|
||||
void SkARGB32_Black_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);)
|
||||
|
||||
device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0);
|
||||
device[1] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[1], 256 - a1);
|
||||
}
|
||||
|
||||
void SkARGB32_Black_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);)
|
||||
|
||||
device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0);
|
||||
device = (uint32_t*)((char*)device + fDevice.rowBytes());
|
||||
@ -319,7 +319,7 @@ static void blend_srcmode(SkPMColor* SK_RESTRICT device,
|
||||
}
|
||||
}
|
||||
|
||||
SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device,
|
||||
SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
|
||||
const SkPaint& paint, SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
@ -363,7 +363,7 @@ SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() {
|
||||
void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
|
||||
if (fShadeDirectlyIntoDevice) {
|
||||
fShaderContext->shadeSpan(x, y, device, width);
|
||||
@ -382,7 +382,7 @@ void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkASSERT(x >= 0 && y >= 0 &&
|
||||
x + width <= fDevice.width() && y + height <= fDevice.height());
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
SkPMColor* span = fBuffer;
|
||||
@ -457,7 +457,7 @@ void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||
const int16_t runs[]) {
|
||||
SkPMColor* span = fBuffer;
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
|
||||
if (fXfermode && !fShadeDirectlyIntoDevice) {
|
||||
@ -558,7 +558,7 @@ void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
|
||||
int y = clip.fTop;
|
||||
int height = clip.height();
|
||||
|
||||
char* dstRow = (char*)fDevice.getAddr32(x, y);
|
||||
char* dstRow = (char*)fDevice.writable_addr32(x, y);
|
||||
const size_t dstRB = fDevice.rowBytes();
|
||||
const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
|
||||
const size_t maskRB = mask.fRowBytes;
|
||||
@ -589,7 +589,7 @@ void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
|
||||
void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height());
|
||||
|
||||
uint32_t* device = fDevice.getAddr32(x, y);
|
||||
uint32_t* device = fDevice.writable_addr32(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "SkBlitRow.h"
|
||||
#include "SkCoreBlitters.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -58,15 +56,14 @@ void sk_dither_memset16(uint16_t dst[], uint16_t value, uint16_t other,
|
||||
|
||||
class SkRGB16_Blitter : public SkRasterBlitter {
|
||||
public:
|
||||
SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkRGB16_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
void blitH(int x, int y, int width) override;
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
|
||||
const int16_t* runs) override;
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override;
|
||||
void blitRect(int x, int y, int width, int height) override;
|
||||
virtual void blitMask(const SkMask&,
|
||||
const SkIRect&) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t*) override;
|
||||
void blitMask(const SkMask&, const SkIRect&) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t*) override;
|
||||
|
||||
protected:
|
||||
SkPMColor fSrcColor32;
|
||||
@ -87,14 +84,12 @@ protected:
|
||||
|
||||
class SkRGB16_Opaque_Blitter : public SkRGB16_Blitter {
|
||||
public:
|
||||
SkRGB16_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkRGB16_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
void blitH(int x, int y, int width) override;
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
|
||||
const int16_t* runs) override;
|
||||
void blitAntiH(int x, int y, const SkAlpha* antialias, const int16_t* runs) override;
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override;
|
||||
void blitRect(int x, int y, int width, int height) override;
|
||||
virtual void blitMask(const SkMask&,
|
||||
const SkIRect&) override;
|
||||
void blitMask(const SkMask&, const SkIRect&) override;
|
||||
|
||||
private:
|
||||
typedef SkRGB16_Blitter INHERITED;
|
||||
@ -103,10 +98,9 @@ private:
|
||||
#ifdef USE_BLACK_BLITTER
|
||||
class SkRGB16_Black_Blitter : public SkRGB16_Opaque_Blitter {
|
||||
public:
|
||||
SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkRGB16_Black_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
void blitMask(const SkMask&, const SkIRect&) override;
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
|
||||
const int16_t* runs) override;
|
||||
void blitAntiH(int x, int y, const SkAlpha* antialias, const int16_t* runs) override;
|
||||
|
||||
private:
|
||||
typedef SkRGB16_Opaque_Blitter INHERITED;
|
||||
@ -115,7 +109,7 @@ private:
|
||||
|
||||
class SkRGB16_Shader_Blitter : public SkShaderBlitter {
|
||||
public:
|
||||
SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkRGB16_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
virtual ~SkRGB16_Shader_Blitter();
|
||||
void blitH(int x, int y, int width) override;
|
||||
@ -138,7 +132,7 @@ private:
|
||||
// used only if the shader can perform shadSpan16
|
||||
class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter {
|
||||
public:
|
||||
SkRGB16_Shader16_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkRGB16_Shader16_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
void blitH(int x, int y, int width) override;
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
|
||||
@ -151,7 +145,7 @@ private:
|
||||
|
||||
class SkRGB16_Shader_Xfermode_Blitter : public SkShaderBlitter {
|
||||
public:
|
||||
SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkRGB16_Shader_Xfermode_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
virtual ~SkRGB16_Shader_Xfermode_Blitter();
|
||||
void blitH(int x, int y, int width) override;
|
||||
@ -171,7 +165,7 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef USE_BLACK_BLITTER
|
||||
SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device, paint) {
|
||||
SkASSERT(paint.getShader() == NULL);
|
||||
SkASSERT(paint.getColorFilter() == NULL);
|
||||
@ -208,7 +202,7 @@ static inline black_8_pixels(U8CPU mask, uint16_t dst[])
|
||||
#define SK_BLITBWMASK_NAME SkRGB16_Black_BlitBW
|
||||
#define SK_BLITBWMASK_ARGS
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) black_8_pixels(mask, dst)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr16
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr16
|
||||
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -217,7 +211,7 @@ void SkRGB16_Black_Blitter::blitMask(const SkMask& mask,
|
||||
if (mask.fFormat == SkMask::kBW_Format) {
|
||||
SkRGB16_Black_BlitBW(fDevice, mask, clip);
|
||||
} else {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop);
|
||||
const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
|
||||
unsigned width = clip.width();
|
||||
unsigned height = clip.height();
|
||||
@ -245,7 +239,7 @@ void SkRGB16_Black_Blitter::blitMask(const SkMask& mask,
|
||||
void SkRGB16_Black_Blitter::blitAntiH(int x, int y,
|
||||
const SkAlpha* SK_RESTRICT antialias,
|
||||
const int16_t* SK_RESTRICT runs) {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
|
||||
for (;;) {
|
||||
int count = runs[0];
|
||||
@ -277,14 +271,13 @@ void SkRGB16_Black_Blitter::blitAntiH(int x, int y,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkRGB16_Opaque_Blitter::SkRGB16_Opaque_Blitter(const SkBitmap& device,
|
||||
const SkPaint& paint)
|
||||
: INHERITED(device, paint) {}
|
||||
SkRGB16_Opaque_Blitter::SkRGB16_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device, paint) {}
|
||||
|
||||
void SkRGB16_Opaque_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(width > 0);
|
||||
SkASSERT(x + width <= fDevice.width());
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
uint16_t srcColor = fColor16;
|
||||
|
||||
SkASSERT(fRawColor16 == srcColor);
|
||||
@ -307,7 +300,7 @@ static inline int Bool2Int(int value) {
|
||||
void SkRGB16_Opaque_Blitter::blitAntiH(int x, int y,
|
||||
const SkAlpha* SK_RESTRICT antialias,
|
||||
const int16_t* SK_RESTRICT runs) {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
uint16_t srcColor = fRawColor16;
|
||||
uint32_t srcExpanded = fExpandedRaw16;
|
||||
int ditherInt = Bool2Int(fDoDither);
|
||||
@ -372,7 +365,7 @@ void SkRGB16_Opaque_Blitter::blitAntiH(int x, int y,
|
||||
#define SK_BLITBWMASK_NAME SkRGB16_BlitBW
|
||||
#define SK_BLITBWMASK_ARGS , uint16_t color
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr16
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr16
|
||||
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -389,7 +382,7 @@ void SkRGB16_Opaque_Blitter::blitMask(const SkMask& mask,
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop);
|
||||
const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
@ -484,7 +477,7 @@ void SkRGB16_Opaque_Blitter::blitMask(const SkMask& mask,
|
||||
}
|
||||
|
||||
void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
|
||||
// TODO: respect fDoDither
|
||||
@ -500,7 +493,7 @@ void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
|
||||
void SkRGB16_Opaque_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
uint16_t color16 = fColor16;
|
||||
|
||||
@ -524,7 +517,7 @@ void SkRGB16_Opaque_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
SkRGB16_Blitter::SkRGB16_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device) {
|
||||
SkColor color = paint.getColor();
|
||||
|
||||
@ -561,7 +554,7 @@ SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
fColorProc16 = SkBlitRow::ColorFactory16(flags);
|
||||
}
|
||||
|
||||
const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
const SkPixmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
if (!fDoDither && 256 == fScale) {
|
||||
*value = fRawColor16;
|
||||
return &fDevice;
|
||||
@ -572,7 +565,7 @@ const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||
void SkRGB16_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(width > 0);
|
||||
SkASSERT(x + width <= fDevice.width());
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
|
||||
fColorProc16(device, fSrcColor32, width, x, y);
|
||||
}
|
||||
@ -580,7 +573,7 @@ void SkRGB16_Blitter::blitH(int x, int y, int width) {
|
||||
void SkRGB16_Blitter::blitAntiH(int x, int y,
|
||||
const SkAlpha* SK_RESTRICT antialias,
|
||||
const int16_t* SK_RESTRICT runs) {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
uint32_t srcExpanded = fExpandedRaw16;
|
||||
unsigned scale = fScale;
|
||||
|
||||
@ -624,7 +617,7 @@ static inline void blend_8_pixels(U8CPU bw, uint16_t dst[], unsigned dst_scale,
|
||||
#define SK_BLITBWMASK_NAME SkRGB16_BlendBW
|
||||
#define SK_BLITBWMASK_ARGS , unsigned dst_scale, U16CPU src_color
|
||||
#define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, dst_scale, src_color)
|
||||
#define SK_BLITBWMASK_GETADDR getAddr16
|
||||
#define SK_BLITBWMASK_GETADDR writable_addr16
|
||||
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
||||
#include "SkBlitBWMaskTemplate.h"
|
||||
|
||||
@ -635,7 +628,7 @@ void SkRGB16_Blitter::blitMask(const SkMask& mask,
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop);
|
||||
const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
|
||||
int width = clip.width();
|
||||
int height = clip.height();
|
||||
@ -659,7 +652,7 @@ void SkRGB16_Blitter::blitMask(const SkMask& mask,
|
||||
}
|
||||
|
||||
void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
|
||||
// TODO: respect fDoDither
|
||||
@ -675,7 +668,7 @@ void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||
|
||||
void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
|
||||
while (--height >= 0) {
|
||||
@ -686,17 +679,18 @@ void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkBitmap& device,
|
||||
SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkPixmap& device,
|
||||
const SkPaint& paint,
|
||||
SkShader::Context* shaderContext)
|
||||
: SkRGB16_Shader_Blitter(device, paint, shaderContext) {
|
||||
: SkRGB16_Shader_Blitter(device, paint, shaderContext)
|
||||
{
|
||||
SkASSERT(SkShader::CanCallShadeSpan16(fShaderFlags));
|
||||
}
|
||||
|
||||
void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(x + width <= fDevice.width());
|
||||
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
|
||||
int alpha = shaderContext->getSpan16Alpha();
|
||||
@ -711,7 +705,7 @@ void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) {
|
||||
|
||||
void SkRGB16_Shader16_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
uint16_t* dst = fDevice.getAddr16(x, y);
|
||||
uint16_t* dst = fDevice.writable_addr16(x, y);
|
||||
size_t dstRB = fDevice.rowBytes();
|
||||
int alpha = shaderContext->getSpan16Alpha();
|
||||
|
||||
@ -759,7 +753,7 @@ void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y,
|
||||
const int16_t* SK_RESTRICT runs) {
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
SkPMColor* SK_RESTRICT span = fBuffer;
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
|
||||
int alpha = shaderContext->getSpan16Alpha();
|
||||
uint16_t* span16 = (uint16_t*)span;
|
||||
@ -810,10 +804,11 @@ void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkBitmap& device,
|
||||
SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
|
||||
const SkPaint& paint,
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext) {
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
SkASSERT(paint.getXfermode() == NULL);
|
||||
|
||||
fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
|
||||
@ -845,14 +840,14 @@ void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) {
|
||||
|
||||
fShaderContext->shadeSpan(x, y, fBuffer, width);
|
||||
// shaders take care of global alpha, so we pass 0xFF (should be ignored)
|
||||
fOpaqueProc(fDevice.getAddr16(x, y), fBuffer, width, 0xFF, x, y);
|
||||
fOpaqueProc(fDevice.writable_addr16(x, y), fBuffer, width, 0xFF, x, y);
|
||||
}
|
||||
|
||||
void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
SkBlitRow::Proc16 proc = fOpaqueProc;
|
||||
SkPMColor* buffer = fBuffer;
|
||||
uint16_t* dst = fDevice.getAddr16(x, y);
|
||||
uint16_t* dst = fDevice.writable_addr16(x, y);
|
||||
size_t dstRB = fDevice.rowBytes();
|
||||
|
||||
if (fShaderFlags & SkShader::kConstInY32_Flag) {
|
||||
@ -891,7 +886,7 @@ void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
|
||||
const int16_t* SK_RESTRICT runs) {
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
SkPMColor* SK_RESTRICT span = fBuffer;
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
|
||||
for (;;) {
|
||||
int count = *runs;
|
||||
@ -937,9 +932,10 @@ void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
|
||||
const SkBitmap& device, const SkPaint& paint,
|
||||
const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext) {
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
fXfermode = paint.getXfermode();
|
||||
SkASSERT(fXfermode);
|
||||
fXfermode->ref();
|
||||
@ -957,7 +953,7 @@ SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() {
|
||||
void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) {
|
||||
SkASSERT(x + width <= fDevice.width());
|
||||
|
||||
uint16_t* device = fDevice.getAddr16(x, y);
|
||||
uint16_t* device = fDevice.writable_addr16(x, y);
|
||||
SkPMColor* span = fBuffer;
|
||||
|
||||
fShaderContext->shadeSpan(x, y, span, width);
|
||||
@ -971,7 +967,7 @@ void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
|
||||
SkXfermode* mode = fXfermode;
|
||||
SkPMColor* SK_RESTRICT span = fBuffer;
|
||||
uint8_t* SK_RESTRICT aaExpand = fAAExpand;
|
||||
uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
|
||||
uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
|
||||
|
||||
for (;;) {
|
||||
int count = *runs;
|
||||
@ -1021,7 +1017,7 @@ void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint,
|
||||
SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext,
|
||||
SkTBlitterAllocator* allocator) {
|
||||
SkASSERT(allocator != NULL);
|
||||
|
@ -271,7 +271,9 @@ public:
|
||||
fClip = &((SkRasterClip*)&rec->fClip)->forceGetBW();
|
||||
fRC = &rec->fClip;
|
||||
fDevice = rec->fDevice;
|
||||
fBitmap = &fDevice->accessBitmap(true);
|
||||
if (!fDevice->accessPixels(&fDst)) {
|
||||
fDst.reset(fDevice->imageInfo(), NULL, 0);
|
||||
}
|
||||
fPaint = rec->fPaint;
|
||||
SkDEBUGCODE(this->validate();)
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
class SkRasterBlitter : public SkBlitter {
|
||||
public:
|
||||
SkRasterBlitter(const SkBitmap& device) : fDevice(device) {}
|
||||
SkRasterBlitter(const SkPixmap& device) : fDevice(device) {}
|
||||
|
||||
protected:
|
||||
const SkBitmap& fDevice;
|
||||
const SkPixmap fDevice;
|
||||
|
||||
private:
|
||||
typedef SkBlitter INHERITED;
|
||||
@ -32,7 +32,7 @@ public:
|
||||
* The blitter only ensures that the storage always holds a live object, but it may
|
||||
* exchange that object.
|
||||
*/
|
||||
SkShaderBlitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
virtual ~SkShaderBlitter();
|
||||
|
||||
@ -61,24 +61,24 @@ private:
|
||||
|
||||
class SkA8_Coverage_Blitter : public SkRasterBlitter {
|
||||
public:
|
||||
SkA8_Coverage_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkA8_Coverage_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
void blitH(int x, int y, int width) override;
|
||||
void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override;
|
||||
void blitRect(int x, int y, int width, int height) override;
|
||||
void blitMask(const SkMask&, const SkIRect&) override;
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t*) override;
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t*) override;
|
||||
};
|
||||
|
||||
class SkA8_Blitter : public SkRasterBlitter {
|
||||
public:
|
||||
SkA8_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkA8_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
virtual void blitH(int x, int y, int width);
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
|
||||
virtual void blitV(int x, int y, int height, SkAlpha alpha);
|
||||
virtual void blitRect(int x, int y, int width, int height);
|
||||
virtual void blitMask(const SkMask&, const SkIRect&);
|
||||
virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
|
||||
virtual const SkPixmap* justAnOpaqueColor(uint32_t*);
|
||||
|
||||
private:
|
||||
unsigned fSrcA;
|
||||
@ -91,7 +91,7 @@ private:
|
||||
|
||||
class SkA8_Shader_Blitter : public SkShaderBlitter {
|
||||
public:
|
||||
SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
virtual ~SkA8_Shader_Blitter();
|
||||
virtual void blitH(int x, int y, int width);
|
||||
@ -113,13 +113,13 @@ private:
|
||||
|
||||
class SkARGB32_Blitter : public SkRasterBlitter {
|
||||
public:
|
||||
SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||
SkARGB32_Blitter(const SkPixmap& device, const SkPaint& paint);
|
||||
virtual void blitH(int x, int y, int width);
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
|
||||
virtual void blitV(int x, int y, int height, SkAlpha alpha);
|
||||
virtual void blitRect(int x, int y, int width, int height);
|
||||
virtual void blitMask(const SkMask&, const SkIRect&);
|
||||
virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
|
||||
virtual const SkPixmap* justAnOpaqueColor(uint32_t*);
|
||||
void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
|
||||
void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override;
|
||||
|
||||
@ -138,7 +138,7 @@ private:
|
||||
|
||||
class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter {
|
||||
public:
|
||||
SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
SkARGB32_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); }
|
||||
virtual void blitMask(const SkMask&, const SkIRect&);
|
||||
void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
|
||||
@ -150,7 +150,7 @@ private:
|
||||
|
||||
class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter {
|
||||
public:
|
||||
SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||
SkARGB32_Black_Blitter(const SkPixmap& device, const SkPaint& paint)
|
||||
: INHERITED(device, paint) {}
|
||||
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
|
||||
void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
|
||||
@ -162,7 +162,7 @@ private:
|
||||
|
||||
class SkARGB32_Shader_Blitter : public SkShaderBlitter {
|
||||
public:
|
||||
SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
|
||||
SkARGB32_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext);
|
||||
virtual ~SkARGB32_Shader_Blitter();
|
||||
void blitH(int x, int y, int width) override;
|
||||
@ -200,7 +200,7 @@ private:
|
||||
SkBlitter::Choose(...)
|
||||
*/
|
||||
|
||||
SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint,
|
||||
SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
|
||||
SkShader::Context* shaderContext,
|
||||
SkTBlitterAllocator* allocator);
|
||||
|
||||
|
@ -7,17 +7,16 @@
|
||||
|
||||
#include "SkDeviceLooper.h"
|
||||
|
||||
SkDeviceLooper::SkDeviceLooper(const SkBitmap& base,
|
||||
const SkRasterClip& rc,
|
||||
const SkIRect& bounds, bool aa)
|
||||
: fBaseBitmap(base)
|
||||
SkDeviceLooper::SkDeviceLooper(const SkPixmap& base, const SkRasterClip& rc, const SkIRect& bounds,
|
||||
bool aa)
|
||||
: fBaseDst(base)
|
||||
, fBaseRC(rc)
|
||||
, fSubsetRC(rc.isForceConservativeRects())
|
||||
, fDelta(aa ? kAA_Delta : kBW_Delta)
|
||||
{
|
||||
// sentinels that next() has not yet been called, and so our mapper functions
|
||||
// should not be called either.
|
||||
fCurrBitmap = NULL;
|
||||
fCurrDst = NULL;
|
||||
fCurrRC = NULL;
|
||||
|
||||
if (!rc.isEmpty()) {
|
||||
@ -38,12 +37,11 @@ SkDeviceLooper::SkDeviceLooper(const SkBitmap& base,
|
||||
}
|
||||
}
|
||||
|
||||
SkDeviceLooper::~SkDeviceLooper() {
|
||||
}
|
||||
SkDeviceLooper::~SkDeviceLooper() {}
|
||||
|
||||
void SkDeviceLooper::mapRect(SkRect* dst, const SkRect& src) const {
|
||||
SkASSERT(kDone_State != fState);
|
||||
SkASSERT(fCurrBitmap);
|
||||
SkASSERT(fCurrDst);
|
||||
SkASSERT(fCurrRC);
|
||||
|
||||
*dst = src;
|
||||
@ -53,12 +51,11 @@ void SkDeviceLooper::mapRect(SkRect* dst, const SkRect& src) const {
|
||||
|
||||
void SkDeviceLooper::mapMatrix(SkMatrix* dst, const SkMatrix& src) const {
|
||||
SkASSERT(kDone_State != fState);
|
||||
SkASSERT(fCurrBitmap);
|
||||
SkASSERT(fCurrDst);
|
||||
SkASSERT(fCurrRC);
|
||||
|
||||
*dst = src;
|
||||
dst->postTranslate(SkIntToScalar(-fCurrOffset.fX),
|
||||
SkIntToScalar(-fCurrOffset.fY));
|
||||
dst->postTranslate(SkIntToScalar(-fCurrOffset.fX), SkIntToScalar(-fCurrOffset.fY));
|
||||
}
|
||||
|
||||
bool SkDeviceLooper::computeCurrBitmapAndClip() {
|
||||
@ -66,16 +63,14 @@ bool SkDeviceLooper::computeCurrBitmapAndClip() {
|
||||
|
||||
SkIRect r = SkIRect::MakeXYWH(fCurrOffset.x(), fCurrOffset.y(),
|
||||
fDelta, fDelta);
|
||||
if (!fBaseBitmap.extractSubset(&fSubsetBitmap, r)) {
|
||||
if (!fBaseDst.extractSubset(&fSubsetDst, r)) {
|
||||
fSubsetRC.setEmpty();
|
||||
} else {
|
||||
fSubsetBitmap.lockPixels();
|
||||
fBaseRC.translate(-r.left(), -r.top(), &fSubsetRC);
|
||||
(void)fSubsetRC.op(SkIRect::MakeWH(fDelta, fDelta),
|
||||
SkRegion::kIntersect_Op);
|
||||
(void)fSubsetRC.op(SkIRect::MakeWH(fDelta, fDelta), SkRegion::kIntersect_Op);
|
||||
}
|
||||
|
||||
fCurrBitmap = &fSubsetBitmap;
|
||||
fCurrDst = &fSubsetDst;
|
||||
fCurrRC = &fSubsetRC;
|
||||
return !fCurrRC->isEmpty();
|
||||
}
|
||||
@ -107,8 +102,8 @@ bool SkDeviceLooper::next() {
|
||||
|
||||
case kSimple_State:
|
||||
// first time for simple
|
||||
if (NULL == fCurrBitmap) {
|
||||
fCurrBitmap = &fBaseBitmap;
|
||||
if (NULL == fCurrDst) {
|
||||
fCurrDst = &fBaseDst;
|
||||
fCurrRC = &fBaseRC;
|
||||
fCurrOffset.set(0, 0);
|
||||
return true;
|
||||
|
@ -30,14 +30,13 @@
|
||||
*/
|
||||
class SkDeviceLooper {
|
||||
public:
|
||||
SkDeviceLooper(const SkBitmap& base, const SkRasterClip&,
|
||||
const SkIRect& bounds, bool aa);
|
||||
SkDeviceLooper(const SkPixmap& base, const SkRasterClip&, const SkIRect& bounds, bool aa);
|
||||
~SkDeviceLooper();
|
||||
|
||||
const SkBitmap& getBitmap() const {
|
||||
const SkPixmap& getPixmap() const {
|
||||
SkASSERT(kDone_State != fState);
|
||||
SkASSERT(fCurrBitmap);
|
||||
return *fCurrBitmap;
|
||||
SkASSERT(fCurrDst);
|
||||
return *fCurrDst;
|
||||
}
|
||||
|
||||
const SkRasterClip& getRC() const {
|
||||
@ -61,7 +60,7 @@ public:
|
||||
bool next();
|
||||
|
||||
private:
|
||||
const SkBitmap& fBaseBitmap;
|
||||
const SkPixmap& fBaseDst;
|
||||
const SkRasterClip& fBaseRC;
|
||||
|
||||
enum State {
|
||||
@ -71,10 +70,10 @@ private:
|
||||
};
|
||||
|
||||
// storage for our tiled versions. Perhaps could use SkTLazy
|
||||
SkBitmap fSubsetBitmap;
|
||||
SkPixmap fSubsetDst;
|
||||
SkRasterClip fSubsetRC;
|
||||
|
||||
const SkBitmap* fCurrBitmap;
|
||||
const SkPixmap* fCurrDst;
|
||||
const SkRasterClip* fCurrRC;
|
||||
SkIRect fClippedBounds;
|
||||
SkIPoint fCurrOffset;
|
||||
|
@ -44,20 +44,18 @@ public:
|
||||
SkAutoBlitterChoose() {
|
||||
fBlitter = NULL;
|
||||
}
|
||||
SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix,
|
||||
SkAutoBlitterChoose(const SkPixmap& dst, const SkMatrix& matrix,
|
||||
const SkPaint& paint, bool drawCoverage = false) {
|
||||
fBlitter = SkBlitter::Choose(device, matrix, paint, &fAllocator,
|
||||
drawCoverage);
|
||||
fBlitter = SkBlitter::Choose(dst, matrix, paint, &fAllocator, drawCoverage);
|
||||
}
|
||||
|
||||
|
||||
SkBlitter* operator->() { return fBlitter; }
|
||||
SkBlitter* get() const { return fBlitter; }
|
||||
|
||||
void choose(const SkBitmap& device, const SkMatrix& matrix,
|
||||
void choose(const SkPixmap& dst, const SkMatrix& matrix,
|
||||
const SkPaint& paint, bool drawCoverage = false) {
|
||||
SkASSERT(!fBlitter);
|
||||
fBlitter = SkBlitter::Choose(device, matrix, paint, &fAllocator,
|
||||
drawCoverage);
|
||||
fBlitter = SkBlitter::Choose(dst, matrix, paint, &fAllocator, drawCoverage);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -152,8 +150,7 @@ static void DA8_Src_BitmapXferProc(void* pixels, size_t bytes, uint32_t data) {
|
||||
memset(pixels, data, bytes);
|
||||
}
|
||||
|
||||
static BitmapXferProc ChooseBitmapXferProc(const SkBitmap& bitmap,
|
||||
const SkPaint& paint,
|
||||
static BitmapXferProc ChooseBitmapXferProc(const SkPixmap& dst, const SkPaint& paint,
|
||||
uint32_t* data) {
|
||||
// todo: we can apply colorfilter up front if no shader, so we wouldn't
|
||||
// need to abort this fastpath
|
||||
@ -190,7 +187,7 @@ static BitmapXferProc ChooseBitmapXferProc(const SkBitmap& bitmap,
|
||||
should I worry about dithering for the lower depths?
|
||||
*/
|
||||
SkPMColor pmc = SkPreMultiplyColor(color);
|
||||
switch (bitmap.colorType()) {
|
||||
switch (dst.colorType()) {
|
||||
case kN32_SkColorType:
|
||||
if (data) {
|
||||
*data = pmc;
|
||||
@ -220,10 +217,10 @@ static BitmapXferProc ChooseBitmapXferProc(const SkBitmap& bitmap,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void CallBitmapXferProc(const SkBitmap& bitmap, const SkIRect& rect,
|
||||
BitmapXferProc proc, uint32_t procData) {
|
||||
static void CallBitmapXferProc(const SkPixmap& dst, const SkIRect& rect, BitmapXferProc proc,
|
||||
uint32_t procData) {
|
||||
int shiftPerPixel;
|
||||
switch (bitmap.colorType()) {
|
||||
switch (dst.colorType()) {
|
||||
case kN32_SkColorType:
|
||||
shiftPerPixel = 2;
|
||||
break;
|
||||
@ -238,9 +235,9 @@ static void CallBitmapXferProc(const SkBitmap& bitmap, const SkIRect& rect,
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t* pixels = (uint8_t*)bitmap.getPixels();
|
||||
uint8_t* pixels = (uint8_t*)dst.writable_addr();
|
||||
SkASSERT(pixels);
|
||||
const size_t rowBytes = bitmap.rowBytes();
|
||||
const size_t rowBytes = dst.rowBytes();
|
||||
const int widthBytes = rect.width() << shiftPerPixel;
|
||||
|
||||
// skip down to the first scanline and X position
|
||||
@ -259,7 +256,7 @@ void SkDraw::drawPaint(const SkPaint& paint) const {
|
||||
}
|
||||
|
||||
SkIRect devRect;
|
||||
devRect.set(0, 0, fBitmap->width(), fBitmap->height());
|
||||
devRect.set(0, 0, fDst.width(), fDst.height());
|
||||
|
||||
if (fRC->isBW()) {
|
||||
/* If we don't have a shader (i.e. we're just a solid color) we may
|
||||
@ -269,7 +266,7 @@ void SkDraw::drawPaint(const SkPaint& paint) const {
|
||||
in the clip, we don't have to worry about antialiasing.
|
||||
*/
|
||||
uint32_t procData = 0; // to avoid the warning
|
||||
BitmapXferProc proc = ChooseBitmapXferProc(*fBitmap, paint, &procData);
|
||||
BitmapXferProc proc = ChooseBitmapXferProc(fDst, paint, &procData);
|
||||
if (proc) {
|
||||
if (D_Dst_BitmapXferProc == proc) { // nothing to do
|
||||
return;
|
||||
@ -277,7 +274,7 @@ void SkDraw::drawPaint(const SkPaint& paint) const {
|
||||
|
||||
SkRegion::Iterator iter(fRC->bwRgn());
|
||||
while (!iter.done()) {
|
||||
CallBitmapXferProc(*fBitmap, iter.rect(), proc, procData);
|
||||
CallBitmapXferProc(fDst, iter.rect(), proc, procData);
|
||||
iter.next();
|
||||
}
|
||||
return;
|
||||
@ -285,7 +282,7 @@ void SkDraw::drawPaint(const SkPaint& paint) const {
|
||||
}
|
||||
|
||||
// normal case: use a blitter
|
||||
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
|
||||
SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
|
||||
SkScan::FillIRect(devRect, *fRC, blitter.get());
|
||||
}
|
||||
|
||||
@ -331,11 +328,11 @@ static void bw_pt_rect_16_hair_proc(const PtProcRec& rec,
|
||||
SkASSERT(rec.fRC->isRect());
|
||||
const SkIRect& r = rec.fRC->getBounds();
|
||||
uint32_t value;
|
||||
const SkBitmap* bitmap = blitter->justAnOpaqueColor(&value);
|
||||
SkASSERT(bitmap);
|
||||
const SkPixmap* dst = blitter->justAnOpaqueColor(&value);
|
||||
SkASSERT(dst);
|
||||
|
||||
uint16_t* addr = bitmap->getAddr16(0, 0);
|
||||
size_t rb = bitmap->rowBytes();
|
||||
uint16_t* addr = dst->writable_addr16(0, 0);
|
||||
size_t rb = dst->rowBytes();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = SkScalarFloorToInt(devPts[i].fX);
|
||||
@ -352,11 +349,11 @@ static void bw_pt_rect_32_hair_proc(const PtProcRec& rec,
|
||||
SkASSERT(rec.fRC->isRect());
|
||||
const SkIRect& r = rec.fRC->getBounds();
|
||||
uint32_t value;
|
||||
const SkBitmap* bitmap = blitter->justAnOpaqueColor(&value);
|
||||
SkASSERT(bitmap);
|
||||
const SkPixmap* dst = blitter->justAnOpaqueColor(&value);
|
||||
SkASSERT(dst);
|
||||
|
||||
SkPMColor* addr = bitmap->getAddr32(0, 0);
|
||||
size_t rb = bitmap->rowBytes();
|
||||
SkPMColor* addr = dst->writable_addr32(0, 0);
|
||||
size_t rb = dst->rowBytes();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = SkScalarFloorToInt(devPts[i].fX);
|
||||
@ -512,7 +509,7 @@ PtProcRec::Proc PtProcRec::chooseProc(SkBlitter** blitterPtr) {
|
||||
if (fRadius <= SK_FixedHalf) { // small radii and hairline
|
||||
if (SkCanvas::kPoints_PointMode == fMode && fClip->isRect()) {
|
||||
uint32_t value;
|
||||
const SkBitmap* bm = blitter->justAnOpaqueColor(&value);
|
||||
const SkPixmap* bm = blitter->justAnOpaqueColor(&value);
|
||||
if (bm && kRGB_565_SkColorType == bm->colorType()) {
|
||||
proc = bw_pt_rect_16_hair_proc;
|
||||
} else if (bm && kN32_SkColorType == bm->colorType()) {
|
||||
@ -559,7 +556,7 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
|
||||
|
||||
PtProcRec rec;
|
||||
if (!forceUseDevice && rec.init(mode, paint, fMatrix, fRC)) {
|
||||
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
|
||||
SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
|
||||
|
||||
SkPoint devPts[MAX_DEV_PTS];
|
||||
const SkMatrix* matrix = fMatrix;
|
||||
@ -853,14 +850,14 @@ void SkDraw::drawRect(const SkRect& prePaintRect, const SkPaint& paint,
|
||||
return;
|
||||
}
|
||||
|
||||
SkDeviceLooper looper(*fBitmap, *fRC, ir, paint.isAntiAlias());
|
||||
SkDeviceLooper looper(fDst, *fRC, ir, paint.isAntiAlias());
|
||||
while (looper.next()) {
|
||||
SkRect localDevRect;
|
||||
looper.mapRect(&localDevRect, devRect);
|
||||
SkMatrix localMatrix;
|
||||
looper.mapMatrix(&localMatrix, *matrix);
|
||||
|
||||
SkAutoBlitterChoose blitterStorage(looper.getBitmap(), localMatrix, paint);
|
||||
SkAutoBlitterChoose blitterStorage(looper.getPixmap(), localMatrix, paint);
|
||||
const SkRasterClip& clip = looper.getRC();
|
||||
SkBlitter* blitter = blitterStorage.get();
|
||||
|
||||
@ -911,7 +908,7 @@ void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const {
|
||||
}
|
||||
SkAutoMaskFreeImage ami(dstM.fImage);
|
||||
|
||||
SkAutoBlitterChoose blitterChooser(*fBitmap, *fMatrix, paint);
|
||||
SkAutoBlitterChoose blitterChooser(fDst, *fMatrix, paint);
|
||||
SkBlitter* blitter = blitterChooser.get();
|
||||
|
||||
SkAAClipBlitterWrapper wrapper;
|
||||
@ -989,7 +986,7 @@ void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const {
|
||||
// Transform the rrect into device space.
|
||||
SkRRect devRRect;
|
||||
if (rrect.transform(*fMatrix, &devRRect)) {
|
||||
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
|
||||
SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
|
||||
if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, blitter.get(),
|
||||
SkPaint::kFill_Style)) {
|
||||
return; // filterRRect() called the blitter, so we're done
|
||||
@ -1108,7 +1105,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
|
||||
SkBlitter* blitter = NULL;
|
||||
SkAutoBlitterChoose blitterStorage;
|
||||
if (NULL == customBlitter) {
|
||||
blitterStorage.choose(*fBitmap, *fMatrix, *paint, drawCoverage);
|
||||
blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage);
|
||||
blitter = blitterStorage.get();
|
||||
} else {
|
||||
blitter = customBlitter;
|
||||
@ -1182,7 +1179,7 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
|
||||
// clipped to the actual device
|
||||
{
|
||||
SkIRect devBounds;
|
||||
devBounds.set(0, 0, fBitmap->width(), fBitmap->height());
|
||||
devBounds.set(0, 0, fDst.width(), fDst.height());
|
||||
// need intersect(l, t, r, b) on irect
|
||||
if (!mask.fBounds.intersect(devBounds)) {
|
||||
return;
|
||||
@ -1280,13 +1277,9 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
|
||||
int ix = SkScalarRoundToInt(matrix.getTranslateX());
|
||||
int iy = SkScalarRoundToInt(matrix.getTranslateY());
|
||||
if (clipHandlesSprite(*fRC, ix, iy, pmap)) {
|
||||
SkPixmap dstPM;
|
||||
if (!fBitmap->peekPixels(&dstPM)) {
|
||||
return;
|
||||
}
|
||||
SkTBlitterAllocator allocator;
|
||||
// blitter will be owned by the allocator.
|
||||
SkBlitter* blitter = SkBlitter::ChooseSprite(dstPM, paint, pmap, ix, iy, &allocator);
|
||||
SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, ix, iy, &allocator);
|
||||
if (blitter) {
|
||||
SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.height()),
|
||||
*fRC, blitter);
|
||||
@ -1341,13 +1334,9 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& ori
|
||||
const SkPixmap& pmap = unlocker.pixmap();
|
||||
|
||||
if (NULL == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, pmap)) {
|
||||
SkPixmap dstPM;
|
||||
if (!fBitmap->peekPixels(&dstPM)) {
|
||||
return;
|
||||
}
|
||||
SkTBlitterAllocator allocator;
|
||||
// blitter will be owned by the allocator.
|
||||
SkBlitter* blitter = SkBlitter::ChooseSprite(dstPM, paint, pmap, x, y, &allocator);
|
||||
SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, x, y, &allocator);
|
||||
if (blitter) {
|
||||
SkScan::FillIRect(bounds, *fRC, blitter);
|
||||
return;
|
||||
@ -1646,7 +1635,7 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
||||
SkAutoBlitterChoose blitterChooser;
|
||||
SkBlitter* blitter = NULL;
|
||||
if (needsRasterTextBlit(*this)) {
|
||||
blitterChooser.choose(*fBitmap, *fMatrix, paint);
|
||||
blitterChooser.choose(fDst, *fMatrix, paint);
|
||||
blitter = blitterChooser.get();
|
||||
if (fRC->isAA()) {
|
||||
aaBlitter.init(blitter, &fRC->aaRgn());
|
||||
@ -1765,7 +1754,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
|
||||
SkAutoBlitterChoose blitterChooser;
|
||||
SkBlitter* blitter = NULL;
|
||||
if (needsRasterTextBlit(*this)) {
|
||||
blitterChooser.choose(*fBitmap, *fMatrix, paint);
|
||||
blitterChooser.choose(fDst, *fMatrix, paint);
|
||||
blitter = blitterChooser.get();
|
||||
if (fRC->isAA()) {
|
||||
wrapper.init(*fRC, blitter);
|
||||
@ -2095,7 +2084,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
|
||||
}
|
||||
}
|
||||
|
||||
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, p);
|
||||
SkAutoBlitterChoose blitter(fDst, *fMatrix, p);
|
||||
// Abort early if we failed to create a shader context.
|
||||
if (blitter->isNullBlitter()) {
|
||||
return;
|
||||
@ -2166,7 +2155,6 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
|
||||
#ifdef SK_DEBUG
|
||||
|
||||
void SkDraw::validate() const {
|
||||
SkASSERT(fBitmap != NULL);
|
||||
SkASSERT(fMatrix != NULL);
|
||||
SkASSERT(fClip != NULL);
|
||||
SkASSERT(fRC != NULL);
|
||||
@ -2174,7 +2162,7 @@ void SkDraw::validate() const {
|
||||
const SkIRect& cr = fRC->getBounds();
|
||||
SkIRect br;
|
||||
|
||||
br.set(0, 0, fBitmap->width(), fBitmap->height());
|
||||
br.set(0, 0, fDst.width(), fDst.height());
|
||||
SkASSERT(cr.isEmpty() || br.contains(cr));
|
||||
}
|
||||
|
||||
@ -2230,22 +2218,20 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
|
||||
SkPaint::Style style) {
|
||||
SkBitmap bm;
|
||||
SkDraw draw;
|
||||
static void draw_into_mask(const SkMask& mask, const SkPath& devPath, SkPaint::Style style) {
|
||||
SkDraw draw;
|
||||
if (!draw.fDst.reset(mask)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkRasterClip clip;
|
||||
SkMatrix matrix;
|
||||
SkPaint paint;
|
||||
|
||||
bm.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), mask.fBounds.height()),
|
||||
mask.fImage, mask.fRowBytes);
|
||||
|
||||
clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height()));
|
||||
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
|
||||
-SkIntToScalar(mask.fBounds.fTop));
|
||||
|
||||
draw.fBitmap = &bm;
|
||||
draw.fRC = &clip;
|
||||
draw.fClip = &clip.bwRgn();
|
||||
draw.fMatrix = &matrix;
|
||||
|
@ -248,7 +248,7 @@ static void applyLUTToA8Mask(const SkMask& mask, const uint8_t* lut) {
|
||||
}
|
||||
|
||||
template<bool APPLY_PREBLEND>
|
||||
static void pack4xHToLCD16(const SkBitmap& src, const SkMask& dst,
|
||||
static void pack4xHToLCD16(const SkPixmap& src, const SkMask& dst,
|
||||
const SkMaskGamma::PreBlend& maskPreBlend) {
|
||||
#define SAMPLES_PER_PIXEL 4
|
||||
#define LCD_PER_PIXEL 3
|
||||
@ -291,7 +291,7 @@ static void pack4xHToLCD16(const SkBitmap& src, const SkMask& dst,
|
||||
};
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
const uint8_t* srcP = src.getAddr8(0, y);
|
||||
const uint8_t* srcP = src.addr8(0, y);
|
||||
|
||||
// TODO: this fir filter implementation is straight forward, but slow.
|
||||
// It should be possible to make it much faster.
|
||||
@ -406,29 +406,29 @@ static void generateMask(const SkMask& mask, const SkPath& path,
|
||||
clip.setRect(SkIRect::MakeWH(dstW, dstH));
|
||||
|
||||
const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
|
||||
SkBitmap bm;
|
||||
SkAutoPixmapStorage dst;
|
||||
|
||||
if (0 == dstRB) {
|
||||
if (!bm.tryAllocPixels(info)) {
|
||||
if (!dst.tryAlloc(info)) {
|
||||
// can't allocate offscreen, so empty the mask and return
|
||||
sk_bzero(mask.fImage, mask.computeImageSize());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
bm.installPixels(info, mask.fImage, dstRB);
|
||||
dst.reset(info, mask.fImage, dstRB);
|
||||
}
|
||||
sk_bzero(bm.getPixels(), bm.getSafeSize());
|
||||
sk_bzero(dst.writable_addr(), dst.getSafeSize());
|
||||
|
||||
SkDraw draw;
|
||||
draw.fDst = dst;
|
||||
draw.fRC = &clip;
|
||||
draw.fClip = &clip.bwRgn();
|
||||
draw.fMatrix = &matrix;
|
||||
draw.fBitmap = &bm;
|
||||
draw.drawPath(path, paint);
|
||||
|
||||
switch (mask.fFormat) {
|
||||
case SkMask::kBW_Format:
|
||||
packA8ToA1(mask, bm.getAddr8(0, 0), bm.rowBytes());
|
||||
packA8ToA1(mask, dst.addr8(0, 0), dst.rowBytes());
|
||||
break;
|
||||
case SkMask::kA8_Format:
|
||||
if (maskPreBlend.isApplicable()) {
|
||||
@ -437,9 +437,9 @@ static void generateMask(const SkMask& mask, const SkPath& path,
|
||||
break;
|
||||
case SkMask::kLCD16_Format:
|
||||
if (maskPreBlend.isApplicable()) {
|
||||
pack4xHToLCD16<true>(bm, mask, maskPreBlend);
|
||||
pack4xHToLCD16<true>(dst, mask, maskPreBlend);
|
||||
} else {
|
||||
pack4xHToLCD16<false>(bm, mask, maskPreBlend);
|
||||
pack4xHToLCD16<false>(dst, mask, maskPreBlend);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -344,7 +344,7 @@ public:
|
||||
void blitMask(const SkMask&, const SkIRect& clip) override {
|
||||
SkDEBUGFAIL("blitMask unexpected");
|
||||
}
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override {
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override {
|
||||
SkDEBUGFAIL("justAnOpaqueColor unexpected");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -116,9 +116,12 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
|
||||
}
|
||||
|
||||
if (SkMask::kJustComputeBounds_CreateMode != mode) {
|
||||
SkBitmap device;
|
||||
SkRasterClip rectClip;
|
||||
SkDraw draw;
|
||||
if (!draw.fDst.reset(*mask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkRasterClip rectClip;
|
||||
SkMatrix translatedMatrix; // this translates us to our local pixels
|
||||
SkMatrix drawMatrix; // this translates the path by each layer's offset
|
||||
|
||||
@ -128,9 +131,6 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
|
||||
translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft),
|
||||
-SkIntToScalar(mask->fBounds.fTop));
|
||||
|
||||
device.installMaskPixels(*mask);
|
||||
|
||||
draw.fBitmap = &device;
|
||||
draw.fMatrix = &drawMatrix;
|
||||
draw.fRC = &rectClip;
|
||||
draw.fClip = &rectClip.bwRgn();
|
||||
|
@ -354,14 +354,12 @@ private:
|
||||
SkIRect pathBounds = SkIRect::MakeWH(devPathBounds.width(),
|
||||
devPathBounds.height());
|
||||
|
||||
SkBitmap bmp;
|
||||
const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(pathBounds.fRight,
|
||||
pathBounds.fBottom);
|
||||
if (!bmp.tryAllocPixels(bmImageInfo)) {
|
||||
SkAutoPixmapStorage dst;
|
||||
if (!dst.tryAlloc(SkImageInfo::MakeA8(pathBounds.width(),
|
||||
pathBounds.height()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_bzero(bmp.getPixels(), bmp.getSafeSize());
|
||||
sk_bzero(dst.writable_addr(), dst.getSafeSize());
|
||||
|
||||
// rasterize path
|
||||
SkPaint paint;
|
||||
@ -388,7 +386,7 @@ private:
|
||||
draw.fRC = &rasterClip;
|
||||
draw.fClip = &rasterClip.bwRgn();
|
||||
draw.fMatrix = &drawMatrix;
|
||||
draw.fBitmap = &bmp;
|
||||
draw.fDst = dst;
|
||||
|
||||
draw.drawPathCoverage(path, paint);
|
||||
|
||||
@ -400,13 +398,9 @@ private:
|
||||
SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
|
||||
|
||||
// Generate signed distance field
|
||||
{
|
||||
SkAutoLockPixels alp(bmp);
|
||||
|
||||
SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
|
||||
(const unsigned char*)bmp.getPixels(),
|
||||
bmp.width(), bmp.height(), bmp.rowBytes());
|
||||
}
|
||||
SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
|
||||
(const unsigned char*)dst.addr(),
|
||||
dst.width(), dst.height(), dst.rowBytes());
|
||||
|
||||
// add to atlas
|
||||
SkIPoint16 atlasLocation;
|
||||
|
@ -146,7 +146,8 @@ void GrSWMaskHelper::draw(const SkPath& path, const SkStrokeRec& stroke, SkRegio
|
||||
if (kBlitter_CompressionMode == fCompressionMode) {
|
||||
SkASSERT(fCompressedBuffer.get());
|
||||
blitter = SkTextureCompressor::CreateBlitterForFormat(
|
||||
fBM.width(), fBM.height(), fCompressedBuffer.get(), &allocator, fCompressedFormat);
|
||||
fPixels.width(), fPixels.height(), fCompressedBuffer.get(), &allocator,
|
||||
fCompressedFormat);
|
||||
}
|
||||
|
||||
if (SkRegion::kReplace_Op == op && 0xFF == alpha) {
|
||||
@ -202,28 +203,26 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds,
|
||||
}
|
||||
}
|
||||
|
||||
sk_bzero(&fDraw, sizeof(fDraw));
|
||||
|
||||
// If we don't have a custom blitter, then we either need a bitmap to compress
|
||||
// from or a bitmap that we're going to use as a texture. In any case, we should
|
||||
// allocate the pixels for a bitmap
|
||||
const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(cmpWidth, cmpHeight);
|
||||
if (kBlitter_CompressionMode != fCompressionMode) {
|
||||
if (!fBM.tryAllocPixels(bmImageInfo)) {
|
||||
if (!fPixels.tryAlloc(bmImageInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_bzero(fBM.getPixels(), fBM.getSafeSize());
|
||||
fPixels.erase(0);
|
||||
} else {
|
||||
// Otherwise, we just need to remember how big the buffer is...
|
||||
fBM.setInfo(bmImageInfo);
|
||||
fPixels.reset(bmImageInfo);
|
||||
}
|
||||
|
||||
sk_bzero(&fDraw, sizeof(fDraw));
|
||||
|
||||
fDraw.fDst = fPixels;
|
||||
fRasterClip.setRect(bounds);
|
||||
fDraw.fRC = &fRasterClip;
|
||||
fDraw.fClip = &fRasterClip.bwRgn();
|
||||
fDraw.fMatrix = &fMatrix;
|
||||
fDraw.fBitmap = &fBM;
|
||||
fDraw.fRC = &fRasterClip;
|
||||
fDraw.fClip = &fRasterClip.bwRgn();
|
||||
fDraw.fMatrix = &fMatrix;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -232,8 +231,8 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds,
|
||||
*/
|
||||
GrTexture* GrSWMaskHelper::createTexture() {
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = fBM.width();
|
||||
desc.fHeight = fBM.height();
|
||||
desc.fWidth = fPixels.width();
|
||||
desc.fHeight = fPixels.height();
|
||||
desc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
|
||||
if (kNone_CompressionMode != fCompressionMode) {
|
||||
@ -273,7 +272,8 @@ void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc
|
||||
SkASSERT(GrPixelConfigIsCompressed(desc.fConfig));
|
||||
SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig);
|
||||
|
||||
SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fBM, fCompressedFormat));
|
||||
SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fPixels,
|
||||
fCompressedFormat));
|
||||
SkASSERT(cmpData);
|
||||
|
||||
this->sendTextureData(texture, desc, cmpData->data(), 0);
|
||||
@ -283,17 +283,15 @@ void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc
|
||||
* Move the result of the software mask generation back to the gpu
|
||||
*/
|
||||
void GrSWMaskHelper::toTexture(GrTexture *texture) {
|
||||
SkAutoLockPixels alp(fBM);
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = fBM.width();
|
||||
desc.fHeight = fBM.height();
|
||||
desc.fWidth = fPixels.width();
|
||||
desc.fHeight = fPixels.height();
|
||||
desc.fConfig = texture->config();
|
||||
|
||||
// First see if we should compress this texture before uploading.
|
||||
switch (fCompressionMode) {
|
||||
case kNone_CompressionMode:
|
||||
this->sendTextureData(texture, desc, fBM.getPixels(), fBM.rowBytes());
|
||||
this->sendTextureData(texture, desc, fPixels.addr(), fPixels.rowBytes());
|
||||
break;
|
||||
|
||||
case kCompress_CompressionMode:
|
||||
@ -311,10 +309,8 @@ void GrSWMaskHelper::toTexture(GrTexture *texture) {
|
||||
* Convert mask generation results to a signed distance field
|
||||
*/
|
||||
void GrSWMaskHelper::toSDF(unsigned char* sdf) {
|
||||
SkAutoLockPixels alp(fBM);
|
||||
|
||||
SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fBM.getPixels(),
|
||||
fBM.width(), fBM.height(), fBM.rowBytes());
|
||||
SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr(),
|
||||
fPixels.width(), fPixels.height(), fPixels.rowBytes());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
// Reset the internal bitmap
|
||||
void clear(uint8_t alpha) {
|
||||
fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
|
||||
fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
|
||||
// Canonical usage utility that draws a single path and uploads it
|
||||
@ -105,7 +105,7 @@ private:
|
||||
|
||||
GrContext* fContext;
|
||||
SkMatrix fMatrix;
|
||||
SkBitmap fBM;
|
||||
SkAutoPixmapStorage fPixels;
|
||||
SkDraw fDraw;
|
||||
SkRasterClip fRasterClip;
|
||||
|
||||
|
@ -173,19 +173,17 @@ bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcCol
|
||||
return false;
|
||||
}
|
||||
|
||||
SkData* CompressBitmapToFormat(const SkBitmap &bitmap, Format format) {
|
||||
SkAutoLockPixels alp(bitmap);
|
||||
|
||||
int compressedDataSize = GetCompressedDataSize(format, bitmap.width(), bitmap.height());
|
||||
SkData* CompressBitmapToFormat(const SkPixmap& pixmap, Format format) {
|
||||
int compressedDataSize = GetCompressedDataSize(format, pixmap.width(), pixmap.height());
|
||||
if (compressedDataSize < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const uint8_t* src = reinterpret_cast<const uint8_t*>(bitmap.getPixels());
|
||||
const uint8_t* src = reinterpret_cast<const uint8_t*>(pixmap.addr());
|
||||
SkData* dst = SkData::NewUninitialized(compressedDataSize);
|
||||
|
||||
if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, bitmap.colorType(),
|
||||
bitmap.width(), bitmap.height(), bitmap.rowBytes(), format)) {
|
||||
if (!CompressBufferToFormat((uint8_t*)dst->writable_data(), src, pixmap.colorType(),
|
||||
pixmap.width(), pixmap.height(), pixmap.rowBytes(), format)) {
|
||||
dst->unref();
|
||||
dst = NULL;
|
||||
}
|
||||
|
@ -55,10 +55,10 @@ namespace SkTextureCompressor {
|
||||
int GetCompressedDataSize(Format fmt, int width, int height);
|
||||
|
||||
// Returns an SkData holding a blob of compressed data that corresponds
|
||||
// to the bitmap. If the bitmap colorType cannot be compressed using the
|
||||
// to the pixmap. If the pixmap colorType cannot be compressed using the
|
||||
// associated format, then we return NULL. The caller is responsible for
|
||||
// calling unref() on the returned data.
|
||||
SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format);
|
||||
SkData* CompressBitmapToFormat(const SkPixmap&, Format format);
|
||||
|
||||
// Compresses the given src data into dst. The src data is assumed to be
|
||||
// large enough to hold width*height pixels. The dst data is expected to
|
||||
|
@ -368,7 +368,7 @@ public:
|
||||
// If the blitter just sets a single value for each pixel, return the
|
||||
// bitmap it draws into, and assign value. If not, return NULL and ignore
|
||||
// the value parameter.
|
||||
const SkBitmap* justAnOpaqueColor(uint32_t* value) override {
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,8 @@
|
||||
#include "SkRasterClip.h"
|
||||
#include "Test.h"
|
||||
|
||||
static void make_bm(SkBitmap* bm, int w, int h) {
|
||||
bm->allocPixels(SkImageInfo::Make(w, h, kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType));
|
||||
static void make_pm(SkAutoPixmapStorage* pixmap, int w, int h) {
|
||||
pixmap->alloc(SkImageInfo::Make(w, h, kAlpha_8_SkColorType, kPremul_SkAlphaType));
|
||||
}
|
||||
|
||||
static bool equal(const SkRasterClip& a, const SkRasterClip& b) {
|
||||
@ -40,19 +39,19 @@ static const struct {
|
||||
static void test_simple(skiatest::Reporter* reporter) {
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
||||
SkBitmap bitmap;
|
||||
make_bm(&bitmap, gRec[i].fDevSize.width(), gRec[i].fDevSize.height());
|
||||
SkAutoPixmapStorage pmap;
|
||||
make_pm(&pmap, gRec[i].fDevSize.width(), gRec[i].fDevSize.height());
|
||||
|
||||
SkRasterClip rc(gRec[i].fRCBounds);
|
||||
|
||||
for (int aa = 0; aa <= 1; ++aa) {
|
||||
SkDeviceLooper looper(bitmap, rc, gRec[i].fRect, SkToBool(aa));
|
||||
SkDeviceLooper looper(pmap, rc, gRec[i].fRect, SkToBool(aa));
|
||||
|
||||
bool valid = looper.next();
|
||||
REPORTER_ASSERT(reporter, valid);
|
||||
if (valid) {
|
||||
REPORTER_ASSERT(reporter, looper.getBitmap().width() == bitmap.width());
|
||||
REPORTER_ASSERT(reporter, looper.getBitmap().height() == bitmap.height());
|
||||
REPORTER_ASSERT(reporter, looper.getPixmap().width() == pmap.width());
|
||||
REPORTER_ASSERT(reporter, looper.getPixmap().height() == pmap.height());
|
||||
REPORTER_ASSERT(reporter, equal(looper.getRC(), rc));
|
||||
|
||||
REPORTER_ASSERT(reporter, !looper.next());
|
||||
@ -62,7 +61,7 @@ static void test_simple(skiatest::Reporter* reporter) {
|
||||
{
|
||||
SkIRect r = rc.getBounds();
|
||||
r.offset(r.width(), 0);
|
||||
SkDeviceLooper looper(bitmap, rc, r, false);
|
||||
SkDeviceLooper looper(pmap, rc, r, false);
|
||||
REPORTER_ASSERT(reporter, !looper.next());
|
||||
}
|
||||
}
|
||||
@ -109,8 +108,8 @@ static void test_complex(skiatest::Reporter* reporter) {
|
||||
const int w = gRec[i].fSize.width();
|
||||
const int h = gRec[i].fSize.height();
|
||||
|
||||
SkBitmap bitmap;
|
||||
make_bm(&bitmap, w, h);
|
||||
SkAutoPixmapStorage pmap;
|
||||
make_pm(&pmap, w, h);
|
||||
|
||||
const SkIRect rect = SkIRect::MakeWH(w, h);
|
||||
|
||||
@ -125,7 +124,7 @@ static void test_complex(skiatest::Reporter* reporter) {
|
||||
SkRasterClip rc;
|
||||
rc.op(rgn, SkRegion::kReplace_Op);
|
||||
|
||||
SkDeviceLooper looper(bitmap, rc, rect, gRec[i].fAA);
|
||||
SkDeviceLooper looper(pmap, rc, rect, gRec[i].fAA);
|
||||
while (looper.next()) {
|
||||
REPORTER_ASSERT(reporter, !looper.getRC().isEmpty());
|
||||
}
|
||||
|
@ -42,10 +42,8 @@ static bool compresses_a8(SkTextureCompressor::Format fmt) {
|
||||
* Make sure that we properly fail when we don't have multiple of four image dimensions.
|
||||
*/
|
||||
DEF_TEST(CompressAlphaFailDimensions, reporter) {
|
||||
SkBitmap bitmap;
|
||||
static const int kWidth = 17;
|
||||
static const int kHeight = 17;
|
||||
SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight);
|
||||
|
||||
// R11_EAC and LATC are both dimensions of 4, so we need to make sure that we
|
||||
// are violating those assumptions. And if we are, then we're also violating the
|
||||
@ -55,18 +53,16 @@ DEF_TEST(CompressAlphaFailDimensions, reporter) {
|
||||
REPORTER_ASSERT(reporter, kWidth % 4 != 0);
|
||||
REPORTER_ASSERT(reporter, kHeight % 4 != 0);
|
||||
|
||||
bool setInfoSuccess = bitmap.setInfo(info);
|
||||
REPORTER_ASSERT(reporter, setInfoSuccess);
|
||||
|
||||
bitmap.allocPixels(info);
|
||||
bitmap.unlockPixels();
|
||||
SkAutoPixmapStorage pixmap;
|
||||
pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
|
||||
// leaving the pixels uninitialized, as they don't affect the test...
|
||||
|
||||
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) {
|
||||
const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor::Format>(i);
|
||||
if (!compresses_a8(fmt)) {
|
||||
continue;
|
||||
}
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt));
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt));
|
||||
REPORTER_ASSERT(reporter, NULL == data);
|
||||
}
|
||||
}
|
||||
@ -76,10 +72,8 @@ DEF_TEST(CompressAlphaFailDimensions, reporter) {
|
||||
* compressed textures can (currently) only be created from A8 bitmaps.
|
||||
*/
|
||||
DEF_TEST(CompressAlphaFailColorType, reporter) {
|
||||
SkBitmap bitmap;
|
||||
static const int kWidth = 12;
|
||||
static const int kHeight = 12;
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
|
||||
|
||||
// ASTC is at most 12x12, and any dimension divisible by 12 is also divisible
|
||||
// by 4, which is the dimensions of R11_EAC and LATC. In the future, we might
|
||||
@ -88,18 +82,16 @@ DEF_TEST(CompressAlphaFailColorType, reporter) {
|
||||
REPORTER_ASSERT(reporter, kWidth % 12 == 0);
|
||||
REPORTER_ASSERT(reporter, kHeight % 12 == 0);
|
||||
|
||||
bool setInfoSuccess = bitmap.setInfo(info);
|
||||
REPORTER_ASSERT(reporter, setInfoSuccess);
|
||||
|
||||
bitmap.allocPixels(info);
|
||||
bitmap.unlockPixels();
|
||||
SkAutoPixmapStorage pixmap;
|
||||
pixmap.alloc(SkImageInfo::MakeN32Premul(kWidth, kHeight));
|
||||
// leaving the pixels uninitialized, as they don't affect the test...
|
||||
|
||||
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) {
|
||||
const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor::Format>(i);
|
||||
if (!compresses_a8(fmt)) {
|
||||
continue;
|
||||
}
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt));
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt));
|
||||
REPORTER_ASSERT(reporter, NULL == data);
|
||||
}
|
||||
}
|
||||
@ -109,10 +101,8 @@ DEF_TEST(CompressAlphaFailColorType, reporter) {
|
||||
* then decompress it, you get what you started with.
|
||||
*/
|
||||
DEF_TEST(CompressCheckerboard, reporter) {
|
||||
SkBitmap bitmap;
|
||||
static const int kWidth = 48; // We need the number to be divisible by both
|
||||
static const int kHeight = 48; // 12 (ASTC) and 16 (ARM NEON R11 EAC).
|
||||
SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight);
|
||||
|
||||
// ASTC is at most 12x12, and any dimension divisible by 12 is also divisible
|
||||
// by 4, which is the dimensions of R11_EAC and LATC. In the future, we might
|
||||
@ -123,17 +113,12 @@ DEF_TEST(CompressCheckerboard, reporter) {
|
||||
REPORTER_ASSERT(reporter, kWidth % 48 == 0);
|
||||
REPORTER_ASSERT(reporter, kHeight % 48 == 0);
|
||||
|
||||
bool setInfoSuccess = bitmap.setInfo(info);
|
||||
REPORTER_ASSERT(reporter, setInfoSuccess);
|
||||
SkAutoPixmapStorage pixmap;
|
||||
pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
|
||||
|
||||
bitmap.allocPixels(info);
|
||||
bitmap.unlockPixels();
|
||||
|
||||
// Populate bitmap
|
||||
// Populate the pixels
|
||||
{
|
||||
SkAutoLockPixels alp(bitmap);
|
||||
|
||||
uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels());
|
||||
uint8_t* pixels = reinterpret_cast<uint8_t*>(pixmap.writable_addr());
|
||||
REPORTER_ASSERT(reporter, pixels);
|
||||
if (NULL == pixels) {
|
||||
return;
|
||||
@ -147,7 +132,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
|
||||
pixels[x] = 0;
|
||||
}
|
||||
}
|
||||
pixels += bitmap.rowBytes();
|
||||
pixels += pixmap.rowBytes();
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +152,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt));
|
||||
SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt));
|
||||
REPORTER_ASSERT(reporter, data);
|
||||
if (NULL == data) {
|
||||
continue;
|
||||
@ -180,8 +165,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
|
||||
kWidth, kHeight, fmt);
|
||||
REPORTER_ASSERT(reporter, decompResult);
|
||||
|
||||
SkAutoLockPixels alp(bitmap);
|
||||
uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels());
|
||||
const uint8_t* pixels = reinterpret_cast<const uint8_t*>(pixmap.addr());
|
||||
REPORTER_ASSERT(reporter, pixels);
|
||||
if (NULL == pixels) {
|
||||
continue;
|
||||
@ -189,7 +173,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
|
||||
|
||||
for (int y = 0; y < kHeight; ++y) {
|
||||
for (int x = 0; x < kWidth; ++x) {
|
||||
bool ok = pixels[y*bitmap.rowBytes() + x] == decompBuffer[y*kWidth + x];
|
||||
bool ok = pixels[y*pixmap.rowBytes() + x] == decompBuffer[y*kWidth + x];
|
||||
REPORTER_ASSERT(reporter, ok);
|
||||
}
|
||||
}
|
||||
@ -204,16 +188,11 @@ DEF_TEST(CompressLATC, reporter) {
|
||||
const SkTextureCompressor::Format kLATCFormat = SkTextureCompressor::kLATC_Format;
|
||||
static const int kLATCEncodedBlockSize = 8;
|
||||
|
||||
SkBitmap bitmap;
|
||||
static const int kWidth = 8;
|
||||
static const int kHeight = 8;
|
||||
SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight);
|
||||
|
||||
bool setInfoSuccess = bitmap.setInfo(info);
|
||||
REPORTER_ASSERT(reporter, setInfoSuccess);
|
||||
|
||||
bitmap.allocPixels(info);
|
||||
bitmap.unlockPixels();
|
||||
SkAutoPixmapStorage pixmap;
|
||||
pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
|
||||
|
||||
int latcDimX, latcDimY;
|
||||
SkTextureCompressor::GetBlockDimensions(kLATCFormat, &latcDimX, &latcDimY);
|
||||
@ -226,21 +205,13 @@ DEF_TEST(CompressLATC, reporter) {
|
||||
REPORTER_ASSERT(reporter, (kSizeToBe % kLATCEncodedBlockSize) == 0);
|
||||
|
||||
for (int lum = 0; lum < 256; ++lum) {
|
||||
bitmap.lockPixels();
|
||||
uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels());
|
||||
REPORTER_ASSERT(reporter, pixels);
|
||||
if (NULL == pixels) {
|
||||
bitmap.unlockPixels();
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t* pixels = reinterpret_cast<uint8_t*>(pixmap.writable_addr());
|
||||
for (int i = 0; i < kWidth*kHeight; ++i) {
|
||||
pixels[i] = lum;
|
||||
}
|
||||
bitmap.unlockPixels();
|
||||
|
||||
SkAutoDataUnref latcData(
|
||||
SkTextureCompressor::CompressBitmapToFormat(bitmap, kLATCFormat));
|
||||
SkTextureCompressor::CompressBitmapToFormat(pixmap, kLATCFormat));
|
||||
REPORTER_ASSERT(reporter, latcData);
|
||||
if (NULL == latcData) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user