remove SkDeviceProperties

There is a lot more clean up to do here but this is probably a big enough bite.

Review URL: https://codereview.chromium.org/1196683003
This commit is contained in:
robertphillips 2015-06-19 11:49:52 -07:00 committed by Commit bot
parent 97c595f304
commit fcf7829b67
28 changed files with 142 additions and 191 deletions

View File

@ -75,7 +75,6 @@
'<(skia_src_path)/core/SkDevice.cpp',
'<(skia_src_path)/core/SkDeviceLooper.cpp',
'<(skia_src_path)/core/SkDeviceProfile.cpp',
'<(skia_src_path)/core/SkDeviceProperties.h',
'<(skia_src_path)/lazy/SkDiscardableMemoryPool.cpp',
'<(skia_src_path)/lazy/SkDiscardablePixelRef.cpp',
'<(skia_src_path)/core/SkDistanceFieldGen.cpp',

View File

@ -22,14 +22,15 @@ public:
* any drawing to this device will have no effect.
*/
SkBitmapDevice(const SkBitmap& bitmap);
private:
protected:
/**
* Construct a new device with the specified bitmap as its backend. It is
* valid for the bitmap to have no pixels associated with it. In that case,
* any drawing to this device will have no effect.
*/
SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
static SkBitmapDevice* Create(const SkImageInfo&, const SkDeviceProperties*);
SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps);
private:
static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps*);
public:
static SkBitmapDevice* Create(const SkImageInfo& info) {
return Create(info, NULL);

View File

@ -1290,7 +1290,9 @@ private:
kConservativeRasterClip_InitFlag = 1 << 0,
};
SkCanvas(const SkIRect& bounds, InitFlags);
// TODO: remove this ctor - the basedevice should already have surface props
SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags);
SkCanvas(SkBaseDevice* device, InitFlags);
void resetForNextPicture(const SkIRect& bounds);

View File

@ -13,6 +13,7 @@
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkImageFilter.h"
#include "SkSurfaceProps.h"
class SkClipStack;
class SkDraw;
@ -21,7 +22,6 @@ struct SkIRect;
class SkMatrix;
class SkMetaData;
class SkRegion;
struct SkDeviceProperties;
class GrRenderTarget;
class SK_API SkBaseDevice : public SkRefCnt {
@ -32,7 +32,7 @@ public:
* Construct a new device.
*/
SkBaseDevice();
explicit SkBaseDevice(const SkDeviceProperties&);
explicit SkBaseDevice(const SkSurfaceProps&);
virtual ~SkBaseDevice();
SkMetaData& getMetaData();
@ -315,8 +315,8 @@ protected:
* If the device does handle a property, that property should be set to the identity value
* for that property, effectively making it non-leaky.
*/
const SkDeviceProperties& getLeakyProperties() const {
return *fLeakyProperties;
const SkSurfaceProps& getLeakyProperties() const {
return fLeakyProperties;
}
/**
@ -399,7 +399,7 @@ private:
SkIPoint fOrigin;
SkMetaData* fMetaData;
SkDeviceProperties* fLeakyProperties; // will always exist.
SkSurfaceProps fLeakyProperties;
#ifdef SK_DEBUG
bool fAttachedToCanvas;

View File

@ -20,7 +20,6 @@ class SkAutoGlyphCache;
class SkColorFilter;
class SkData;
class SkDescriptor;
struct SkDeviceProperties;
class SkReadBuffer;
class SkWriteBuffer;
class SkGlyph;
@ -33,6 +32,7 @@ class SkPathEffect;
struct SkPoint;
class SkRasterizer;
class SkShader;
class SkSurfaceProps;
class SkTypeface;
typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**,
@ -1066,15 +1066,15 @@ private:
* Allocs an SkDescriptor on the heap and return it to the caller as a refcnted
* SkData. Caller is responsible for managing the lifetime of this object.
*/
void getScalerContextDescriptor(SkAutoDescriptor*, const SkDeviceProperties* deviceProperties,
void getScalerContextDescriptor(SkAutoDescriptor*, const SkSurfaceProps& surfaceProps,
const SkMatrix*, bool ignoreGamma) const;
SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*,
SkGlyphCache* detachCache(const SkSurfaceProps* surfaceProps, const SkMatrix*,
bool ignoreGamma) const;
void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix,
void descriptorProc(const SkSurfaceProps* surfaceProps, const SkMatrix* deviceMatrix,
void (*proc)(SkTypeface*, const SkDescriptor*, void*),
void* context, bool ignoreGamma = false) const;
void* context, bool ignoreGamma) const;
/*
* The luminance color is used to determine which Gamma Canonical color to map to. This is

View File

@ -71,6 +71,9 @@ public:
bool isDisallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); }
bool isUseDistanceFieldFonts() const { return SkToBool(fFlags & kUseDistanceFieldFonts_Flag); }
// TODO: remove this entry point
void setPixelGeometry_dont_use(SkPixelGeometry geo) { fPixelGeometry = geo; }
private:
SkSurfaceProps();

View File

@ -180,8 +180,8 @@ public:
*
* @return a draw context
*/
GrDrawContext* drawContext(const SkDeviceProperties* devProps = NULL) {
return fDrawingMgr.drawContext(devProps);
GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) {
return fDrawingMgr.drawContext(surfaceProps);
}
///////////////////////////////////////////////////////////////////////////
@ -419,7 +419,7 @@ private:
// Callers should take a ref if they rely on the GrDrawContext sticking around.
// NULL will be returned if the context has been abandoned.
GrDrawContext* drawContext(const SkDeviceProperties* devProps);
GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps);
private:
void cleanup();

View File

@ -10,6 +10,7 @@
#include "GrColor.h"
#include "SkRefCnt.h"
#include "SkSurfaceProps.h"
class GrBatch;
class GrClip;
@ -23,7 +24,6 @@ class GrRenderTarget;
class GrStrokeInfo;
class GrSurface;
class GrTextContext;
struct SkDeviceProperties;
class SkDrawFilter;
struct SkIPoint;
struct SkIRect;
@ -244,14 +244,14 @@ private:
friend class GrAtlasTextContext; // for access to drawBatch
friend class GrContext; // for ctor
GrDrawContext(GrContext*, GrDrawTarget*, const SkDeviceProperties&);
GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps&);
// Sets the paint. Returns true on success; false on failure.
bool prepareToDraw(GrPipelineBuilder*,
GrRenderTarget* rt,
const GrClip&,
const GrPaint* paint);
GrTextContext* createTextContext(GrRenderTarget*, const SkDeviceProperties&);
GrTextContext* createTextContext(GrRenderTarget*, const SkSurfaceProps&);
// A simpler version of the above which just returns true on success; false on failure.
// Clip is *NOT* set
@ -273,7 +273,7 @@ private:
GrDrawTarget* fDrawTarget;
GrTextContext* fTextContext; // lazily created
SkDeviceProperties* fDevProps; // ptr b.c. SkDeviceProperties isn't public
SkSurfaceProps fSurfaceProps;
};
#endif

View File

@ -17,7 +17,7 @@
class SK_API SkNoSaveLayerCanvas : public SkCanvas {
public:
SkNoSaveLayerCanvas(SkBaseDevice* device)
: INHERITED(device, NULL, kConservativeRasterClip_InitFlag)
: INHERITED(device, kConservativeRasterClip_InitFlag)
{}
protected:

View File

@ -7,7 +7,6 @@
#include "SkBitmapDevice.h"
#include "SkConfig8888.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkPixelRef.h"
#include "SkRasterClip.h"
@ -63,15 +62,15 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) {
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
}
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
: SkBaseDevice(deviceProperties)
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps)
: SkBaseDevice(surfaceProps)
, fBitmap(bitmap)
{
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
}
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
const SkDeviceProperties* props) {
const SkSurfaceProps* surfaceProps) {
SkAlphaType newAT = origInfo.alphaType();
if (!valid_for_bitmap_device(origInfo, &newAT)) {
return NULL;
@ -93,8 +92,8 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
}
}
if (props) {
return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
if (surfaceProps) {
return SkNEW_ARGS(SkBitmapDevice, (bitmap, *surfaceProps));
} else {
return SkNEW_ARGS(SkBitmapDevice, (bitmap));
}
@ -117,7 +116,7 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
}
SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
const SkDeviceProperties leaky(cinfo.fPixelGeometry);
const SkSurfaceProps leaky(0, cinfo.fPixelGeometry);
return SkBitmapDevice::Create(cinfo.fInfo, &leaky);
}

View File

@ -9,7 +9,6 @@
#include "SkCanvasPriv.h"
#include "SkBitmapDevice.h"
#include "SkColorFilter.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkDrawable.h"
#include "SkDrawFilter.h"
@ -537,6 +536,7 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
fSurfaceBase = NULL;
if (device) {
// TODO: remove this - the root device & canvas should always have same surfaceProps
device->initForRootLayer(fProps.pixelGeometry());
if (device->forceConservativeRasterClip()) {
fConservativeRasterClip = true;
@ -565,8 +565,8 @@ static SkBitmap make_nopixels(int width, int height) {
class SkNoPixelsBitmapDevice : public SkBitmapDevice {
public:
SkNoPixelsBitmapDevice(const SkIRect& bounds)
: INHERITED(make_nopixels(bounds.width(), bounds.height()))
SkNoPixelsBitmapDevice(const SkIRect& bounds, const SkSurfaceProps& surfaceProps)
: INHERITED(make_nopixels(bounds.width(), bounds.height()), surfaceProps)
{
this->setOrigin(bounds.x(), bounds.y());
}
@ -583,7 +583,7 @@ SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props)
inc_canvas();
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice,
(SkIRect::MakeWH(width, height))), kDefault_InitFlags)->unref();
(SkIRect::MakeWH(width, height), fProps)), kDefault_InitFlags)->unref();
}
SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
@ -592,9 +592,10 @@ SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
{
inc_canvas();
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds)), flags)->unref();
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds, fProps)), flags)->unref();
}
// TODO: remove this ctor
SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfacePropsCopyOrDefault(props))
@ -606,20 +607,29 @@ SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags
SkCanvas::SkCanvas(SkBaseDevice* device)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
, fProps(device->getLeakyProperties())
{
inc_canvas();
this->init(device, kDefault_InitFlags);
}
SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(device->getLeakyProperties())
{
inc_canvas();
this->init(device, flags);
}
SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(props)
{
inc_canvas();
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap, fProps)));
this->init(device, kDefault_InitFlags);
}
@ -629,7 +639,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
{
inc_canvas();
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap, fProps)));
this->init(device, kDefault_InitFlags);
}
@ -1039,8 +1049,8 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
SkBaseDevice* newDev = device->onCreateDevice(createInfo, paint);
if (NULL == newDev) {
// If onCreateDevice didn't succeed, try raster (e.g. PDF couldn't handle the paint)
const SkDeviceProperties deviceProps(createInfo.fPixelGeometry);
newDev = SkBitmapDevice::Create(createInfo.fInfo, &deviceProps);
const SkSurfaceProps surfaceProps(0, createInfo.fPixelGeometry);
newDev = SkBitmapDevice::Create(createInfo.fInfo, &surfaceProps);
if (NULL == newDev) {
SkErrorInternals::SetError(kInternalError_SkError,
"Unable to create device for layer.");

View File

@ -6,7 +6,6 @@
*/
#include "SkDevice.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkDrawFilter.h"
#include "SkImage_Base.h"
@ -19,7 +18,7 @@
#include "SkTextToPathIter.h"
SkBaseDevice::SkBaseDevice()
: fLeakyProperties(SkNEW(SkDeviceProperties))
: fLeakyProperties(SkSurfaceProps::kLegacyFontHost_InitType)
#ifdef SK_DEBUG
, fAttachedToCanvas(false)
#endif
@ -28,8 +27,8 @@ SkBaseDevice::SkBaseDevice()
fMetaData = NULL;
}
SkBaseDevice::SkBaseDevice(const SkDeviceProperties& dp)
: fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (dp)))
SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps)
: fLeakyProperties(surfaceProps)
#ifdef SK_DEBUG
, fAttachedToCanvas(false)
#endif
@ -39,7 +38,6 @@ SkBaseDevice::SkBaseDevice(const SkDeviceProperties& dp)
}
SkBaseDevice::~SkBaseDevice() {
SkDELETE(fLeakyProperties);
SkDELETE(fMetaData);
}
@ -86,9 +84,9 @@ void SkBaseDevice::initForRootLayer(SkPixelGeometry geo) {
// For now we don't expect to change the geometry for the root-layer, but we make the call
// anyway to document logically what is going on.
//
fLeakyProperties->setPixelGeometry(CreateInfo::AdjustGeometry(this->imageInfo(),
kPossible_TileUsage,
geo));
fLeakyProperties.setPixelGeometry_dont_use(CreateInfo::AdjustGeometry(this->imageInfo(),
kPossible_TileUsage,
geo));
}
void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
@ -371,7 +369,7 @@ uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const {
return flags;
}
if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry()
if (kUnknown_SkPixelGeometry == fLeakyProperties.pixelGeometry()
|| this->onShouldDisableLCD(paint)) {
flags &= ~SkPaint::kLCDRenderText_Flag;

View File

@ -1,41 +0,0 @@
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDeviceProperties_DEFINED
#define SkDeviceProperties_DEFINED
#include "SkSurfacePriv.h"
struct SkDeviceProperties {
SkDeviceProperties(const SkDeviceProperties& src)
: fUseDFT(src.fUseDFT)
, fPixelGeometry(src.fPixelGeometry) {
}
SkDeviceProperties()
: fUseDFT(false)
, fPixelGeometry(SkSurfacePropsDefaultPixelGeometry())
{}
SkDeviceProperties(SkPixelGeometry geo, bool useDFT = false)
: fUseDFT(useDFT)
, fPixelGeometry(geo)
{}
bool useDFT() const { return fUseDFT; }
SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
void setPixelGeometry(SkPixelGeometry geo) {
fPixelGeometry = geo;
}
private:
const bool fUseDFT;
SkPixelGeometry fPixelGeometry;
};
#endif

View File

@ -17,7 +17,6 @@
#include "SkTemplates.h"
#include "SkTDArray.h"
struct SkDeviceProperties;
class SkPaint;
class SkGlyphCache_Globals;
@ -276,7 +275,7 @@ protected:
fCache = SkGlyphCache::DetachCache(typeface, desc);
}
SkAutoGlyphCacheBase(const SkPaint& /*paint*/,
const SkDeviceProperties* /*deviceProperties*/,
const SkSurfaceProps* /*surfaceProps*/,
const SkMatrix* /*matrix*/) {
fCache = NULL;
}
@ -301,9 +300,9 @@ public:
SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) :
SkAutoGlyphCacheBase(typeface, desc) {}
SkAutoGlyphCache(const SkPaint& paint,
const SkDeviceProperties* deviceProperties,
const SkSurfaceProps* surfaceProps,
const SkMatrix* matrix) {
fCache = paint.detachCache(deviceProperties, matrix, false);
fCache = paint.detachCache(surfaceProps, matrix, false);
}
private:
@ -317,9 +316,9 @@ public:
SkAutoGlyphCacheNoGamma(SkTypeface* typeface, const SkDescriptor* desc) :
SkAutoGlyphCacheBase(typeface, desc) {}
SkAutoGlyphCacheNoGamma(const SkPaint& paint,
const SkDeviceProperties* deviceProperties,
const SkSurfaceProps* surfaceProps,
const SkMatrix* matrix) {
fCache = paint.detachCache(deviceProperties, matrix, true);
fCache = paint.detachCache(surfaceProps, matrix, true);
}
private:

View File

@ -11,7 +11,6 @@
#include "SkChecksum.h"
#include "SkColorFilter.h"
#include "SkData.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkFontDescriptor.h"
#include "SkGlyphCache.h"
@ -32,6 +31,7 @@
#include "SkTextToPathIter.h"
#include "SkTLazy.h"
#include "SkTypeface.h"
#include "SkSurfacePriv.h"
#include "SkXfermode.h"
// define this to get a printf for out-of-range parameter in setters
@ -1329,7 +1329,7 @@ static SkScalar sk_relax(SkScalar x) {
}
void SkScalerContext::MakeRec(const SkPaint& paint,
const SkDeviceProperties* deviceProperties,
const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
Rec* rec) {
SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective());
@ -1415,8 +1415,8 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
rec->fMaskFormat = SkMask::kA8_Format;
flags |= SkScalerContext::kGenA8FromLCD_Flag;
} else {
SkPixelGeometry geometry = deviceProperties
? deviceProperties->pixelGeometry()
SkPixelGeometry geometry = surfaceProps
? surfaceProps->pixelGeometry()
: SkSurfacePropsDefaultPixelGeometry();
switch (geometry) {
case kUnknown_SkPixelGeometry:
@ -1603,12 +1603,12 @@ static void write_out_descriptor(SkDescriptor* desc, const SkScalerContext::Rec&
}
static size_t fill_out_rec(const SkPaint& paint, SkScalerContext::Rec* rec,
const SkDeviceProperties* deviceProperties,
const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix, bool ignoreGamma,
const SkPathEffect* pe, SkWriteBuffer* peBuffer,
const SkMaskFilter* mf, SkWriteBuffer* mfBuffer,
const SkRasterizer* ra, SkWriteBuffer* raBuffer) {
SkScalerContext::MakeRec(paint, deviceProperties, deviceMatrix, rec);
SkScalerContext::MakeRec(paint, surfaceProps, deviceMatrix, rec);
if (ignoreGamma) {
rec->ignorePreBlend();
}
@ -1698,7 +1698,7 @@ static void test_desc(const SkScalerContext::Rec& rec,
/* see the note on ignoreGamma on descriptorProc */
void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad,
const SkDeviceProperties* deviceProperties,
const SkSurfaceProps& surfaceProps,
const SkMatrix* deviceMatrix, bool ignoreGamma) const {
SkScalerContext::Rec rec;
@ -1707,7 +1707,7 @@ void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad,
SkRasterizer* ra = this->getRasterizer();
SkWriteBuffer peBuffer, mfBuffer, raBuffer;
size_t descSize = fill_out_rec(*this, &rec, deviceProperties, deviceMatrix, ignoreGamma,
size_t descSize = fill_out_rec(*this, &rec, &surfaceProps, deviceMatrix, ignoreGamma,
pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer);
ad->reset(descSize);
@ -1727,7 +1727,7 @@ void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad,
* by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1,
* contrast = 0, luminanceColor = transparent black.
*/
void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
void (*proc)(SkTypeface*, const SkDescriptor*, void*),
void* context, bool ignoreGamma) const {
@ -1738,7 +1738,7 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
SkRasterizer* ra = this->getRasterizer();
SkWriteBuffer peBuffer, mfBuffer, raBuffer;
size_t descSize = fill_out_rec(*this, &rec, deviceProperties, deviceMatrix, ignoreGamma,
size_t descSize = fill_out_rec(*this, &rec, surfaceProps, deviceMatrix, ignoreGamma,
pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer);
SkAutoDescriptor ad(descSize);
@ -1755,11 +1755,11 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
proc(fTypeface, desc, context);
}
SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties,
SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps,
const SkMatrix* deviceMatrix,
bool ignoreGamma) const {
SkGlyphCache* cache;
this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, ignoreGamma);
this->descriptorProc(surfaceProps, deviceMatrix, DetachDescProc, &cache, ignoreGamma);
return cache;
}
@ -2289,10 +2289,10 @@ static bool has_thick_frame(const SkPaint& paint) {
paint.getStyle() != SkPaint::kFill_Style;
}
SkTextToPathIter::SkTextToPathIter( const char text[], size_t length,
const SkPaint& paint,
bool applyStrokeAndPathEffects)
: fPaint(paint) {
SkTextToPathIter::SkTextToPathIter(const char text[], size_t length,
const SkPaint& paint,
bool applyStrokeAndPathEffects)
: fPaint(paint) {
fGlyphCacheProc = paint.getMeasureCacheProc(true);
fPaint.setLinearText(true);

View File

@ -237,7 +237,7 @@ public:
static void GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma,
void* data);
static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps,
const SkMatrix*, Rec* rec);
static inline void PostMakeRec(const SkPaint&, Rec*);

View File

@ -101,8 +101,8 @@ static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
GrDrawContext* drawContext,
const SkDeviceProperties& properties)
: INHERITED(context, drawContext, properties)
const SkSurfaceProps& surfaceProps)
: INHERITED(context, drawContext, surfaceProps)
, fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) {
// We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
// vertexStride
@ -196,8 +196,8 @@ void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() {
GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context,
GrDrawContext* drawContext,
const SkDeviceProperties& props) {
return SkNEW_ARGS(GrAtlasTextContext, (context, drawContext, props));
const SkSurfaceProps& surfaceProps) {
return SkNEW_ARGS(GrAtlasTextContext, (context, drawContext, surfaceProps));
}
bool GrAtlasTextContext::canDraw(const GrRenderTarget*,
@ -338,7 +338,7 @@ inline SkGlyphCache* GrAtlasTextContext::setupCache(BitmapTextBlob::Run* run,
const SkPaint& skPaint,
const SkMatrix* viewMatrix,
bool noGamma) {
skPaint.getScalerContextDescriptor(&run->fDescriptor, &fDeviceProperties, viewMatrix, noGamma);
skPaint.getScalerContextDescriptor(&run->fDescriptor, fSurfaceProps, viewMatrix, noGamma);
run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc());
}
@ -367,7 +367,7 @@ void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt,
bool hasLCD = HasLCD(blob);
// We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry
SkPixelGeometry pixelGeometry = hasLCD ? fDeviceProperties.pixelGeometry() :
SkPixelGeometry pixelGeometry = hasLCD ? fSurfaceProps.pixelGeometry() :
kUnknown_SkPixelGeometry;
// TODO we want to figure out a way to be able to use the canonical color on LCD text,
@ -446,7 +446,7 @@ inline bool GrAtlasTextContext::canDrawAsDistanceFields(const SkPaint& skPaint,
return false;
}
bool useDFT = fDeviceProperties.useDFT();
bool useDFT = fSurfaceProps.isUseDistanceFieldFonts();
#if SK_FORCE_DISTANCE_FIELD_TEXT
useDFT = true;
#endif
@ -498,7 +498,7 @@ void GrAtlasTextContext::regenerateTextBlob(BitmapTextBlob* cacheBlob,
continue;
}
runPaint.setFlags(FilterTextFlags(fDeviceProperties, runPaint));
runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint));
// setup vertex / glyphIndex for the new run
if (run > 0) {
@ -666,7 +666,7 @@ inline void GrAtlasTextContext::fallbackDrawPosText(BitmapTextBlob* blob,
run.push_back();
run.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor));
skPaint.getScalerContextDescriptor(run.fOverrideDescriptor,
&fDeviceProperties, &viewMatrix, false);
fSurfaceProps, &viewMatrix, false);
SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
run.fOverrideDescriptor->getDesc());
this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(), viewMatrix,
@ -1077,7 +1077,7 @@ void GrAtlasTextContext::internalDrawDFText(BitmapTextBlob* blob, int runIndex,
SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc();
SkAutoDescriptor desc;
origPaint.getScalerContextDescriptor(&desc, &fDeviceProperties, NULL, true);
origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, NULL, true);
SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypeface(),
desc.getDesc());
@ -2046,7 +2046,7 @@ void GrAtlasTextContext::flushRunAsPaths(GrRenderTarget* rt, const SkTextBlob::R
return;
}
runPaint.setFlags(FilterTextFlags(fDeviceProperties, runPaint));
runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint));
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
@ -2092,7 +2092,7 @@ GrAtlasTextContext::createBatch(BitmapTextBlob* cacheBlob, const PerSubRunInfo&
} else {
filteredColor = skPaint.getColor();
}
bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry());
bool useBGR = SkPixelGeometryIsBGR(fSurfaceProps.pixelGeometry());
batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFontCache(),
fDistanceAdjustTable, filteredColor,
info.fUseLCDText, useBGR);
@ -2214,7 +2214,7 @@ void GrAtlasTextContext::flush(BitmapTextBlob* cacheBlob,
BATCH_TEST_DEFINE(TextBlobBatch) {
static uint32_t gContextID = SK_InvalidGenID;
static GrAtlasTextContext* gTextContext = NULL;
static SkDeviceProperties gDevProperties;
static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
if (context->uniqueID() != gContextID) {
gContextID = context->uniqueID();
@ -2223,9 +2223,9 @@ BATCH_TEST_DEFINE(TextBlobBatch) {
// We don't yet test the fall back to paths in the GrTextContext base class. This is mostly
// because we don't really want to have a gpu device here.
// We enable distance fields by twiddling a knob on the paint
GrDrawContext* drawContext = context->drawContext(&gDevProperties);
GrDrawContext* drawContext = context->drawContext(&gSurfaceProps);
gTextContext = GrAtlasTextContext::Create(context, drawContext, gDevProperties);
gTextContext = GrAtlasTextContext::Create(context, drawContext, gSurfaceProps);
}
// create dummy render target

View File

@ -35,10 +35,10 @@ class GrTextBlobCache;
*/
class GrAtlasTextContext : public GrTextContext {
public:
static GrAtlasTextContext* Create(GrContext*, GrDrawContext*, const SkDeviceProperties&);
static GrAtlasTextContext* Create(GrContext*, GrDrawContext*, const SkSurfaceProps&);
private:
GrAtlasTextContext(GrContext*, GrDrawContext*, const SkDeviceProperties&);
GrAtlasTextContext(GrContext*, GrDrawContext*, const SkSurfaceProps&);
~GrAtlasTextContext() override {}
bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&,

View File

@ -43,6 +43,7 @@
#include "SkGr.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "SkSurfacePriv.h"
#include "SkTLazy.h"
#include "SkTLS.h"
#include "SkTraceEvent.h"
@ -111,23 +112,20 @@ void GrContext::DrawingMgr::flush() {
}
}
GrDrawContext* GrContext::DrawingMgr::drawContext(const SkDeviceProperties* devProps) {
GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) {
if (this->abandoned()) {
return NULL;
}
const SkDeviceProperties defProps;
if (!devProps) {
devProps = &defProps;
const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps));
SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) {
fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] =
SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, props));
}
SkASSERT(devProps->pixelGeometry() < kNumPixelGeometries);
if (!fDrawContext[devProps->pixelGeometry()][devProps->useDFT()]) {
fDrawContext[devProps->pixelGeometry()][devProps->useDFT()] =
SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, *devProps));
}
return fDrawContext[devProps->pixelGeometry()][devProps->useDFT()];
return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()];
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -34,17 +34,16 @@ private:
GrDrawContext::GrDrawContext(GrContext* context,
GrDrawTarget* drawTarget,
const SkDeviceProperties& devProps)
const SkSurfaceProps& surfaceProps)
: fContext(context)
, fDrawTarget(SkRef(drawTarget))
, fTextContext(NULL)
, fDevProps(SkNEW_ARGS(SkDeviceProperties, (devProps))) {
, fSurfaceProps(surfaceProps) {
}
GrDrawContext::~GrDrawContext() {
SkSafeUnref(fDrawTarget);
SkDELETE(fTextContext);
SkDELETE(fDevProps);
}
void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src,
@ -57,16 +56,16 @@ void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src,
}
GrTextContext* GrDrawContext::createTextContext(GrRenderTarget* renderTarget,
const SkDeviceProperties& leakyProperties) {
const SkSurfaceProps& surfaceProps) {
if (fContext->caps()->shaderCaps()->pathRenderingSupport() &&
renderTarget->isStencilBufferMultisampled()) {
GrStencilAttachment* sb = renderTarget->renderTargetPriv().attachStencilAttachment();
if (sb) {
return GrStencilAndCoverTextContext::Create(fContext, this, leakyProperties);
return GrStencilAndCoverTextContext::Create(fContext, this, surfaceProps);
}
}
return GrAtlasTextContext::Create(fContext, this, leakyProperties);
return GrAtlasTextContext::Create(fContext, this, surfaceProps);
}
void GrDrawContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& grPaint,
@ -75,7 +74,7 @@ void GrDrawContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
if (!fTextContext) {
fTextContext = this->createTextContext(rt, *fDevProps);
fTextContext = this->createTextContext(rt, fSurfaceProps);
}
fTextContext->drawText(rt, clip, grPaint, skPaint, viewMatrix,
@ -89,7 +88,7 @@ void GrDrawContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
if (!fTextContext) {
fTextContext = this->createTextContext(rt, *fDevProps);
fTextContext = this->createTextContext(rt, fSurfaceProps);
}
fTextContext->drawPosText(rt, clip, grPaint, skPaint, viewMatrix, text, byteLength,
@ -101,7 +100,7 @@ void GrDrawContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip, const S
SkScalar x, SkScalar y,
SkDrawFilter* filter, const SkIRect& clipBounds) {
if (!fTextContext) {
fTextContext = this->createTextContext(rt, *fDevProps);
fTextContext = this->createTextContext(rt, fSurfaceProps);
}
fTextContext->drawTextBlob(rt, clip, skPaint, viewMatrix, blob, x, y, filter, clipBounds);

View File

@ -11,7 +11,6 @@
#include "SkBigPicture.h"
#include "SkCanvas.h"
#include "SkDeviceProperties.h"
#include "SkGpuDevice.h"
#include "SkGrPixelRef.h"
#include "SkLayerInfo.h"

View File

@ -23,8 +23,8 @@
GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context,
GrDrawContext* drawContext,
const SkDeviceProperties& properties)
: GrTextContext(context, drawContext, properties)
const SkSurfaceProps& surfaceProps)
: GrTextContext(context, drawContext, surfaceProps)
, fStroke(SkStrokeRec::kFill_InitStyle)
, fQueuedGlyphCount(0)
, fFallbackGlyphsIdx(kGlyphBufferSize) {
@ -32,10 +32,10 @@ GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context,
GrStencilAndCoverTextContext*
GrStencilAndCoverTextContext::Create(GrContext* context, GrDrawContext* drawContext,
const SkDeviceProperties& props) {
const SkSurfaceProps& surfaceProps) {
GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverTextContext,
(context, drawContext, props));
textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, drawContext, props);
(context, drawContext, surfaceProps));
textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, drawContext, surfaceProps);
return textContext;
}
@ -69,7 +69,7 @@ bool GrStencilAndCoverTextContext::canDraw(const GrRenderTarget* rt,
// No color bitmap fonts.
SkScalerContext::Rec rec;
SkScalerContext::MakeRec(skPaint, &fDeviceProperties, NULL, &rec);
SkScalerContext::MakeRec(skPaint, &fSurfaceProps, NULL, &rec);
return rec.getFormat() != SkMask::kARGB32_Format;
}
@ -293,7 +293,7 @@ void GrStencilAndCoverTextContext::init(GrRenderTarget* rt,
return;
}
fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, &fContextInitialMatrix,
fGlyphCache = fSkPaint.detachCache(&fSurfaceProps, &fContextInitialMatrix,
true /*ignoreGamma*/);
fGlyphs = get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->getTypeface(),
&fGlyphCache->getDescriptor(), fStroke);
@ -363,7 +363,7 @@ void GrStencilAndCoverTextContext::init(GrRenderTarget* rt,
fViewMatrix.preConcat(textMatrix);
fLocalMatrix = textMatrix;
fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, true /*ignoreGamma*/);
fGlyphCache = fSkPaint.detachCache(&fSurfaceProps, NULL, true /*ignoreGamma*/);
fGlyphs = canUseRawPaths ?
get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, fStroke) :
get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->getTypeface(),

View File

@ -15,6 +15,7 @@
class GrTextStrike;
class GrPath;
class GrPathRange;
class SkSurfaceProps;
/*
* This class implements text rendering using stencil and cover path rendering
@ -24,7 +25,7 @@ class GrPathRange;
class GrStencilAndCoverTextContext : public GrTextContext {
public:
static GrStencilAndCoverTextContext* Create(GrContext*, GrDrawContext*,
const SkDeviceProperties&);
const SkSurfaceProps&);
virtual ~GrStencilAndCoverTextContext();
@ -68,7 +69,7 @@ private:
SkMatrix fLocalMatrix;
bool fUsingDeviceSpaceGlyphs;
GrStencilAndCoverTextContext(GrContext*, GrDrawContext*, const SkDeviceProperties&);
GrStencilAndCoverTextContext(GrContext*, GrDrawContext*, const SkSurfaceProps&);
bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&,
const SkPaint&, const SkMatrix& viewMatrix) override;

View File

@ -21,10 +21,10 @@
#include "SkTextToPathIter.h"
GrTextContext::GrTextContext(GrContext* context, GrDrawContext* drawContext,
const SkDeviceProperties& properties)
const SkSurfaceProps& surfaceProps)
: fFallbackTextContext(NULL)
, fContext(context)
, fDeviceProperties(properties)
, fSurfaceProps(surfaceProps)
, fDrawContext(drawContext) {
}
@ -108,14 +108,14 @@ bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) {
return false;
}
uint32_t GrTextContext::FilterTextFlags(const SkDeviceProperties& devProps, const SkPaint& paint) {
uint32_t GrTextContext::FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint) {
uint32_t flags = paint.getFlags();
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
return flags;
}
if (kUnknown_SkPixelGeometry == devProps.pixelGeometry() || ShouldDisableLCD(paint)) {
if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisableLCD(paint)) {
flags &= ~SkPaint::kLCDRenderText_Flag;
flags |= SkPaint::kGenA8FromLCD_Flag;
}
@ -144,7 +144,7 @@ void GrTextContext::drawTextBlob(GrRenderTarget* rt,
continue;
}
runPaint.setFlags(FilterTextFlags(fDeviceProperties, runPaint));
runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint));
GrPaint grPaint;
if (!SkPaint2GrPaint(fContext, fRenderTarget, runPaint, viewMatrix, true, &grPaint)) {

View File

@ -11,7 +11,7 @@
#include "GrClip.h"
#include "GrGlyph.h"
#include "GrPaint.h"
#include "SkDeviceProperties.h"
#include "SkSurfaceProps.h"
#include "SkPostConfig.h"
class GrClip;
@ -46,7 +46,7 @@ public:
protected:
GrTextContext* fFallbackTextContext;
GrContext* fContext;
SkDeviceProperties fDeviceProperties;
SkSurfaceProps fSurfaceProps;
GrDrawContext* fDrawContext; // owning drawContext
SkAutoTUnref<GrRenderTarget> fRenderTarget;
@ -56,7 +56,7 @@ protected:
GrPaint fPaint;
SkPaint fSkPaint;
GrTextContext(GrContext*, GrDrawContext*, const SkDeviceProperties&);
GrTextContext(GrContext*, GrDrawContext*, const SkSurfaceProps&);
virtual bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&,
const SkPaint&, const SkMatrix& viewMatrix) = 0;
@ -89,7 +89,7 @@ protected:
// sets extent in stopVector and returns glyph count
static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
const char text[], size_t byteLength, SkVector* stopVector);
static uint32_t FilterTextFlags(const SkDeviceProperties& devProps, const SkPaint& paint);
static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint);
friend class BitmapTextBatch;
};

View File

@ -134,26 +134,9 @@ SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags));
}
static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* props) {
if (props) {
return SkDeviceProperties(props->pixelGeometry(), props->isUseDistanceFieldFonts());
} else {
return SkDeviceProperties();
}
}
static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) {
if (props) {
return SkSurfaceProps(*props);
} else {
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
}
}
SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
const SkSurfaceProps* props, unsigned flags)
: INHERITED(surfaceprops_to_deviceprops(props))
, fSurfaceProps(copy_or_default_props(props))
: INHERITED(SkSurfacePropsCopyOrDefault(props))
{
fDrawProcs = NULL;
@ -1701,7 +1684,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
texture.reset(fContext->textureProvider()->refScratchTexture(desc, match));
if (texture) {
SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry);
SkSurfaceProps props(this->getLeakyProperties().flags(), cinfo.fPixelGeometry);
return SkGpuDevice::Create(
texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height(), &props, flags);
} else {

View File

@ -76,7 +76,9 @@ public:
return fLegacyBitmap.info();
}
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
const SkSurfaceProps& surfaceProps() const {
return this->getLeakyProperties();
}
void drawPaint(const SkDraw&, const SkPaint& paint) override;
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
@ -151,7 +153,6 @@ private:
SkIPoint fClipOrigin;
GrClip fClip;
SkAutoTUnref<GrDrawContext> fDrawContext;
SkSurfaceProps fSurfaceProps;
GrRenderTarget* fRenderTarget;
// remove when our clients don't rely on accessBitmap()
SkBitmap fLegacyBitmap;

View File

@ -32,7 +32,7 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
// When we think this works...
// flags |= SkCanvas::kConservativeRasterClip_InitFlag;
return SkNEW_ARGS(SkCanvas, (fDevice, &this->props(), flags));
return SkNEW_ARGS(SkCanvas, (fDevice, flags));
}
SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {