2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2010 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkDevice_DEFINED
|
|
|
|
#define SkDevice_DEFINED
|
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkColor.h"
|
2015-06-19 18:49:52 +00:00
|
|
|
#include "SkSurfaceProps.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-08-05 20:57:49 +00:00
|
|
|
class SkBitmap;
|
2011-02-22 20:56:26 +00:00
|
|
|
class SkClipStack;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkDraw;
|
2015-03-04 03:08:17 +00:00
|
|
|
class SkDrawFilter;
|
2016-04-27 18:31:23 +00:00
|
|
|
class SkImageFilterCache;
|
2008-12-17 15:59:43 +00:00
|
|
|
struct SkIRect;
|
|
|
|
class SkMatrix;
|
2011-03-30 21:23:07 +00:00
|
|
|
class SkMetaData;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkRegion;
|
2016-07-18 15:31:31 +00:00
|
|
|
class SkSpecialImage;
|
2013-06-26 19:18:23 +00:00
|
|
|
class GrRenderTarget;
|
2011-07-18 15:25:04 +00:00
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
class SK_API SkBaseDevice : public SkRefCnt {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2011-06-16 19:10:39 +00:00
|
|
|
/**
|
2013-08-29 11:54:56 +00:00
|
|
|
* Construct a new device.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-08-20 14:59:19 +00:00
|
|
|
explicit SkBaseDevice(const SkImageInfo&, const SkSurfaceProps&);
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual ~SkBaseDevice();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
SkMetaData& getMetaData();
|
|
|
|
|
2014-02-13 17:14:46 +00:00
|
|
|
/**
|
|
|
|
* Return ImageInfo for this device. If the canvas is not backed by pixels
|
|
|
|
* (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.
|
|
|
|
*/
|
2016-08-20 14:59:19 +00:00
|
|
|
const SkImageInfo& imageInfo() const { return fInfo; }
|
2014-02-13 17:14:46 +00:00
|
|
|
|
2016-04-06 14:38:23 +00:00
|
|
|
/**
|
|
|
|
* Return SurfaceProps for this device.
|
|
|
|
*/
|
|
|
|
const SkSurfaceProps& surfaceProps() const {
|
|
|
|
return fSurfaceProps;
|
|
|
|
}
|
|
|
|
|
2011-08-30 15:56:11 +00:00
|
|
|
/**
|
|
|
|
* Return the bounds of the device in the coordinate space of the root
|
|
|
|
* canvas. The root device will have its top-left at 0,0, but other devices
|
|
|
|
* such as those associated with saveLayer may have a non-zero origin.
|
|
|
|
*/
|
2013-11-13 16:02:18 +00:00
|
|
|
void getGlobalBounds(SkIRect* bounds) const {
|
|
|
|
SkASSERT(bounds);
|
|
|
|
const SkIPoint& origin = this->getOrigin();
|
|
|
|
bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
|
|
|
|
}
|
2013-11-14 07:02:31 +00:00
|
|
|
|
2014-11-19 16:04:34 +00:00
|
|
|
SkIRect getGlobalBounds() const {
|
|
|
|
SkIRect bounds;
|
|
|
|
this->getGlobalBounds(&bounds);
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
2014-06-14 11:24:56 +00:00
|
|
|
int width() const {
|
|
|
|
return this->imageInfo().width();
|
|
|
|
}
|
2014-07-07 20:51:48 +00:00
|
|
|
|
2014-06-14 11:24:56 +00:00
|
|
|
int height() const {
|
|
|
|
return this->imageInfo().height();
|
|
|
|
}
|
2014-07-07 20:51:48 +00:00
|
|
|
|
2014-06-14 11:24:56 +00:00
|
|
|
bool isOpaque() const {
|
|
|
|
return this->imageInfo().isOpaque();
|
|
|
|
}
|
2013-08-30 07:01:34 +00:00
|
|
|
|
2016-07-21 14:17:54 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the bitmap associated with this device. Call this each time you need
|
|
|
|
to access the bitmap, as it notifies the subclass to perform any flushing
|
|
|
|
etc. before you examine the pixels.
|
|
|
|
@param changePixels set to true if the caller plans to change the pixels
|
|
|
|
@return the device's bitmap
|
|
|
|
*/
|
|
|
|
const SkBitmap& accessBitmap(bool changePixels);
|
2016-07-21 14:17:54 +00:00
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-17 17:03:18 +00:00
|
|
|
bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-06-05 21:11:32 +00:00
|
|
|
/**
|
|
|
|
* Try to get write-access to the pixels behind the device. If successful, this returns true
|
|
|
|
* and fills-out the pixmap parameter. On success it also bumps the genID of the underlying
|
|
|
|
* bitmap.
|
|
|
|
*
|
|
|
|
* On failure, returns false and ignores the pixmap parameter.
|
|
|
|
*/
|
2015-05-26 18:31:54 +00:00
|
|
|
bool accessPixels(SkPixmap* pmap);
|
2014-03-12 18:28:35 +00:00
|
|
|
|
2015-06-05 21:11:32 +00:00
|
|
|
/**
|
|
|
|
* Try to get read-only-access to the pixels behind the device. If successful, this returns
|
|
|
|
* true and fills-out the pixmap parameter.
|
|
|
|
*
|
|
|
|
* On failure, returns false and ignores the pixmap parameter.
|
|
|
|
*/
|
|
|
|
bool peekPixels(SkPixmap*);
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/**
|
|
|
|
* Return the device's origin: its offset in device coordinates from
|
|
|
|
* the default origin in its canvas' matrix/clip
|
|
|
|
*/
|
|
|
|
const SkIPoint& getOrigin() const { return fOrigin; }
|
|
|
|
|
2012-01-05 17:05:05 +00:00
|
|
|
protected:
|
2015-03-14 17:54:31 +00:00
|
|
|
enum TileUsage {
|
|
|
|
kPossible_TileUsage, //!< the created device may be drawn tiled
|
|
|
|
kNever_TileUsage, //!< the created device will never be drawn tiled
|
2012-01-05 17:05:05 +00:00
|
|
|
};
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
struct TextFlags {
|
2014-09-16 19:27:55 +00:00
|
|
|
uint32_t fFlags; // SkPaint::getFlags()
|
2011-08-08 19:41:56 +00:00
|
|
|
};
|
|
|
|
|
2014-11-13 22:05:58 +00:00
|
|
|
/**
|
|
|
|
* Returns the text-related flags, possibly modified based on the state of the
|
|
|
|
* device (e.g. support for LCD).
|
|
|
|
*/
|
|
|
|
uint32_t filterTextFlags(const SkPaint&) const;
|
|
|
|
|
2014-11-13 20:41:02 +00:00
|
|
|
virtual bool onShouldDisableLCD(const SkPaint&) const { return false; }
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** These are called inside the per-device-layer loop for each draw call.
|
|
|
|
When these are called, we have already applied any saveLayer operations,
|
|
|
|
and are handling any looping from the paint, and any effects from the
|
|
|
|
DrawFilter.
|
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPoint[], const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawRect(const SkDraw&, const SkRect& r,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2016-08-25 20:54:30 +00:00
|
|
|
virtual void drawRegion(const SkDraw&, const SkRegion& r,
|
|
|
|
const SkPaint& paint);
|
2013-01-22 13:34:01 +00:00
|
|
|
virtual void drawOval(const SkDraw&, const SkRect& oval,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2016-08-19 18:25:19 +00:00
|
|
|
/** By the time this is called we know that abs(sweepAngle) is in the range [0, 360). */
|
|
|
|
virtual void drawArc(const SkDraw&, const SkRect& oval, SkScalar startAngle,
|
|
|
|
SkScalar sweepAngle, bool useCenter, const SkPaint& paint);
|
2013-04-25 15:27:00 +00:00
|
|
|
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2013-04-25 15:27:00 +00:00
|
|
|
|
2014-02-21 02:32:36 +00:00
|
|
|
// Default impl calls drawPath()
|
|
|
|
virtual void drawDRRect(const SkDraw&, const SkRRect& outer,
|
|
|
|
const SkRRect& inner, const SkPaint&);
|
|
|
|
|
2011-03-25 15:08:16 +00:00
|
|
|
/**
|
|
|
|
* If pathIsMutable, then the implementation is allowed to cast path to a
|
|
|
|
* non-const pointer and modify it in place (as an optimization). Canvas
|
|
|
|
* may do this to implement helpers such as drawOval, by placing a temp
|
|
|
|
* path on the stack to hold the representation of the oval.
|
|
|
|
*
|
|
|
|
* If prePathMatrix is not null, it should logically be applied before any
|
|
|
|
* stroking or other effects. If there are no effects on the paint that
|
|
|
|
* affect the geometry/rasterization, then the pre matrix can just be
|
|
|
|
* pre-concated with the current matrix.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPath(const SkDraw&, const SkPath& path,
|
2010-12-20 18:26:13 +00:00
|
|
|
const SkPaint& paint,
|
|
|
|
const SkMatrix* prePathMatrix = NULL,
|
2013-08-29 11:54:56 +00:00
|
|
|
bool pathIsMutable = false) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkMatrix& matrix, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
|
2013-08-29 11:54:56 +00:00
|
|
|
int x, int y, const SkPaint& paint) = 0;
|
2012-09-25 15:37:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The default impl. will create a bitmap-shader from the bitmap,
|
|
|
|
* and call drawRect with it.
|
|
|
|
*/
|
|
|
|
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
|
|
|
|
const SkRect* srcOrNull, const SkRect& dst,
|
2013-08-16 10:24:37 +00:00
|
|
|
const SkPaint& paint,
|
2015-07-28 14:35:14 +00:00
|
|
|
SkCanvas::SrcRectConstraint) = 0;
|
2015-06-25 19:32:03 +00:00
|
|
|
virtual void drawBitmapNine(const SkDraw&, const SkBitmap&, const SkIRect& center,
|
2016-08-02 15:05:56 +00:00
|
|
|
const SkRect& dst, const SkPaint&);
|
2016-08-16 16:31:08 +00:00
|
|
|
virtual void drawBitmapLattice(const SkDraw&, const SkBitmap&, const SkCanvas::Lattice&,
|
|
|
|
const SkRect& dst, const SkPaint&);
|
2012-09-25 15:37:50 +00:00
|
|
|
|
2015-05-06 19:56:48 +00:00
|
|
|
virtual void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&);
|
|
|
|
virtual void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
|
2015-07-14 17:54:12 +00:00
|
|
|
const SkPaint&, SkCanvas::SrcRectConstraint);
|
2015-06-25 19:32:03 +00:00
|
|
|
virtual void drawImageNine(const SkDraw&, const SkImage*, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint&);
|
2016-08-02 15:05:56 +00:00
|
|
|
virtual void drawImageLattice(const SkDraw&, const SkImage*, const SkCanvas::Lattice&,
|
|
|
|
const SkRect& dst, const SkPaint&);
|
2015-05-06 19:56:48 +00:00
|
|
|
|
2011-08-22 21:30:43 +00:00
|
|
|
/**
|
|
|
|
* Does not handle text decoration.
|
|
|
|
* Decorations (underline and stike-thru) will be handled by SkCanvas.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawText(const SkDraw&, const void* text, size_t len,
|
2013-08-29 11:54:56 +00:00
|
|
|
SkScalar x, SkScalar y, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
Revert of Revert of Fix SkTextBlob offset semantics. (patchset #1 id:1 of https://codereview.chromium.org/609223003/)
Reason for revert:
Re-landing: Chromium-side fix to be landed with the roll (https://codereview.chromium.org/607853003/)
Original issue's description:
> Revert of Fix SkTextBlob offset semantics. (patchset #2 id:20001 of https://codereview.chromium.org/605533002/)
>
> Reason for revert:
> Breaking the Chrome builds with the error:
>
> [14:54:14.317833] ../../skia/ext/pixel_ref_utils.cc:221:16: error: 'drawPosText' marked 'override' but does not override any member functions
> [14:54:14.318022] virtual void drawPosText(const SkDraw& draw,
> [14:54:14.318082] ^
>
> Original issue's description:
> > Fix SkTextBlob offset semantics.
> >
> > Implement proper x/y drawTextBlob() handling by plumbing a
> > drawPosText() offset parameter (to act as an additional glyph pos
> > translation) throughout the device layer.
> >
> > The new offset superceeds the existing constY, with a minor semantic
> > tweak: whereas previous implementations were ignoring constY in 2D
> > positioning mode (scalarsPerGlyph == 2), now the offset is always
> > observed, in all positioning modes. We can do this because existing
> > drawPosText() clients always pass constY == 0 for full positioning mode.
> >
> > R=reed@google.com, jvanverth@google.com, robertphillips@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/c13bc571d3e61a43b87eb97f0719abd304cafaf2
>
> TBR=jvanverth@google.com,reed@google.com,bsalomon@google.com,fmalita@chromium.org
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/d46b8d2bab7cfba8458432248e1568ac377429e9
R=jvanverth@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com
TBR=bsalomon@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/607413003
2014-09-29 13:29:53 +00:00
|
|
|
const SkScalar pos[], int scalarsPerPos,
|
|
|
|
const SkPoint& offset, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
|
|
|
|
const SkPoint verts[], const SkPoint texs[],
|
2016-11-03 18:45:31 +00:00
|
|
|
const SkColor colors[], SkBlendMode,
|
2008-12-17 15:59:43 +00:00
|
|
|
const uint16_t indices[], int indexCount,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2014-08-28 21:32:24 +00:00
|
|
|
// default implementation unrolls the blob runs.
|
|
|
|
virtual void drawTextBlob(const SkDraw&, const SkTextBlob*, SkScalar x, SkScalar y,
|
2015-03-04 03:08:17 +00:00
|
|
|
const SkPaint& paint, SkDrawFilter* drawFilter);
|
2014-08-04 17:02:00 +00:00
|
|
|
// default implementation calls drawVertices
|
2014-08-12 15:34:29 +00:00
|
|
|
virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColor colors[4],
|
2016-11-03 18:45:31 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint);
|
2015-06-24 17:29:17 +00:00
|
|
|
|
|
|
|
// default implementation calls drawPath
|
|
|
|
virtual void drawAtlas(const SkDraw&, const SkImage* atlas, const SkRSXform[], const SkRect[],
|
2016-11-03 18:45:31 +00:00
|
|
|
const SkColor[], int count, SkBlendMode, const SkPaint&);
|
2015-06-24 17:29:17 +00:00
|
|
|
|
2016-03-05 00:36:20 +00:00
|
|
|
virtual void drawAnnotation(const SkDraw&, const SkRect&, const char[], SkData*) {}
|
|
|
|
|
2013-08-20 20:06:40 +00:00
|
|
|
/** The SkDevice passed will be an SkDevice which was returned by a call to
|
2015-03-14 17:54:31 +00:00
|
|
|
onCreateDevice on this device with kNeverTile_TileExpectation.
|
2011-08-08 19:41:56 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
|
|
|
|
const SkPaint&) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-02-17 18:33:54 +00:00
|
|
|
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, const SkPath&,
|
|
|
|
const SkMatrix*, const SkPaint&);
|
2016-07-07 19:47:17 +00:00
|
|
|
virtual void drawTextRSXform(const SkDraw&, const void* text, size_t len, const SkRSXform[],
|
|
|
|
const SkPaint&);
|
2015-05-26 18:31:54 +00:00
|
|
|
|
2016-07-18 15:31:31 +00:00
|
|
|
virtual void drawSpecial(const SkDraw&, SkSpecialImage*, int x, int y, const SkPaint&);
|
|
|
|
virtual sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&);
|
2016-07-19 21:33:20 +00:00
|
|
|
virtual sk_sp<SkSpecialImage> makeSpecial(const SkImage*);
|
2016-07-18 15:31:31 +00:00
|
|
|
virtual sk_sp<SkSpecialImage> snapSpecial();
|
|
|
|
|
2014-03-17 21:31:26 +00:00
|
|
|
bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y);
|
2011-11-03 20:29:47 +00:00
|
|
|
|
2011-01-25 23:50:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-21 14:17:54 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP
|
2012-02-07 16:27:57 +00:00
|
|
|
/** Update as needed the pixel value in the bitmap, so that the caller can
|
2013-08-30 07:01:34 +00:00
|
|
|
access the pixels directly.
|
2013-08-29 11:54:56 +00:00
|
|
|
@return The device contents as a bitmap
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-07-21 14:17:54 +00:00
|
|
|
virtual const SkBitmap& onAccessBitmap() {
|
|
|
|
SkASSERT(0);
|
|
|
|
return fLegacyBitmap;
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-28 01:45:11 +00:00
|
|
|
|
2016-04-26 13:57:31 +00:00
|
|
|
virtual GrContext* context() const { return nullptr; }
|
|
|
|
|
2016-03-24 01:59:25 +00:00
|
|
|
virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&);
|
2015-05-26 18:31:54 +00:00
|
|
|
virtual bool onPeekPixels(SkPixmap*) { return false; }
|
2014-02-14 03:02:05 +00:00
|
|
|
|
2014-03-17 21:31:26 +00:00
|
|
|
/**
|
|
|
|
* The caller is responsible for "pre-clipping" the dst. The impl can assume that the dst
|
|
|
|
* image at the specified x,y offset will fit within the device's bounds.
|
|
|
|
*
|
|
|
|
* This is explicitly asserted in readPixels(), the public way to call this.
|
|
|
|
*/
|
|
|
|
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y);
|
2014-03-12 03:04:08 +00:00
|
|
|
|
2014-03-07 03:25:16 +00:00
|
|
|
/**
|
|
|
|
* The caller is responsible for "pre-clipping" the src. The impl can assume that the src
|
|
|
|
* image at the specified x,y offset will fit within the device's bounds.
|
|
|
|
*
|
|
|
|
* This is explicitly asserted in writePixelsDirect(), the public way to call this.
|
|
|
|
*/
|
|
|
|
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y);
|
|
|
|
|
2015-05-26 18:31:54 +00:00
|
|
|
virtual bool onAccessPixels(SkPixmap*) { return false; }
|
2014-03-12 18:28:35 +00:00
|
|
|
|
2014-11-13 16:33:37 +00:00
|
|
|
struct CreateInfo {
|
2015-12-10 21:44:45 +00:00
|
|
|
static SkPixelGeometry AdjustGeometry(const SkImageInfo&, TileUsage, SkPixelGeometry,
|
|
|
|
bool preserveLCDText);
|
2014-11-13 20:41:02 +00:00
|
|
|
|
2015-03-14 17:54:31 +00:00
|
|
|
// The constructor may change the pixel geometry based on other parameters.
|
2015-12-10 21:44:45 +00:00
|
|
|
CreateInfo(const SkImageInfo& info,
|
|
|
|
TileUsage tileUsage,
|
|
|
|
SkPixelGeometry geo)
|
|
|
|
: fInfo(info)
|
|
|
|
, fTileUsage(tileUsage)
|
|
|
|
, fPixelGeometry(AdjustGeometry(info, tileUsage, geo, false))
|
2016-07-15 16:41:26 +00:00
|
|
|
{}
|
2015-12-10 21:44:45 +00:00
|
|
|
|
2015-04-15 20:05:18 +00:00
|
|
|
CreateInfo(const SkImageInfo& info,
|
|
|
|
TileUsage tileUsage,
|
|
|
|
SkPixelGeometry geo,
|
2016-07-15 16:41:26 +00:00
|
|
|
bool preserveLCDText)
|
2014-11-13 20:41:02 +00:00
|
|
|
: fInfo(info)
|
2015-03-14 17:54:31 +00:00
|
|
|
, fTileUsage(tileUsage)
|
2015-12-10 21:44:45 +00:00
|
|
|
, fPixelGeometry(AdjustGeometry(info, tileUsage, geo, preserveLCDText))
|
2016-07-15 16:41:26 +00:00
|
|
|
{}
|
2014-11-13 20:41:02 +00:00
|
|
|
|
2015-03-14 17:54:31 +00:00
|
|
|
const SkImageInfo fInfo;
|
|
|
|
const TileUsage fTileUsage;
|
|
|
|
const SkPixelGeometry fPixelGeometry;
|
2014-11-13 16:33:37 +00:00
|
|
|
};
|
2014-11-13 20:41:02 +00:00
|
|
|
|
2015-03-14 17:54:31 +00:00
|
|
|
/**
|
|
|
|
* Create a new device based on CreateInfo. If the paint is not null, then it represents a
|
|
|
|
* preview of how the new device will be composed with its creator device (this).
|
2015-04-29 15:34:00 +00:00
|
|
|
*
|
|
|
|
* The subclass may be handed this device in drawDevice(), so it must always return
|
|
|
|
* a device that it knows how to draw, and that it knows how to identify if it is not of the
|
|
|
|
* same subclass (since drawDevice is passed a SkBaseDevice*). If the subclass cannot fulfill
|
|
|
|
* that contract (e.g. PDF cannot support some settings on the paint) it should return NULL,
|
|
|
|
* and the caller may then decide to explicitly create a bitmapdevice, knowing that later
|
|
|
|
* it could not call drawDevice with it (but it could call drawSprite or drawBitmap).
|
2015-03-14 17:54:31 +00:00
|
|
|
*/
|
2015-03-14 11:30:21 +00:00
|
|
|
virtual SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-18 16:14:00 +00:00
|
|
|
// A helper function used by derived classes to log the scale factor of a bitmap or image draw.
|
|
|
|
static void LogDrawScaleFactor(const SkMatrix&, SkFilterQuality);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2011-03-04 22:27:10 +00:00
|
|
|
friend class SkCanvas;
|
2012-10-09 22:30:18 +00:00
|
|
|
friend struct DeviceCM; //for setMatrixClip
|
2011-08-08 19:41:56 +00:00
|
|
|
friend class SkDraw;
|
|
|
|
friend class SkDrawIter;
|
|
|
|
friend class SkDeviceFilteredPaint;
|
2014-11-19 16:04:34 +00:00
|
|
|
friend class SkNoPixelsBitmapDevice;
|
2012-08-28 12:19:02 +00:00
|
|
|
friend class SkSurface_Raster;
|
2016-07-18 15:31:31 +00:00
|
|
|
friend class DeviceTestingAccess;
|
2013-08-29 11:54:56 +00:00
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
// used to change the backend's pixels (and possibly config/rowbytes)
|
|
|
|
// but cannot change the width/height, so there should be no change to
|
|
|
|
// any clip information.
|
2013-11-13 16:02:18 +00:00
|
|
|
// TODO: move to SkBitmapDevice
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {}
|
2012-08-28 12:19:02 +00:00
|
|
|
|
Revert of Revert of allow canvas to force conservative clips (for speed) (patchset #1 id:1 of https://codereview.chromium.org/554033003/)
Reason for revert:
May just rebaseline, plus want to see the results of the chrome tests, so re-trying this CL.
Original issue's description:
> Revert of allow canvas to force conservative clips (for speed) (patchset #7 id:120001 of https://codereview.chromium.org/541593005/)
>
> Reason for revert:
> multipicturedraw failed on nvprmsaa -- don't know why yet
>
> Original issue's description:
> > Allow SkCanvas to be initialized to force conservative rasterclips. This has the following effects:
> >
> > 1. Queries to the current clip will be conservatively large. This can mean the quickReject may return false more often.
> >
> > 2. The conservative clips mean less work is done.
> >
> > 3. Enabled by default for Gpu, Record, and NoSaveLayer canvases.
> >
> > 4. API is private for now.
> >
> > Committed: https://skia.googlesource.com/skia/+/27a5e656c3d6ef22f9cb34de18e1b960da3aa241
>
> TBR=robertphillips@google.com,bsalomon@google.com,mtklein@google.com,junov@google.com
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/6f09709519b79a1159f3826645f1c5fbc101ee11
R=robertphillips@google.com, bsalomon@google.com, mtklein@google.com, junov@google.com, reed@google.com
TBR=bsalomon@google.com, junov@google.com, mtklein@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/560713002
2014-09-10 01:46:22 +00:00
|
|
|
virtual bool forceConservativeRasterClip() const { return false; }
|
|
|
|
|
2016-07-20 15:54:31 +00:00
|
|
|
/**
|
|
|
|
* Don't call this!
|
|
|
|
*/
|
2016-10-27 18:47:55 +00:00
|
|
|
virtual GrRenderTargetContext* accessRenderTargetContext() { return nullptr; }
|
2016-07-20 15:54:31 +00:00
|
|
|
|
2011-10-03 19:03:48 +00:00
|
|
|
// just called by SkCanvas when built as a layer
|
|
|
|
void setOrigin(int x, int y) { fOrigin.set(x, y); }
|
2011-03-04 22:27:10 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/** Causes any deferred drawing to the device to be completed.
|
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual void flush() {}
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2016-04-27 18:31:23 +00:00
|
|
|
virtual SkImageFilterCache* getImageFilterCache() { return NULL; }
|
2014-07-30 18:26:46 +00:00
|
|
|
|
2016-08-20 14:59:19 +00:00
|
|
|
friend class SkBitmapDevice;
|
|
|
|
void privateResize(int w, int h) {
|
|
|
|
*const_cast<SkImageInfo*>(&fInfo) = fInfo.makeWH(w, h);
|
|
|
|
}
|
|
|
|
|
2016-11-16 19:45:34 +00:00
|
|
|
bool drawExternallyScaledImage(const SkDraw& draw, const SkImage* image, const SkRect* src,
|
|
|
|
const SkRect& dst, const SkPaint& paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint);
|
|
|
|
|
2011-03-04 22:27:10 +00:00
|
|
|
SkIPoint fOrigin;
|
2011-03-30 21:23:07 +00:00
|
|
|
SkMetaData* fMetaData;
|
2016-08-20 14:59:19 +00:00
|
|
|
const SkImageInfo fInfo;
|
|
|
|
const SkSurfaceProps fSurfaceProps;
|
2012-06-21 20:25:03 +00:00
|
|
|
|
2016-07-21 14:17:54 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP
|
|
|
|
SkBitmap fLegacyBitmap;
|
|
|
|
#endif
|
|
|
|
|
2012-06-21 20:25:03 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|