Revert of introduce Props to surface (patchset #27 id:520001 of https://codereview.chromium.org/551463004/)
Reason for revert: Broke call site in WebKit Original issue's description: > introduce Props to surface (work in progress) > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/3716fd067a5621bb94a6cb08d72afec8bf3aceda R=robertphillips@google.com, bsalomon@google.com, jvanverth@google.com, bungeman@google.com, fmalita@google.com, vangelis@chromium.org, reed@google.com TBR=bsalomon@google.com, bungeman@google.com, fmalita@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com, vangelis@chromium.org NOTREECHECKS=true NOTRY=true BUG=skia: Author: reed@chromium.org Review URL: https://codereview.chromium.org/583773004
This commit is contained in:
parent
3716fd067a
commit
29c857d0f3
@ -47,8 +47,7 @@ void SkGLWidget::initializeGL() {
|
||||
GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height());
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
|
||||
fGpuDevice = SkGpuDevice::Create(curRenderTarget,
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
fGpuDevice = SkGpuDevice::Create(curRenderTarget);
|
||||
fCanvas = new SkCanvas(fGpuDevice);
|
||||
curRenderTarget->unref();
|
||||
}
|
||||
@ -66,8 +65,7 @@ void SkGLWidget::resizeGL(int w, int h) {
|
||||
GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
|
||||
SkSafeUnref(fGpuDevice);
|
||||
SkSafeUnref(fCanvas);
|
||||
fGpuDevice = SkGpuDevice::Create(curRenderTarget,
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
|
||||
fGpuDevice = SkGpuDevice::Create(curRenderTarget);
|
||||
fCanvas = new SkCanvas(fGpuDevice);
|
||||
}
|
||||
fDebugger->setWindowSize(w, h);
|
||||
|
@ -22,7 +22,7 @@ static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory,
|
||||
GrGLStandard gpuAPI,
|
||||
SkImageInfo info,
|
||||
int samples) {
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples, NULL);
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples);
|
||||
}
|
||||
|
||||
} // namespace DM
|
||||
|
@ -48,9 +48,8 @@ protected:
|
||||
#if SK_SUPPORT_GPU
|
||||
GrContext* ctx = inputCanvas->getGrContext();
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag,
|
||||
SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, info, 0, &props));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, info, 0,
|
||||
SkSurface::kDistanceField_TextRenderMode));
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
#else
|
||||
SkCanvas* canvas = inputCanvas;
|
||||
|
@ -179,7 +179,7 @@ protected:
|
||||
#if SK_SUPPORT_GPU
|
||||
GrContext* ctx = canvas->getGrContext();
|
||||
|
||||
SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info));
|
||||
SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0));
|
||||
#endif
|
||||
|
||||
test_surface(canvas, surf0, true);
|
||||
|
109
gm/surface.cpp
109
gm/surface.cpp
@ -1,109 +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.
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
|
||||
#define W 200
|
||||
#define H 100
|
||||
|
||||
static SkShader* make_shader() {
|
||||
int a = 0x99;
|
||||
int b = 0xBB;
|
||||
SkPoint pts[] = { { 0, 0 }, { W, H } };
|
||||
SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) };
|
||||
return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
|
||||
}
|
||||
|
||||
static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
|
||||
int disallowAA, int disallowDither) {
|
||||
uint32_t flags = 0;
|
||||
if (disallowAA) {
|
||||
flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
|
||||
}
|
||||
if (disallowDither) {
|
||||
flags |= SkSurfaceProps::kDisallowDither_Flag;
|
||||
}
|
||||
|
||||
SkSurfaceProps props(flags, geo);
|
||||
if (ctx) {
|
||||
return SkSurface::NewRenderTarget(ctx, info, 0, &props);
|
||||
} else {
|
||||
return SkSurface::NewRaster(info, &props);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_draw(SkCanvas* canvas, const char label[]) {
|
||||
SkPaint paint;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLCDRenderText(true);
|
||||
paint.setDither(true);
|
||||
|
||||
paint.setShader(make_shader())->unref();
|
||||
canvas->drawRect(SkRect::MakeWH(W, H), paint);
|
||||
paint.setShader(NULL);
|
||||
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
paint.setTextSize(32);
|
||||
paint.setTextAlign(SkPaint::kCenter_Align);
|
||||
canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint);
|
||||
}
|
||||
|
||||
class SurfacePropsGM : public skiagm::GM {
|
||||
public:
|
||||
SurfacePropsGM() {}
|
||||
|
||||
protected:
|
||||
SkString onShortName() SK_OVERRIDE {
|
||||
return SkString("surfaceprops");
|
||||
}
|
||||
|
||||
virtual SkISize onISize() SK_OVERRIDE {
|
||||
return SkISize::Make(W * 4, H * 5);
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
|
||||
GrContext* ctx = canvas->getGrContext();
|
||||
|
||||
// must be opaque to have a hope of testing LCD text
|
||||
const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType);
|
||||
|
||||
const struct {
|
||||
SkPixelGeometry fGeo;
|
||||
const char* fLabel;
|
||||
} rec[] = {
|
||||
{ kUnknown_SkPixelGeometry, "Unknown" },
|
||||
{ kRGB_H_SkPixelGeometry, "RGB_H" },
|
||||
{ kBGR_H_SkPixelGeometry, "BGR_H" },
|
||||
{ kRGB_V_SkPixelGeometry, "RGB_V" },
|
||||
{ kBGR_V_SkPixelGeometry, "BGR_V" },
|
||||
};
|
||||
|
||||
SkScalar x = 0;
|
||||
for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) {
|
||||
for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
|
||||
SkScalar y = 0;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
|
||||
SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[i].fGeo,
|
||||
disallowAA, disallowDither));
|
||||
test_draw(surface->getCanvas(), rec[i].fLabel);
|
||||
surface->draw(canvas, x, y, NULL);
|
||||
y += H;
|
||||
}
|
||||
x += W;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
DEF_GM( return new SurfacePropsGM )
|
@ -132,8 +132,7 @@ private:
|
||||
desc.fConfig = SkImageInfo2GrPixelConfig(baseCanvas->imageInfo());
|
||||
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
||||
SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc, NULL, 0));
|
||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get(),
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)));
|
||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get()));
|
||||
if (device.get()) {
|
||||
tempCanvas = SkNEW_ARGS(SkCanvas, (device.get()));
|
||||
}
|
||||
|
@ -171,7 +171,6 @@
|
||||
'../gm/strokerects.cpp',
|
||||
'../gm/strokes.cpp',
|
||||
'../gm/stroketext.cpp',
|
||||
'../gm/surface.cpp',
|
||||
'../gm/tablecolorfilter.cpp',
|
||||
'../gm/texteffects.cpp',
|
||||
'../gm/testimagefilters.cpp',
|
||||
|
@ -155,7 +155,7 @@ private:
|
||||
|
||||
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
|
||||
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
|
||||
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE;
|
||||
|
||||
virtual SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
|
||||
@ -201,12 +200,8 @@ public:
|
||||
* Create a new surface matching the specified info, one that attempts to
|
||||
* be maximally compatible when used with this canvas. If there is no matching Surface type,
|
||||
* NULL is returned.
|
||||
*
|
||||
* If surfaceprops is specified, those are passed to the new surface, otherwise the new surface
|
||||
* inherits the properties of the surface that owns this canvas. If this canvas has no parent
|
||||
* surface, then the new surface is created with default properties.
|
||||
*/
|
||||
SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL);
|
||||
SkSurface* newSurface(const SkImageInfo&);
|
||||
|
||||
/**
|
||||
* Return the GPU context of the device that is associated with the canvas.
|
||||
@ -1197,7 +1192,7 @@ public:
|
||||
|
||||
protected:
|
||||
// default impl defers to getDevice()->newSurface(info)
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&);
|
||||
|
||||
// default impl defers to its device
|
||||
virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
|
||||
@ -1287,8 +1282,6 @@ private:
|
||||
// the first N recs that can fit here mean we won't call malloc
|
||||
uint32_t fMCRecStorage[32];
|
||||
|
||||
const SkSurfaceProps fProps;
|
||||
|
||||
int fSaveLayerCount; // number of successful saveLayer calls
|
||||
int fCullCount; // number of active culls
|
||||
|
||||
@ -1318,20 +1311,14 @@ private:
|
||||
kDefault_InitFlags = 0,
|
||||
kConservativeRasterClip_InitFlag = 1 << 0,
|
||||
};
|
||||
SkCanvas(int width, int height, InitFlags);
|
||||
SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags);
|
||||
SkCanvas(const SkBitmap&, const SkSurfaceProps&);
|
||||
SkCanvas(int width, int height, InitFlags flags);
|
||||
SkCanvas(SkBaseDevice*, InitFlags flags);
|
||||
|
||||
// needs gettotalclip()
|
||||
friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*);
|
||||
|
||||
SkBaseDevice* createLayerDevice(const SkImageInfo&);
|
||||
|
||||
// call this each time we attach ourselves to a device
|
||||
// - constructor
|
||||
// - internalSaveLayer
|
||||
void setupDevice(SkBaseDevice*);
|
||||
|
||||
SkBaseDevice* init(SkBaseDevice*, InitFlags);
|
||||
|
||||
/**
|
||||
|
@ -288,7 +288,7 @@ protected:
|
||||
|
||||
protected:
|
||||
// default impl returns NULL
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&);
|
||||
virtual SkSurface* newSurface(const SkImageInfo&);
|
||||
|
||||
// default impl returns NULL
|
||||
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
|
||||
@ -343,8 +343,6 @@ protected:
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkMatrix*,
|
||||
const SkPaint*);
|
||||
|
||||
void setPixelGeometry(SkPixelGeometry geo);
|
||||
|
||||
private:
|
||||
friend class SkCanvas;
|
||||
friend struct DeviceCM; //for setMatrixClip
|
||||
|
@ -10,9 +10,6 @@
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkImage.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
|
||||
//#define SK_SUPPORT_LEGACY_TEXTRENDERMODE
|
||||
|
||||
class SkCanvas;
|
||||
class SkPaint;
|
||||
@ -38,8 +35,7 @@ public:
|
||||
* If the requested surface cannot be created, or the request is not a
|
||||
* supported configuration, NULL will be returned.
|
||||
*/
|
||||
static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes,
|
||||
const SkSurfaceProps* = NULL);
|
||||
static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* The same as NewRasterDirect, but also accepts a call-back routine, which is invoked
|
||||
@ -47,7 +43,7 @@ public:
|
||||
*/
|
||||
static SkSurface* NewRasterDirectReleaseProc(const SkImageInfo&, void* pixels, size_t rowBytes,
|
||||
void (*releaseProc)(void* pixels, void* context),
|
||||
void* context, const SkSurfaceProps* = NULL);
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* Return a new surface, with the memory for the pixels automatically
|
||||
@ -56,57 +52,17 @@ public:
|
||||
* If the requested surface cannot be created, or the request is not a
|
||||
* supported configuration, NULL will be returned.
|
||||
*/
|
||||
static SkSurface* NewRaster(const SkImageInfo&, const SkSurfaceProps* = NULL);
|
||||
static SkSurface* NewRaster(const SkImageInfo&);
|
||||
|
||||
/**
|
||||
* Helper version of NewRaster. It creates a SkImageInfo with the
|
||||
* specified width and height, and populates the rest of info to match
|
||||
* pixels in SkPMColor format.
|
||||
*/
|
||||
static SkSurface* NewRasterPMColor(int width, int height, const SkSurfaceProps* props = NULL) {
|
||||
return NewRaster(SkImageInfo::MakeN32Premul(width, height), props);
|
||||
static SkSurface* NewRasterPMColor(int width, int height) {
|
||||
return NewRaster(SkImageInfo::MakeN32Premul(width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new surface using the specified render target.
|
||||
*/
|
||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*);
|
||||
|
||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) {
|
||||
return NewRenderTargetDirect(target, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new surface whose contents will be drawn to an offscreen
|
||||
* render target, allocated by the surface.
|
||||
*/
|
||||
static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
|
||||
const SkSurfaceProps* = NULL);
|
||||
|
||||
static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info) {
|
||||
return NewRenderTarget(gr, info, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new surface whose contents will be drawn to an offscreen
|
||||
* render target, allocated by the surface from the scratch texture pool
|
||||
* managed by the GrContext. The scratch texture pool serves the purpose
|
||||
* of retaining textures after they are no longer in use in order to
|
||||
* re-use them later without having to re-allocate. Scratch textures
|
||||
* should be used in cases where high turnover is expected. This allows,
|
||||
* for example, the copy on write to recycle a texture from a recently
|
||||
* released SkImage snapshot of the surface.
|
||||
* Note: Scratch textures count against the GrContext's cached resource
|
||||
* budget.
|
||||
*/
|
||||
static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
|
||||
const SkSurfaceProps*);
|
||||
|
||||
static SkSurface* NewScratchRenderTarget(GrContext* gr, const SkImageInfo& info) {
|
||||
return NewScratchRenderTarget(gr, info, 0, NULL);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_TEXTRENDERMODE
|
||||
/**
|
||||
* Text rendering modes that can be passed to NewRenderTarget*
|
||||
*/
|
||||
@ -120,12 +76,36 @@ public:
|
||||
*/
|
||||
kDistanceField_TextRenderMode,
|
||||
};
|
||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget*, TextRenderMode);
|
||||
static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
|
||||
TextRenderMode);
|
||||
static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
|
||||
TextRenderMode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return a new surface using the specified render target.
|
||||
* The pixels in the rendertarget are not cleared or otherwised changed when the surface
|
||||
* is created.
|
||||
*/
|
||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget*,
|
||||
TextRenderMode trm = kStandard_TextRenderMode);
|
||||
|
||||
/**
|
||||
* Return a new surface whose contents will be drawn to an offscreen
|
||||
* render target, allocated by the surface.
|
||||
*/
|
||||
static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
|
||||
TextRenderMode trm = kStandard_TextRenderMode);
|
||||
|
||||
/**
|
||||
* Return a new surface whose contents will be drawn to an offscreen
|
||||
* render target, allocated by the surface from the scratch texture pool
|
||||
* managed by the GrContext. The scratch texture pool serves the purpose
|
||||
* of retaining textures after they are no longer in use in order to
|
||||
* re-use them later without having to re-allocate. Scratch textures
|
||||
* should be used in cases where high turnover is expected. This allows,
|
||||
* for example, the copy on write to recycle a texture from a recently
|
||||
* released SkImage snapshot of the surface.
|
||||
* Note: Scratch textures count against the GrContext's cached resource
|
||||
* budget.
|
||||
*/
|
||||
static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
|
||||
TextRenderMode trm = kStandard_TextRenderMode);
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
@ -214,11 +194,9 @@ public:
|
||||
*/
|
||||
const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
|
||||
|
||||
const SkSurfaceProps& props() const { return fProps; }
|
||||
|
||||
protected:
|
||||
SkSurface(int width, int height, const SkSurfaceProps*);
|
||||
SkSurface(const SkImageInfo&, const SkSurfaceProps*);
|
||||
SkSurface(int width, int height);
|
||||
SkSurface(const SkImageInfo&);
|
||||
|
||||
// called by subclass if their contents have changed
|
||||
void dirtyGenerationID() {
|
||||
@ -226,10 +204,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
const SkSurfaceProps fProps;
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
uint32_t fGenerationID;
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
uint32_t fGenerationID;
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
@ -1,80 +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 SkSurfaceProps_DEFINED
|
||||
#define SkSurfaceProps_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
/**
|
||||
* Description of how the LCD strips are arranged for each pixel. If this is unknown, or the
|
||||
* pixels are meant to be "portable" and/or transformed before showing (e.g. rotated, scaled)
|
||||
* then use kUnknown_SkPixelGeometry.
|
||||
*/
|
||||
enum SkPixelGeometry {
|
||||
kUnknown_SkPixelGeometry,
|
||||
kRGB_H_SkPixelGeometry,
|
||||
kBGR_H_SkPixelGeometry,
|
||||
kRGB_V_SkPixelGeometry,
|
||||
kBGR_V_SkPixelGeometry,
|
||||
};
|
||||
|
||||
// Returns true iff geo is a known geometry and is RGB.
|
||||
static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) {
|
||||
return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo;
|
||||
}
|
||||
|
||||
// Returns true iff geo is a known geometry and is BGR.
|
||||
static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) {
|
||||
return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
|
||||
}
|
||||
|
||||
// Returns true iff geo is a known geometry and is horizontal.
|
||||
static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) {
|
||||
return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo;
|
||||
}
|
||||
|
||||
// Returns true iff geo is a known geometry and is vertical.
|
||||
static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) {
|
||||
return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes properties and constraints of a given SkSurface. The rendering engine can parse these
|
||||
* during drawing, and can sometimes optimize its performance (e.g. disabling an expensive
|
||||
* feature).
|
||||
*/
|
||||
class SkSurfaceProps {
|
||||
public:
|
||||
enum Flags {
|
||||
kDisallowAntiAlias_Flag = 1 << 0,
|
||||
kDisallowDither_Flag = 1 << 1,
|
||||
kUseDistanceFieldFonts_Flag = 1 << 2,
|
||||
};
|
||||
SkSurfaceProps(uint32_t flags, SkPixelGeometry);
|
||||
|
||||
enum InitType {
|
||||
kLegacyFontHost_InitType
|
||||
};
|
||||
SkSurfaceProps(InitType);
|
||||
SkSurfaceProps(uint32_t flags, InitType);
|
||||
|
||||
uint32_t flags() const { return fFlags; }
|
||||
SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
|
||||
|
||||
bool isDisallowAA() const { return SkToBool(fFlags & kDisallowAntiAlias_Flag); }
|
||||
bool isDisallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); }
|
||||
bool isUseDistanceFieldFonts() const { return SkToBool(fFlags & kUseDistanceFieldFonts_Flag); }
|
||||
|
||||
private:
|
||||
SkSurfaceProps();
|
||||
|
||||
uint32_t fFlags;
|
||||
SkPixelGeometry fPixelGeometry;
|
||||
};
|
||||
|
||||
#endif
|
@ -217,7 +217,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
|
||||
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
// TODO(vandebo): push most of SkPDFDevice's state into a core object in
|
||||
|
@ -16,8 +16,7 @@
|
||||
// It also simplifies the clipping calls to only use rectangles.
|
||||
class SK_API SkNoSaveLayerCanvas : public SkCanvas {
|
||||
public:
|
||||
SkNoSaveLayerCanvas(SkBaseDevice* device)
|
||||
: INHERITED(device, NULL, kConservativeRasterClip_InitFlag)
|
||||
SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device, kConservativeRasterClip_InitFlag)
|
||||
{}
|
||||
|
||||
protected:
|
||||
|
@ -357,8 +357,8 @@ void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
||||
draw.drawSprite(src, x, y, paint);
|
||||
}
|
||||
|
||||
SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
return SkSurface::NewRaster(info, &props);
|
||||
SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) {
|
||||
return SkSurface::NewRaster(info);
|
||||
}
|
||||
|
||||
const void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCanvasPriv.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
@ -66,19 +67,6 @@ void SkCanvas::predrawNotify() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static uint32_t filter_paint_flags(const SkSurfaceProps& props, uint32_t flags) {
|
||||
const uint32_t propFlags = props.flags();
|
||||
if (propFlags & SkSurfaceProps::kDisallowDither_Flag) {
|
||||
flags &= ~SkPaint::kDither_Flag;
|
||||
}
|
||||
if (propFlags & SkSurfaceProps::kDisallowAntiAlias_Flag) {
|
||||
flags &= ~SkPaint::kAntiAlias_Flag;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* This is the record we keep for each SkBaseDevice that the user installs.
|
||||
The clip/matrix/proc are fields that reflect the top of the save/restore
|
||||
stack. Whenever the canvas changes, it marks a dirty flag, and then before
|
||||
@ -262,12 +250,12 @@ private:
|
||||
|
||||
class AutoDrawLooper {
|
||||
public:
|
||||
AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint& paint,
|
||||
AutoDrawLooper(SkCanvas* canvas, const SkPaint& paint,
|
||||
bool skipLayerForImageFilter = false,
|
||||
const SkRect* bounds = NULL) : fOrigPaint(paint) {
|
||||
fCanvas = canvas;
|
||||
fFilter = canvas->getDrawFilter();
|
||||
fPaint = &fOrigPaint;
|
||||
fPaint = NULL;
|
||||
fSaveCount = canvas->getSaveCount();
|
||||
fDoClearImageFilter = false;
|
||||
fDone = false;
|
||||
@ -292,15 +280,6 @@ public:
|
||||
// can we be marked as simple?
|
||||
fIsSimple = !fFilter && !fDoClearImageFilter;
|
||||
}
|
||||
|
||||
uint32_t oldFlags = paint.getFlags();
|
||||
fNewPaintFlags = filter_paint_flags(props, oldFlags);
|
||||
if (fIsSimple && (fNewPaintFlags != oldFlags)) {
|
||||
SkPaint* paint = fLazyPaint.set(fOrigPaint);
|
||||
paint->setFlags(fNewPaintFlags);
|
||||
fPaint = paint;
|
||||
// if we're not simple, doNext() will take care of calling setFlags()
|
||||
}
|
||||
}
|
||||
|
||||
~AutoDrawLooper() {
|
||||
@ -320,6 +299,7 @@ public:
|
||||
return false;
|
||||
} else if (fIsSimple) {
|
||||
fDone = true;
|
||||
fPaint = &fOrigPaint;
|
||||
return !fPaint->nothingToDraw();
|
||||
} else {
|
||||
return this->doNext(drawType);
|
||||
@ -333,7 +313,6 @@ private:
|
||||
SkDrawFilter* fFilter;
|
||||
const SkPaint* fPaint;
|
||||
int fSaveCount;
|
||||
uint32_t fNewPaintFlags;
|
||||
bool fDoClearImageFilter;
|
||||
bool fDone;
|
||||
bool fIsSimple;
|
||||
@ -349,7 +328,6 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
||||
SkASSERT(fLooperContext || fFilter || fDoClearImageFilter);
|
||||
|
||||
SkPaint* paint = fLazyPaint.set(fOrigPaint);
|
||||
paint->setFlags(fNewPaintFlags);
|
||||
|
||||
if (fDoClearImageFilter) {
|
||||
paint->setImageFilter(NULL);
|
||||
@ -384,17 +362,19 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "SkColorPriv.h"
|
||||
|
||||
////////// macros to place around the internal draw calls //////////////////
|
||||
|
||||
#define LOOPER_BEGIN_DRAWDEVICE(paint, type) \
|
||||
this->predrawNotify(); \
|
||||
AutoDrawLooper looper(this, fProps, paint, true); \
|
||||
AutoDrawLooper looper(this, paint, true); \
|
||||
while (looper.next(type)) { \
|
||||
SkDrawIter iter(this);
|
||||
|
||||
#define LOOPER_BEGIN(paint, type, bounds) \
|
||||
this->predrawNotify(); \
|
||||
AutoDrawLooper looper(this, fProps, paint, false, bounds); \
|
||||
AutoDrawLooper looper(this, paint, false, bounds); \
|
||||
while (looper.next(type)) { \
|
||||
SkDrawIter iter(this);
|
||||
|
||||
@ -402,10 +382,6 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkCanvas::setupDevice(SkBaseDevice* device) {
|
||||
device->setPixelGeometry(fProps.pixelGeometry());
|
||||
}
|
||||
|
||||
SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
|
||||
fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag);
|
||||
fCachedLocalClipBounds.setEmpty();
|
||||
@ -417,6 +393,10 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
|
||||
fCullCount = 0;
|
||||
fMetaData = NULL;
|
||||
|
||||
if (device && device->forceConservativeRasterClip()) {
|
||||
fConservativeRasterClip = true;
|
||||
}
|
||||
|
||||
fMCRec = (MCRec*)fMCStack.push_back();
|
||||
new (fMCRec) MCRec(fConservativeRasterClip);
|
||||
|
||||
@ -426,10 +406,6 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
|
||||
fSurfaceBase = NULL;
|
||||
|
||||
if (device) {
|
||||
this->setupDevice(device);
|
||||
if (device->forceConservativeRasterClip()) {
|
||||
fConservativeRasterClip = true;
|
||||
}
|
||||
device->onAttachToCanvas(this);
|
||||
fMCRec->fLayer->fDevice = SkRef(device);
|
||||
fMCRec->fRasterClip.setRect(SkIRect::MakeWH(device->width(), device->height()));
|
||||
@ -439,7 +415,6 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
|
||||
|
||||
SkCanvas::SkCanvas()
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
@ -463,7 +438,6 @@ private:
|
||||
|
||||
SkCanvas::SkCanvas(int width, int height)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
@ -472,16 +446,14 @@ SkCanvas::SkCanvas(int width, int height)
|
||||
|
||||
SkCanvas::SkCanvas(int width, int height, InitFlags flags)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unref();
|
||||
}
|
||||
|
||||
SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags flags)
|
||||
SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfacePropsCopyOrDefault(props))
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
@ -490,31 +462,18 @@ SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags
|
||||
|
||||
SkCanvas::SkCanvas(SkBaseDevice* device)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
this->init(device, kDefault_InitFlags);
|
||||
}
|
||||
|
||||
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)));
|
||||
this->init(device, kDefault_InitFlags);
|
||||
}
|
||||
|
||||
SkCanvas::SkCanvas(const SkBitmap& bitmap)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
||||
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
{
|
||||
inc_canvas();
|
||||
|
||||
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
|
||||
this->init(device, kDefault_InitFlags);
|
||||
|
||||
this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)), kDefault_InitFlags)->unref();
|
||||
}
|
||||
|
||||
SkCanvas::~SkCanvas() {
|
||||
@ -605,7 +564,6 @@ SkBaseDevice* SkCanvas::setRootDevice(SkBaseDevice* device) {
|
||||
|
||||
SkRefCnt_SafeAssign(rec->fLayer->fDevice, device);
|
||||
rootDevice = device;
|
||||
this->setupDevice(device);
|
||||
|
||||
fDeviceCMDirty = true;
|
||||
|
||||
@ -941,7 +899,6 @@ int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Save
|
||||
SkDebugf("Unable to create device for layer.");
|
||||
return count;
|
||||
}
|
||||
this->setupDevice(device);
|
||||
|
||||
device->setOrigin(ir.fLeft, ir.fTop);
|
||||
DeviceCM* layer = SkNEW_ARGS(DeviceCM,
|
||||
@ -1037,16 +994,13 @@ bool SkCanvas::isDrawingToLayer() const {
|
||||
return fSaveLayerCount > 0;
|
||||
}
|
||||
|
||||
SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* props) {
|
||||
if (NULL == props) {
|
||||
props = &fProps;
|
||||
}
|
||||
return this->onNewSurface(info, *props);
|
||||
SkSurface* SkCanvas::newSurface(const SkImageInfo& info) {
|
||||
return this->onNewSurface(info);
|
||||
}
|
||||
|
||||
SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) {
|
||||
SkBaseDevice* dev = this->getDevice();
|
||||
return dev ? dev->newSurface(info, props) : NULL;
|
||||
return dev ? dev->newSurface(info) : NULL;
|
||||
}
|
||||
|
||||
SkImageInfo SkCanvas::imageInfo() const {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
SkBaseDevice::SkBaseDevice()
|
||||
: fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLegacyLCD_InitType)))
|
||||
: fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::MakeDefault())))
|
||||
#ifdef SK_DEBUG
|
||||
, fAttachedToCanvas(false)
|
||||
#endif
|
||||
@ -57,11 +57,7 @@ const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
void SkBaseDevice::setPixelGeometry(SkPixelGeometry geo) {
|
||||
fLeakyProperties->fPixelGeometry = geo;
|
||||
}
|
||||
|
||||
SkSurface* SkBaseDevice::newSurface(const SkImageInfo&, const SkSurfaceProps&) { return NULL; }
|
||||
SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; }
|
||||
|
||||
const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; }
|
||||
|
||||
|
@ -1,26 +1,103 @@
|
||||
/*
|
||||
* 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"
|
||||
//TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import.
|
||||
#include "SkFontLCDConfig.h"
|
||||
|
||||
struct SkDeviceProperties {
|
||||
enum InitType {
|
||||
kLegacyLCD_InitType
|
||||
struct Geometry {
|
||||
/** The orientation of the pixel specifies the interpretation of the
|
||||
* layout. If the orientation is horizontal, the layout is interpreted as
|
||||
* left to right. It the orientation is vertical, the layout is
|
||||
* interpreted top to bottom (rotated 90deg cw from horizontal).
|
||||
*/
|
||||
enum Orientation {
|
||||
kUnknown_Orientation = 0x0,
|
||||
kKnown_Orientation = 0x2,
|
||||
|
||||
kHorizontal_Orientation = 0x2, //!< this is the default
|
||||
kVertical_Orientation = 0x3,
|
||||
|
||||
kOrientationMask = 0x3,
|
||||
};
|
||||
|
||||
/** The layout of the pixel specifies its subpixel geometry.
|
||||
*
|
||||
* kUnknown_Layout means that the subpixel elements are not spatially
|
||||
* separated in any known or usable fashion.
|
||||
*/
|
||||
enum Layout {
|
||||
kUnknown_Layout = 0x0,
|
||||
kKnown_Layout = 0x8,
|
||||
|
||||
kRGB_Layout = 0x8, //!< this is the default
|
||||
kBGR_Layout = 0xC,
|
||||
|
||||
kLayoutMask = 0xC,
|
||||
};
|
||||
|
||||
Orientation getOrientation() {
|
||||
return static_cast<Orientation>(fGeometry & kOrientationMask);
|
||||
}
|
||||
Layout getLayout() {
|
||||
return static_cast<Layout>(fGeometry & kLayoutMask);
|
||||
}
|
||||
|
||||
bool isOrientationKnown() {
|
||||
return SkToBool(fGeometry & kKnown_Orientation);
|
||||
}
|
||||
bool isLayoutKnown() {
|
||||
return SkToBool(fGeometry & kKnown_Layout);
|
||||
}
|
||||
|
||||
private:
|
||||
//TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and replace these calls with constants.
|
||||
static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation orientation) {
|
||||
switch (orientation) {
|
||||
case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal_Orientation;
|
||||
case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Orientation;
|
||||
default: return kUnknown_Orientation;
|
||||
}
|
||||
}
|
||||
static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) {
|
||||
switch (order) {
|
||||
case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout;
|
||||
case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout;
|
||||
default: return kUnknown_Layout;
|
||||
}
|
||||
}
|
||||
public:
|
||||
static Geometry MakeDefault() {
|
||||
Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSubpixelOrientation()); //kHorizontal_Orientation
|
||||
Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout
|
||||
Geometry ret = { SkToU8(orientation | layout) };
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Geometry Make(Orientation orientation, Layout layout) {
|
||||
Geometry ret = { SkToU8(orientation | layout) };
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t fGeometry;
|
||||
};
|
||||
SkDeviceProperties(InitType) : fPixelGeometry(SkSurfacePropsDefaultPixelGeometry()) {}
|
||||
SkDeviceProperties(SkPixelGeometry geo) : fPixelGeometry(geo) {}
|
||||
|
||||
SkPixelGeometry fPixelGeometry;
|
||||
static SkDeviceProperties MakeDefault() {
|
||||
SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT };
|
||||
return ret;
|
||||
}
|
||||
|
||||
// read-only attribute -- until we actually store a value (future CL)
|
||||
float getGamma() const { return SK_GAMMA_EXPONENT; }
|
||||
static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) {
|
||||
SkDeviceProperties ret = { geometry, gamma };
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Each pixel of an image will have some number of channels.
|
||||
* Can the layout of those channels be exploited? */
|
||||
Geometry fGeometry;
|
||||
|
||||
/** Represents the color space of the image. This is a woefully inadequate beginning. */
|
||||
SkScalar fGamma;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1607,33 +1607,19 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
|
||||
|
||||
rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
|
||||
|
||||
SkDeviceProperties::Geometry geometry = deviceProperties
|
||||
? deviceProperties->fGeometry
|
||||
: SkDeviceProperties::Geometry::MakeDefault();
|
||||
if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == rec->fMaskFormat) {
|
||||
if (tooBigForLCD(*rec)) {
|
||||
if (!geometry.isOrientationKnown() || !geometry.isLayoutKnown() || tooBigForLCD(*rec)) {
|
||||
// eeek, can't support LCD
|
||||
rec->fMaskFormat = SkMask::kA8_Format;
|
||||
flags |= SkScalerContext::kGenA8FromLCD_Flag;
|
||||
} else {
|
||||
SkPixelGeometry geometry = deviceProperties
|
||||
? deviceProperties->fPixelGeometry
|
||||
: SkSurfacePropsDefaultPixelGeometry();
|
||||
switch (geometry) {
|
||||
case kUnknown_SkPixelGeometry:
|
||||
// eeek, can't support LCD
|
||||
rec->fMaskFormat = SkMask::kA8_Format;
|
||||
flags |= SkScalerContext::kGenA8FromLCD_Flag;
|
||||
break;
|
||||
case kRGB_H_SkPixelGeometry:
|
||||
// our default, do nothing.
|
||||
break;
|
||||
case kBGR_H_SkPixelGeometry:
|
||||
flags |= SkScalerContext::kLCD_BGROrder_Flag;
|
||||
break;
|
||||
case kRGB_V_SkPixelGeometry:
|
||||
flags |= SkScalerContext::kLCD_Vertical_Flag;
|
||||
break;
|
||||
case kBGR_V_SkPixelGeometry:
|
||||
flags |= SkScalerContext::kLCD_Vertical_Flag;
|
||||
flags |= SkScalerContext::kLCD_BGROrder_Flag;
|
||||
break;
|
||||
if (SkDeviceProperties::Geometry::kVertical_Orientation == geometry.getOrientation()) {
|
||||
flags |= SkScalerContext::kLCD_Vertical_Flag;
|
||||
}
|
||||
if (SkDeviceProperties::Geometry::kBGR_Layout == geometry.getLayout()) {
|
||||
flags |= SkScalerContext::kLCD_BGROrder_Flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1664,13 +1650,13 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
|
||||
rec->setDeviceGamma(SK_GAMMA_EXPONENT);
|
||||
rec->setPaintGamma(SK_GAMMA_EXPONENT);
|
||||
} else {
|
||||
rec->setDeviceGamma(deviceProperties->getGamma());
|
||||
rec->setDeviceGamma(deviceProperties->fGamma);
|
||||
|
||||
//For now always set the paint gamma equal to the device gamma.
|
||||
//The math in SkMaskGamma can handle them being different,
|
||||
//but it requires superluminous masks when
|
||||
//Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large.
|
||||
rec->setPaintGamma(deviceProperties->getGamma());
|
||||
rec->setPaintGamma(deviceProperties->fGamma);
|
||||
}
|
||||
|
||||
#ifdef SK_GAMMA_CONTRAST
|
||||
|
@ -1429,7 +1429,7 @@ void SkPictureRecord::onPopCull() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) {
|
||||
SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ protected:
|
||||
SkASSERT(fWriter.bytesWritten() == initialOffset + size);
|
||||
}
|
||||
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
void drawData(const void*, size_t) SK_OVERRIDE;
|
||||
|
||||
bool isDrawingToLayer() const SK_OVERRIDE;
|
||||
SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE { return NULL; }
|
||||
SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE { return NULL; }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
|
@ -1,25 +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 SkSurfacePriv_DEFINED
|
||||
#define SkSurfacePriv_DEFINED
|
||||
|
||||
#include "SkSurfaceProps.h"
|
||||
|
||||
static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* props) {
|
||||
if (props) {
|
||||
return *props;
|
||||
} else {
|
||||
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
}
|
||||
}
|
||||
|
||||
static inline SkPixelGeometry SkSurfacePropsDefaultPixelGeometry() {
|
||||
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometry();
|
||||
}
|
||||
|
||||
#endif
|
@ -131,7 +131,8 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
|
||||
flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0;
|
||||
flags |= fUseLCDText && fTextMatrix.rectStaysRect() ?
|
||||
kRectToRect_DistanceFieldEffectFlag : 0;
|
||||
bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry);
|
||||
bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout ==
|
||||
fDeviceProperties.fGeometry.getLayout();
|
||||
flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
|
||||
|
||||
// see if we need to create a new effect
|
||||
@ -148,7 +149,7 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
|
||||
flags));
|
||||
} else {
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.getGamma(),
|
||||
U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.fGamma,
|
||||
filteredColor);
|
||||
fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
|
||||
params,
|
||||
@ -501,8 +502,8 @@ static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache,
|
||||
#else
|
||||
SkScalar contrast = 0.5f;
|
||||
#endif
|
||||
SkScalar paintGamma = deviceProperties.getGamma();
|
||||
SkScalar deviceGamma = deviceProperties.getGamma();
|
||||
SkScalar paintGamma = deviceProperties.fGamma;
|
||||
SkScalar deviceGamma = deviceProperties.fGamma;
|
||||
|
||||
size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma,
|
||||
&width, &height);
|
||||
|
@ -142,7 +142,8 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture,
|
||||
if (atlased.count() > 0) {
|
||||
// All the atlased layers are rendered into the same GrTexture
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
|
||||
atlased[0]->texture()->asRenderTarget(), NULL));
|
||||
atlased[0]->texture()->asRenderTarget(),
|
||||
SkSurface::kStandard_TextRenderMode));
|
||||
|
||||
SkCanvas* atlasCanvas = surface->getCanvas();
|
||||
|
||||
@ -195,7 +196,8 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture,
|
||||
|
||||
// Each non-atlased layer has its own GrTexture
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
|
||||
layer->texture()->asRenderTarget(), NULL));
|
||||
layer->texture()->asRenderTarget(),
|
||||
SkSurface::kStandard_TextRenderMode));
|
||||
|
||||
SkCanvas* layerCanvas = surface->getCanvas();
|
||||
|
||||
|
@ -133,15 +133,15 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) {
|
||||
SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, unsigned flags) {
|
||||
SkASSERT(surface);
|
||||
if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkGpuDevice, (surface, props, flags));
|
||||
return SkNEW_ARGS(SkGpuDevice, (surface, flags));
|
||||
}
|
||||
|
||||
SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) {
|
||||
SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) {
|
||||
|
||||
fDrawProcs = NULL;
|
||||
|
||||
@ -156,15 +156,13 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign
|
||||
fLegacyBitmap.setInfo(surface->info());
|
||||
fLegacyBitmap.setPixelRef(pr)->unref();
|
||||
|
||||
this->setPixelGeometry(props.pixelGeometry());
|
||||
|
||||
bool useDFFonts = !!(flags & kDFFonts_Flag);
|
||||
fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts);
|
||||
fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getLeakyProperties()));
|
||||
}
|
||||
|
||||
SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo,
|
||||
const SkSurfaceProps& props, int sampleCount) {
|
||||
int sampleCount) {
|
||||
if (kUnknown_SkColorType == origInfo.colorType() ||
|
||||
origInfo.width() < 0 || origInfo.height() < 0) {
|
||||
return NULL;
|
||||
@ -196,7 +194,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SkNEW_ARGS(SkGpuDevice, (texture.get(), props));
|
||||
return SkNEW_ARGS(SkGpuDevice, (texture.get()));
|
||||
}
|
||||
|
||||
SkGpuDevice::~SkGpuDevice() {
|
||||
@ -1807,7 +1805,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
|
||||
texture.reset(fContext->createUncachedTexture(desc, NULL, 0));
|
||||
#endif
|
||||
if (texture.get()) {
|
||||
return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), flags);
|
||||
return SkGpuDevice::Create(texture, flags);
|
||||
} else {
|
||||
GrPrintf("---- failed to create compatible device texture [%d %d]\n",
|
||||
info.width(), info.height());
|
||||
@ -1815,8 +1813,8 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
|
||||
}
|
||||
}
|
||||
|
||||
SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples(), &props);
|
||||
SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
|
||||
return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
|
||||
}
|
||||
|
||||
void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
* the kCached_Flag should be specified to make the device responsible for unlocking
|
||||
* the surface when it is released.
|
||||
*/
|
||||
static SkGpuDevice* Create(GrSurface* surface, const SkSurfaceProps&, unsigned flags = 0);
|
||||
static SkGpuDevice* Create(GrSurface* surface, unsigned flags = 0);
|
||||
|
||||
/**
|
||||
* New device that will create an offscreen renderTarget based on the
|
||||
@ -51,8 +51,7 @@ public:
|
||||
* count against the GrContext's texture cache budget. The device's pixels
|
||||
* will be uninitialized. On failure, returns NULL.
|
||||
*/
|
||||
static SkGpuDevice* Create(GrContext*, const SkImageInfo&, const SkSurfaceProps&,
|
||||
int sampleCount);
|
||||
static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount);
|
||||
|
||||
virtual ~SkGpuDevice();
|
||||
|
||||
@ -146,11 +145,11 @@ private:
|
||||
// remove when our clients don't rely on accessBitmap()
|
||||
SkBitmap fLegacyBitmap;
|
||||
|
||||
SkGpuDevice(GrSurface*, const SkSurfaceProps&, unsigned flags = 0);
|
||||
SkGpuDevice(GrSurface*, unsigned flags = 0);
|
||||
|
||||
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
|
||||
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
|
||||
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
|
||||
virtual SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE;
|
||||
|
||||
|
@ -9,56 +9,14 @@
|
||||
#include "SkImagePriv.h"
|
||||
#include "SkCanvas.h"
|
||||
|
||||
#include "SkFontLCDConfig.h"
|
||||
static SkPixelGeometry compute_default_geometry() {
|
||||
SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
|
||||
if (SkFontLCDConfig::kNONE_LCDOrder == order) {
|
||||
return kUnknown_SkPixelGeometry;
|
||||
} else {
|
||||
// Bit0 is RGB(0), BGR(1)
|
||||
// Bit1 is H(0), V(1)
|
||||
const SkPixelGeometry gGeo[] = {
|
||||
kRGB_H_SkPixelGeometry,
|
||||
kBGR_H_SkPixelGeometry,
|
||||
kRGB_V_SkPixelGeometry,
|
||||
kBGR_V_SkPixelGeometry,
|
||||
};
|
||||
int index = 0;
|
||||
if (SkFontLCDConfig::kBGR_LCDOrder == order) {
|
||||
index |= 1;
|
||||
}
|
||||
if (SkFontLCDConfig::kVertical_LCDOrientation == SkFontLCDConfig::GetSubpixelOrientation()){
|
||||
index |= 2;
|
||||
}
|
||||
return gGeo[index];
|
||||
}
|
||||
}
|
||||
|
||||
SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
|
||||
|
||||
SkSurfaceProps::SkSurfaceProps(InitType) : fFlags(0), fPixelGeometry(compute_default_geometry()) {}
|
||||
|
||||
SkSurfaceProps::SkSurfaceProps(uint32_t flags, InitType)
|
||||
: fFlags(flags)
|
||||
, fPixelGeometry(compute_default_geometry())
|
||||
{}
|
||||
|
||||
SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
|
||||
: fFlags(flags), fPixelGeometry(pg)
|
||||
{}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface_Base::SkSurface_Base(int width, int height, const SkSurfaceProps* props)
|
||||
: INHERITED(width, height, props)
|
||||
{
|
||||
SkSurface_Base::SkSurface_Base(int width, int height) : INHERITED(width, height) {
|
||||
fCachedCanvas = NULL;
|
||||
fCachedImage = NULL;
|
||||
}
|
||||
|
||||
SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const SkSurfaceProps* props)
|
||||
: INHERITED(info, props)
|
||||
{
|
||||
SkSurface_Base::SkSurface_Base(const SkImageInfo& info) : INHERITED(info) {
|
||||
fCachedCanvas = NULL;
|
||||
fCachedImage = NULL;
|
||||
}
|
||||
@ -73,7 +31,8 @@ SkSurface_Base::~SkSurface_Base() {
|
||||
SkSafeUnref(fCachedCanvas);
|
||||
}
|
||||
|
||||
void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) {
|
||||
void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
|
||||
const SkPaint* paint) {
|
||||
SkImage* image = this->newImageSnapshot();
|
||||
if (image) {
|
||||
image->draw(canvas, x, y, paint);
|
||||
@ -115,17 +74,13 @@ static SkSurface_Base* asSB(SkSurface* surface) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface::SkSurface(int width, int height, const SkSurfaceProps* props)
|
||||
: fProps(SkSurfacePropsCopyOrDefault(props)), fWidth(width), fHeight(height)
|
||||
{
|
||||
SkSurface::SkSurface(int width, int height) : fWidth(width), fHeight(height) {
|
||||
SkASSERT(fWidth >= 0);
|
||||
SkASSERT(fHeight >= 0);
|
||||
fGenerationID = 0;
|
||||
}
|
||||
|
||||
SkSurface::SkSurface(const SkImageInfo& info, const SkSurfaceProps* props)
|
||||
: fProps(SkSurfacePropsCopyOrDefault(props)), fWidth(info.width()), fHeight(info.height())
|
||||
{
|
||||
SkSurface::SkSurface(const SkImageInfo& info) : fWidth(info.width()), fHeight(info.height()) {
|
||||
SkASSERT(fWidth >= 0);
|
||||
SkASSERT(fHeight >= 0);
|
||||
fGenerationID = 0;
|
||||
@ -164,51 +119,3 @@ void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y,
|
||||
const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) {
|
||||
return this->getCanvas()->peekPixels(info, rowBytes);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef SK_SUPPORT_LEGACY_TEXTRENDERMODE
|
||||
|
||||
static SkSurfaceProps make_props(SkSurface::TextRenderMode trm) {
|
||||
uint32_t propsFlags = 0;
|
||||
if (SkSurface::kDistanceField_TextRenderMode == trm) {
|
||||
propsFlags |= SkSurfaceProps::kUseDistanceFieldFonts_Flag;
|
||||
}
|
||||
return SkSurfaceProps(propsFlags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm,
|
||||
RenderTargetFlags flags) {
|
||||
SkSurfaceProps props = make_props(trm);
|
||||
return NewRenderTargetDirect(target, &props, flags);
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRenderTarget(GrContext* gr, const SkImageInfo& info, int sampleCount,
|
||||
TextRenderMode trm, RenderTargetFlags flags) {
|
||||
SkSurfaceProps props = make_props(trm);
|
||||
return NewRenderTarget(gr, info, sampleCount, &props, flags);
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewScratchRenderTarget(GrContext* gr, const SkImageInfo& info, int sampleCount,
|
||||
TextRenderMode trm, RenderTargetFlags flags) {
|
||||
SkSurfaceProps props = make_props(trm);
|
||||
return NewScratchRenderTarget(gr, info, sampleCount, &props, flags);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !SK_SUPPORT_GPU
|
||||
|
||||
SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRenderTarget(GrContext*, const SkImageInfo&, int, const SkSurfaceProps*) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount,
|
||||
const SkSurfaceProps*) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,14 +8,13 @@
|
||||
#ifndef SkSurface_Base_DEFINED
|
||||
#define SkSurface_Base_DEFINED
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkSurfacePriv.h"
|
||||
#include "SkCanvas.h"
|
||||
|
||||
class SkSurface_Base : public SkSurface {
|
||||
public:
|
||||
SkSurface_Base(int width, int height, const SkSurfaceProps*);
|
||||
SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
|
||||
SkSurface_Base(int width, int height);
|
||||
explicit SkSurface_Base(const SkImageInfo&);
|
||||
virtual ~SkSurface_Base();
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ class SkSurface_Gpu : public SkSurface_Base {
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(SkSurface_Gpu)
|
||||
|
||||
SkSurface_Gpu(GrRenderTarget*, bool cached, const SkSurfaceProps*, bool doClear);
|
||||
SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, bool doClear);
|
||||
virtual ~SkSurface_Gpu();
|
||||
|
||||
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
||||
@ -33,14 +33,13 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, const SkSurfaceProps* props,
|
||||
SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
|
||||
bool doClear)
|
||||
: INHERITED(renderTarget->width(), renderTarget->height(), props)
|
||||
{
|
||||
: INHERITED(renderTarget->width(), renderTarget->height()) {
|
||||
int deviceFlags = 0;
|
||||
deviceFlags |= cached ? SkGpuDevice::kCached_Flag : 0;
|
||||
deviceFlags |= this->props().isUseDistanceFieldFonts() ? SkGpuDevice::kDFFonts_Flag : 0;
|
||||
fDevice = SkGpuDevice::Create(renderTarget, this->props(), deviceFlags);
|
||||
deviceFlags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
|
||||
fDevice = SkGpuDevice::Create(renderTarget, deviceFlags);
|
||||
|
||||
if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) {
|
||||
fDevice->clear(0x0);
|
||||
@ -52,17 +51,13 @@ SkSurface_Gpu::~SkSurface_Gpu() {
|
||||
}
|
||||
|
||||
SkCanvas* SkSurface_Gpu::onNewCanvas() {
|
||||
SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
|
||||
// When we think this works...
|
||||
// flags |= SkCanvas::kConservativeRasterClip_InitFlag;
|
||||
|
||||
return SkNEW_ARGS(SkCanvas, (fDevice, &this->props(), flags));
|
||||
return SkNEW_ARGS(SkCanvas, (fDevice));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
|
||||
GrRenderTarget* rt = fDevice->accessRenderTarget();
|
||||
int sampleCount = rt->numSamples();
|
||||
return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount, &this->props());
|
||||
return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount);
|
||||
}
|
||||
|
||||
SkImage* SkSurface_Gpu::onNewImageSnapshot() {
|
||||
@ -107,15 +102,15 @@ void SkSurface_Gpu::onDiscard() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurfaceProps* props) {
|
||||
SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm) {
|
||||
if (NULL == target) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (target, false, props, false));
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, false));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
|
||||
const SkSurfaceProps* props) {
|
||||
TextRenderMode trm) {
|
||||
if (NULL == ctx) {
|
||||
return NULL;
|
||||
}
|
||||
@ -132,11 +127,11 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, props, true));
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, true));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
|
||||
int sampleCount, const SkSurfaceProps* props) {
|
||||
int sampleCount, TextRenderMode trm) {
|
||||
if (NULL == ctx) {
|
||||
return NULL;
|
||||
}
|
||||
@ -154,5 +149,5 @@ SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, props, true));
|
||||
return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, true));
|
||||
}
|
||||
|
@ -18,9 +18,8 @@ public:
|
||||
static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
|
||||
|
||||
SkSurface_Raster(const SkImageInfo&, void*, size_t rb,
|
||||
void (*releaseProc)(void* pixels, void* context), void* context,
|
||||
const SkSurfaceProps*);
|
||||
SkSurface_Raster(SkPixelRef*, const SkSurfaceProps*);
|
||||
void (*releaseProc)(void* pixels, void* context), void* context);
|
||||
SkSurface_Raster(SkPixelRef*);
|
||||
|
||||
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
@ -79,16 +78,15 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
|
||||
}
|
||||
|
||||
SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb,
|
||||
void (*releaseProc)(void* pixels, void* context), void* context,
|
||||
const SkSurfaceProps* props)
|
||||
: INHERITED(info, props)
|
||||
void (*releaseProc)(void* pixels, void* context), void* context)
|
||||
: INHERITED(info)
|
||||
{
|
||||
fBitmap.installPixels(info, pixels, rb, NULL, releaseProc, context);
|
||||
fWeOwnThePixels = false; // We are "Direct"
|
||||
}
|
||||
|
||||
SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props)
|
||||
: INHERITED(pr->info().width(), pr->info().height(), props)
|
||||
SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr)
|
||||
: INHERITED(pr->info().width(), pr->info().height())
|
||||
{
|
||||
const SkImageInfo& info = pr->info();
|
||||
|
||||
@ -102,7 +100,7 @@ SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props)
|
||||
}
|
||||
|
||||
SkCanvas* SkSurface_Raster::onNewCanvas() {
|
||||
return SkNEW_ARGS(SkCanvas, (fBitmap, this->props()));
|
||||
return SkNEW_ARGS(SkCanvas, (fBitmap));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
|
||||
@ -142,7 +140,7 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
|
||||
|
||||
SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void* pixels, size_t rb,
|
||||
void (*releaseProc)(void* pixels, void* context),
|
||||
void* context, const SkSurfaceProps* props) {
|
||||
void* context) {
|
||||
if (NULL == releaseProc) {
|
||||
context = NULL;
|
||||
}
|
||||
@ -153,15 +151,14 @@ SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context, props));
|
||||
return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
const SkSurfaceProps* props) {
|
||||
return NewRasterDirectReleaseProc(info, pixels, rowBytes, NULL, NULL, props);
|
||||
SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes) {
|
||||
return NewRasterDirectReleaseProc(info, pixels, rowBytes, NULL, NULL);
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* props) {
|
||||
SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
|
||||
if (!SkSurface_Raster::Valid(info)) {
|
||||
return NULL;
|
||||
}
|
||||
@ -170,5 +167,5 @@ SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p
|
||||
if (NULL == pr.get()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkSurface_Raster, (pr, props));
|
||||
return SkNEW_ARGS(SkSurface_Raster, (pr));
|
||||
}
|
||||
|
@ -1261,8 +1261,8 @@ void SkPDFDevice::onDetachFromCanvas() {
|
||||
fClipStack = NULL;
|
||||
}
|
||||
|
||||
SkSurface* SkPDFDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
return SkSurface::NewRaster(info, &props);
|
||||
SkSurface* SkPDFDevice::newSurface(const SkImageInfo& info) {
|
||||
return SkSurface::NewRaster(info);
|
||||
}
|
||||
|
||||
ContentEntry* SkPDFDevice::getLastContentEntry() {
|
||||
|
@ -40,7 +40,6 @@ static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) {
|
||||
|
||||
static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) {
|
||||
CGDataProviderRef data = SkStreamToDataProvider(stream);
|
||||
SkASSERT(data);
|
||||
CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0);
|
||||
CGDataProviderRelease(data);
|
||||
return imageSrc;
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
|
||||
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
|
||||
|
||||
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
|
||||
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
|
||||
@ -474,8 +474,8 @@ SkBaseDevice* SkDeferredDevice::onCreateDevice(const SkImageInfo& info, Usage us
|
||||
return immediateDevice()->createCompatibleDevice(info);
|
||||
}
|
||||
|
||||
SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
return this->immediateDevice()->newSurface(info, props);
|
||||
SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) {
|
||||
return this->immediateDevice()->newSurface(info);
|
||||
}
|
||||
|
||||
bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
|
@ -51,7 +51,7 @@ static SkPMColor read_pixel(SkSurface* surface, int x, int y) {
|
||||
|
||||
class MockSurface : public SkSurface_Base {
|
||||
public:
|
||||
MockSurface(int width, int height) : SkSurface_Base(width, height, NULL) {
|
||||
MockSurface(int width, int height) : SkSurface_Base(width, height) {
|
||||
clearCounts();
|
||||
fBitmap.allocN32Pixels(width, height);
|
||||
}
|
||||
@ -706,7 +706,7 @@ static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFac
|
||||
return;
|
||||
}
|
||||
|
||||
surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
|
||||
surface = SkSurface::NewRenderTarget(context, imageSpec);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@ -788,8 +788,8 @@ static void TestDeferredCanvasSetSurface(skiatest::Reporter* reporter, GrContext
|
||||
if (NULL == context) {
|
||||
continue;
|
||||
}
|
||||
surface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
|
||||
alternateSurface = SkSurface::NewRenderTarget(context, imageSpec, 0, NULL);
|
||||
surface = SkSurface::NewRenderTarget(context, imageSpec);
|
||||
alternateSurface = SkSurface::NewRenderTarget(context, imageSpec);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -56,8 +56,7 @@ DEF_GPUTEST(GpuDrawPath, reporter, factory) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
|
||||
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext, info,
|
||||
sampleCounts[i], NULL));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext, info, sampleCounts[i]));
|
||||
test_drawPathEmpty(reporter, surface->getCanvas());
|
||||
}
|
||||
}
|
||||
|
@ -1000,13 +1000,10 @@ DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const SkSurfaceProps gProps = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
|
||||
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
|
||||
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
gProps,
|
||||
0));
|
||||
test_crop_rects(device, reporter);
|
||||
}
|
||||
@ -1015,7 +1012,6 @@ DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) {
|
||||
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkImageInfo::MakeN32Premul(100, 100),
|
||||
gProps,
|
||||
0));
|
||||
test_huge_blur(device, reporter);
|
||||
}
|
||||
@ -1024,7 +1020,6 @@ DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
|
||||
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
gProps,
|
||||
0));
|
||||
test_xfermode_cropped_input(device, reporter);
|
||||
}
|
||||
@ -1033,7 +1028,6 @@ DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
|
||||
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
|
||||
SkImageInfo::MakeN32Premul(1, 1),
|
||||
gProps,
|
||||
0));
|
||||
test_negative_blur_sigma(device, reporter);
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
|
||||
continue;
|
||||
}
|
||||
|
||||
device.reset(SkGpuDevice::Create(context, info,
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), 0));
|
||||
device.reset(SkGpuDevice::Create(context, info, 0));
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
|
@ -81,8 +81,7 @@ DEF_GPUTEST(ReadWriteAlpha, reporter, factory) {
|
||||
REPORTER_ASSERT(reporter, match);
|
||||
|
||||
// Now try writing on the single channel texture
|
||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget(),
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)));
|
||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget()));
|
||||
SkCanvas canvas(device);
|
||||
|
||||
SkPaint paint;
|
||||
|
@ -298,7 +298,7 @@ DEF_GPUTEST(ResourceCache, reporter, factory) {
|
||||
desc.fWidth = gWidth;
|
||||
desc.fHeight = gHeight;
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, info));
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, info, 0));
|
||||
|
||||
test_cache(reporter, context, surface->getCanvas());
|
||||
test_purge_invalidated(reporter, context);
|
||||
|
@ -52,7 +52,7 @@ static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context,
|
||||
}
|
||||
case kGpu_SurfaceType:
|
||||
#if SK_SUPPORT_GPU
|
||||
return context ? SkSurface::NewRenderTarget(context, info, 0, NULL) : NULL;
|
||||
return context ? SkSurface::NewRenderTarget(context, info) : NULL;
|
||||
#endif
|
||||
break;
|
||||
case kGpuScratch_SurfaceType:
|
||||
|
@ -157,8 +157,7 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(target,
|
||||
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)));
|
||||
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(target));
|
||||
canvas = SkNEW_ARGS(SkCanvas, (device.get()));
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user