Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: src/core/SkSpecialImage.h

Issue 1705113002: Update SkSpecialImage API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-gpu build Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkSpecialImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file 5 * found in the LICENSE file
6 */ 6 */
7 7
8 #ifndef SkSpecialImage_DEFINED 8 #ifndef SkSpecialImage_DEFINED
9 #define SkSpecialImage_DEFINED 9 #define SkSpecialImage_DEFINED
10 10
11 #include "SkNextID.h"
11 #include "SkRefCnt.h" 12 #include "SkRefCnt.h"
12 13
14 // remove this when internal_getProxy goes away (see skbug.com/4965)
15 #include "SkImageFilter.h"
16
13 class GrTexture; 17 class GrTexture;
14 class SkBitmap; 18 class SkBitmap;
15 class SkCanvas; 19 class SkCanvas;
16 class SkImage; 20 class SkImage;
17 struct SkImageInfo; 21 struct SkImageInfo;
18 class SkPaint; 22 class SkPaint;
19 class SkSpecialSurface; 23 class SkSpecialSurface;
20 24
25 enum {
26 kNeedNewImageUniqueID_SpecialImage = 0
27 };
28
21 /** 29 /**
22 * This is a restricted form of SkImage solely intended for internal use. It 30 * This is a restricted form of SkImage solely intended for internal use. It
23 * differs from SkImage in that: 31 * differs from SkImage in that:
24 * - it can only be backed by raster or gpu (no generators) 32 * - it can only be backed by raster or gpu (no generators)
25 * - it can be backed by a GrTexture larger than its nominal bounds 33 * - it can be backed by a GrTexture larger than its nominal bounds
26 * - it can't be drawn tiled 34 * - it can't be drawn tiled
27 * - it can't be drawn with MIPMAPs 35 * - it can't be drawn with MIPMAPs
28 * It is similar to SkImage in that it abstracts how the pixels are stored/repre sented. 36 * It is similar to SkImage in that it abstracts how the pixels are stored/repre sented.
29 * 37 *
30 * Note: the contents of the backing storage outside of the subset rect are unde fined. 38 * Note: the contents of the backing storage outside of the subset rect are unde fined.
31 */ 39 */
32 class SkSpecialImage : public SkRefCnt { 40 class SkSpecialImage : public SkRefCnt {
33 public: 41 public:
34 int width() const { return fSubset.width(); } 42 int width() const { return fSubset.width(); }
35 int height() const { return fSubset.height(); } 43 int height() const { return fSubset.height(); }
44 uint32_t uniqueID() const { return fUniqueID; }
45 virtual bool isOpaque() const { return false; }
46 virtual size_t getSize() const = 0;
36 47
37 /** 48 /**
38 * Draw this SpecialImage into the canvas. 49 * Draw this SpecialImage into the canvas.
39 */ 50 */
40 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; 51 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const;
41 52
42 static SkSpecialImage* NewFromImage(const SkIRect& subset, const SkImage*); 53 static SkSpecialImage* NewFromImage(const SkIRect& subset, const SkImage*);
43 static SkSpecialImage* NewFromRaster(const SkIRect& subset, const SkBitmap&) ; 54 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*,
44 static SkSpecialImage* NewFromGpu(const SkIRect& subset, GrTexture*); 55 const SkIRect& subset,
56 const SkBitmap&);
57 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*,
58 const SkIRect& subset,
59 uint32_t uniqueID,
60 GrTexture*,
61 SkAlphaType at = kPremul_SkAlphaType);
45 62
46 /** 63 /**
47 * Create a new surface with a backend that is compatible with this image. 64 * Create a new surface with a backend that is compatible with this image.
48 */ 65 */
49 SkSpecialSurface* newSurface(const SkImageInfo&) const; 66 SkSpecialSurface* newSurface(const SkImageInfo&) const;
50 67
68 // These three internal methods will go away (see skbug.com/4965)
69 bool internal_getBM(SkBitmap* result);
70 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap &);
71 SkImageFilter::Proxy* internal_getProxy();
72
51 protected: 73 protected:
52 SkSpecialImage(const SkIRect& subset) : fSubset(subset) { } 74 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID)
75 : fSubset(subset)
76 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I mageID()
77 : uniqueID)
78 , fProxy(proxy) {
79 }
53 80
54 // The following 3 are for testing and shouldn't be used. 81 // The following 3 are for testing and shouldn't be used. (see skbug.com/496 5)
55 friend class TestingSpecialImageAccess; 82 friend class TestingSpecialImageAccess;
56 friend class TestingSpecialSurfaceAccess; 83 friend class TestingSpecialSurfaceAccess;
57 const SkIRect& subset() const { return fSubset; } 84 const SkIRect& subset() const { return fSubset; }
58 85
59 /** 86 /**
60 * If the SpecialImage is backed by cpu pixels, return the const address 87 * If the SpecialImage is backed by cpu pixels, return the const address
61 * of those pixels and, if not null, return the ImageInfo and rowBytes. 88 * of those pixels and, if not null, return the ImageInfo and rowBytes.
62 * The returned address is only valid while the image object is in scope. 89 * The returned address is only valid while the image object is in scope.
63 * 90 *
64 * The returned ImageInfo represents the backing memory. Use 'subset' 91 * The returned ImageInfo represents the backing memory. Use 'subset'
65 * to get the active portion's dimensions. 92 * to get the active portion's dimensions.
66 * 93 *
67 * On failure, return false and ignore the pixmap parameter. 94 * On failure, return false and ignore the pixmap parameter.
68 */ 95 */
69 bool peekPixels(SkPixmap*) const; 96 bool peekPixels(SkPixmap*) const;
70 97
71 /** 98 /**
72 * If the SpecialImage is backed by a gpu texture, return that texture. 99 * If the SpecialImage is backed by a gpu texture, return that texture.
73 * The active portion of the texture can be retrieved via 'subset'. 100 * The active portion of the texture can be retrieved via 'subset'.
74 */ 101 */
75 GrTexture* peekTexture() const; 102 GrTexture* peekTexture() const;
76 103
104 // TODO: remove this ASAP (see skbug.com/4965)
105 SkImageFilter::Proxy* proxy() const { return fProxy; }
106
77 private: 107 private:
78 const SkIRect fSubset; 108 const SkIRect fSubset;
109 const uint32_t fUniqueID;
110
111 // TODO: remove this ASAP (see skbug.com/4965)
112 SkImageFilter::Proxy* fProxy;
79 113
80 typedef SkRefCnt INHERITED; 114 typedef SkRefCnt INHERITED;
81 }; 115 };
82 116
83 #endif 117 #endif
84 118
OLDNEW
« no previous file with comments | « no previous file | src/core/SkSpecialImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698