aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkSurface.cpp105
-rw-r--r--src/image/SkSurface_Base.h7
-rw-r--r--src/image/SkSurface_Gpu.cpp31
-rw-r--r--src/image/SkSurface_Raster.cpp29
4 files changed, 35 insertions, 137 deletions
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index 2d0ce7062f..3a28e421a8 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -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
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index 4da4cfb496..e7fa57af0d 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -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();
/**
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 024c151cea..d7260ac29e 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -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));
}
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index cd4f049c41..13f215589f 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -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));
}