diff options
author | reed <reed@chromium.org> | 2014-09-21 10:25:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-21 10:25:07 -0700 |
commit | 29c857d0f3a1cb837f73406eeb6ba9771879b5e7 (patch) | |
tree | 135d517cf36f82b7f6f02fd81bfef92eb8befe34 /include | |
parent | 3716fd067a5621bb94a6cb08d72afec8bf3aceda (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkBitmapDevice.h | 2 | ||||
-rw-r--r-- | include/core/SkCanvas.h | 21 | ||||
-rw-r--r-- | include/core/SkDevice.h | 4 | ||||
-rw-r--r-- | include/core/SkSurface.h | 89 | ||||
-rw-r--r-- | include/core/SkSurfaceProps.h | 80 | ||||
-rw-r--r-- | include/pdf/SkPDFDevice.h | 2 | ||||
-rw-r--r-- | include/utils/SkNoSaveLayerCanvas.h | 3 |
7 files changed, 41 insertions, 160 deletions
diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index 0ab0234772..39bbab63e5 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -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; diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 77038c3067..5088d7ded5 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -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); /** diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 08320bf7b4..e74e95f2f3 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -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 diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index e0e60ab7fb..1871c676f2 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -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,36 +52,45 @@ 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)); } /** + * Text rendering modes that can be passed to NewRenderTarget* + */ + enum TextRenderMode { + /** + * This will use the standard text rendering method + */ + kStandard_TextRenderMode, + /** + * This will use signed distance fields for text rendering when possible + */ + kDistanceField_TextRenderMode, + }; + + /** * 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*, const SkSurfaceProps*); - - static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { - return NewRenderTargetDirect(target, NULL); - } - + 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, - const SkSurfaceProps* = NULL); - - static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info) { - return NewRenderTarget(gr, info, 0, NULL); - } + 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 @@ -99,33 +104,8 @@ public: * 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* - */ - enum TextRenderMode { - /** - * This will use the standard text rendering method - */ - kStandard_TextRenderMode, - /** - * This will use signed distance fields for text rendering when possible - */ - 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 + 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; }; diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h deleted file mode 100644 index 0154473914..0000000000 --- a/include/core/SkSurfaceProps.h +++ /dev/null @@ -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 diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index 0bfbc36d1a..bcdcfb24e4 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -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 diff --git a/include/utils/SkNoSaveLayerCanvas.h b/include/utils/SkNoSaveLayerCanvas.h index b6926973e0..56a09622a0 100644 --- a/include/utils/SkNoSaveLayerCanvas.h +++ b/include/utils/SkNoSaveLayerCanvas.h @@ -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: |