Chromium Code Reviews| Index: src/core/SkSpecialImage.h |
| diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d6cd304f81f7a74f56eb4166c16de7b98deec3f6 |
| --- /dev/null |
| +++ b/src/core/SkSpecialImage.h |
| @@ -0,0 +1,78 @@ |
| +/* |
| + * Copyright 2016 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file |
| + */ |
| + |
| +#ifndef SkSpecialImage_DEFINED |
| +#define SkSpecialImage_DEFINED |
| + |
| +#include "SkRefCnt.h" |
| + |
| +class GrTexture; |
| +class SkBitmap; |
| +class SkCanvas; |
| +class SkImage; |
| +struct SkImageInfo; |
| +class SkPaint; |
| +class SkSpecialSurface; |
| + |
| +/** |
| + * This is a restricted form of SkImage solely intended for internal use. It |
| + * differs from SkImage in that: |
| + * - it can only be backed by raster or gpu (no generators) |
| + * - it can be backed by a GrTexture larger than its nominal bounds |
| + * - it can't be drawn tiled |
| + * - it can't be drawn with MIPMAPs |
| + * It is similar to SkImage in that it abstracts how the pixels are stored/represented. |
| + * |
| + * Note: the contents of the backing storage outside of the active rect are undefined. |
| + */ |
| +class SkSpecialImage : public SkRefCnt { |
| +public: |
| + const SkIRect& activeRect() const { return fActiveRect; } |
|
bsalomon
2016/01/14 20:09:10
width() height() still seems handy
Speculating...
robertphillips
2016/01/15 13:12:47
I readded width() & height().
I'm not sure re the
|
| + |
| + /** |
| + * Draw this SpecialImage into the canvas. |
| + */ |
| + void draw(SkCanvas*, int x, int y, const SkPaint*) const; |
| + |
| + /** |
| + * If the SpecialImage is backed by cpu pixels, return the const address |
| + * of those pixels and, if not null, return the ImageInfo and rowBytes. |
| + * The returned address is only valid while the image object is in scope. |
| + * |
| + * The returned ImageInfo represents the backing memory. Use 'activeRect' |
| + * to get the active portion's dimensions. |
| + * |
| + * On failure, return false and ignore the pixmap parameter. |
| + */ |
| + bool peekPixels(SkPixmap*) const; |
| + |
|
bsalomon
2016/01/14 20:09:10
Should we have peekTexture?
Maybe peekTexture(SkI
robertphillips
2016/01/15 13:12:47
There is a peekTexture below. I think we should al
|
| + /** |
| + * If the SpecialImage is backed by a gpu texture, return that texture. |
| + * The active portion of the texture can be retrieved via 'width' & 'height'. |
| + */ |
| + GrTexture* peekTexture() const; |
| + |
| + static SkSpecialImage* NewImage(const SkIRect& activeRect, const SkImage*); |
| + static SkSpecialImage* NewRaster(const SkIRect& activeRect, const SkBitmap&); |
| + static SkSpecialImage* NewGpu(const SkIRect& activeRect, GrTexture*); |
|
bsalomon
2016/01/14 20:09:10
NewFromTexture to match SkImage?
wonder if subset
robertphillips
2016/01/15 13:12:47
Done.
|
| + |
| + /** |
| + * Create a new surface with a backend that is compatible with this image. |
| + */ |
| + SkSpecialSurface* newSurface(const SkImageInfo&) const; |
| + |
| +protected: |
| + SkSpecialImage(const SkIRect& activeRect) : fActiveRect(activeRect) { } |
| + |
| +private: |
| + const SkIRect fActiveRect; |
| + |
| + typedef SkRefCnt INHERITED; |
| +}; |
| + |
| +#endif |
| + |