2014-09-22 14:29:03 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
2014-09-22 14:29:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*/
|
2014-11-04 01:07:35 +00:00
|
|
|
class SK_API SkSurfaceProps {
|
2014-09-22 14:29:03 +00:00
|
|
|
public:
|
|
|
|
enum Flags {
|
2016-08-18 16:30:44 +00:00
|
|
|
kUseDeviceIndependentFonts_Flag = 1 << 0,
|
2021-07-13 17:54:22 +00:00
|
|
|
// Use internal MSAA to render to non-MSAA GPU surfaces.
|
|
|
|
kDynamicMSAA_Flag = 1 << 1
|
2014-09-22 14:29:03 +00:00
|
|
|
};
|
2015-08-31 19:39:41 +00:00
|
|
|
/** Deprecated alias used by Chromium. Will be removed. */
|
|
|
|
static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag;
|
|
|
|
|
2020-10-23 15:29:03 +00:00
|
|
|
/** No flags, unknown pixel geometry. */
|
2020-09-24 18:49:00 +00:00
|
|
|
SkSurfaceProps();
|
2014-09-22 14:29:03 +00:00
|
|
|
SkSurfaceProps(uint32_t flags, SkPixelGeometry);
|
|
|
|
|
2020-03-23 21:22:24 +00:00
|
|
|
SkSurfaceProps(const SkSurfaceProps&);
|
|
|
|
SkSurfaceProps& operator=(const SkSurfaceProps&);
|
2014-09-22 14:29:03 +00:00
|
|
|
|
2021-04-19 22:33:29 +00:00
|
|
|
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const {
|
|
|
|
return SkSurfaceProps(fFlags, newPixelGeometry);
|
|
|
|
}
|
|
|
|
|
2014-09-22 14:29:03 +00:00
|
|
|
uint32_t flags() const { return fFlags; }
|
|
|
|
SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
|
|
|
|
|
2015-08-31 19:39:41 +00:00
|
|
|
bool isUseDeviceIndependentFonts() const {
|
|
|
|
return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
|
|
|
|
}
|
2014-09-22 14:29:03 +00:00
|
|
|
|
2017-11-30 16:22:14 +00:00
|
|
|
bool operator==(const SkSurfaceProps& that) const {
|
|
|
|
return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry;
|
|
|
|
}
|
|
|
|
|
2019-08-27 15:27:08 +00:00
|
|
|
bool operator!=(const SkSurfaceProps& that) const {
|
|
|
|
return !(*this == that);
|
|
|
|
}
|
2014-09-22 14:29:03 +00:00
|
|
|
|
2020-10-23 15:29:03 +00:00
|
|
|
private:
|
2014-09-22 14:29:03 +00:00
|
|
|
uint32_t fFlags;
|
|
|
|
SkPixelGeometry fPixelGeometry;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|