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

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

Issue 1709263002: Update SkImageFilter's cache to handle SkSpecialImages and add unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment 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
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
(...skipping 23 matching lines...) Expand all
34 * - it can't be drawn tiled 34 * - it can't be drawn tiled
35 * - it can't be drawn with MIPMAPs 35 * - it can't be drawn with MIPMAPs
36 * 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.
37 * 37 *
38 * 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.
39 */ 39 */
40 class SkSpecialImage : public SkRefCnt { 40 class SkSpecialImage : public SkRefCnt {
41 public: 41 public:
42 int width() const { return fSubset.width(); } 42 int width() const { return fSubset.width(); }
43 int height() const { return fSubset.height(); } 43 int height() const { return fSubset.height(); }
44 const SkIRect& subset() const { return fSubset; }
45
44 uint32_t uniqueID() const { return fUniqueID; } 46 uint32_t uniqueID() const { return fUniqueID; }
45 virtual bool isOpaque() const { return false; } 47 virtual bool isOpaque() const { return false; }
46 virtual size_t getSize() const = 0; 48 virtual size_t getSize() const = 0;
47 49
48 /** 50 /**
49 * Draw this SpecialImage into the canvas. 51 * Draw this SpecialImage into the canvas.
50 */ 52 */
51 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; 53 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const;
52 54
53 static SkSpecialImage* NewFromImage(const SkIRect& subset, const SkImage*); 55 static SkSpecialImage* NewFromImage(const SkIRect& subset, const SkImage*);
(...skipping 17 matching lines...) Expand all
71 SkImageFilter::Proxy* internal_getProxy(); 73 SkImageFilter::Proxy* internal_getProxy();
72 74
73 protected: 75 protected:
74 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID) 76 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID)
75 : fSubset(subset) 77 : fSubset(subset)
76 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I mageID() 78 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I mageID()
77 : uniqueID) 79 : uniqueID)
78 , fProxy(proxy) { 80 , fProxy(proxy) {
79 } 81 }
80 82
81 // The following 3 are for testing and shouldn't be used. (see skbug.com/496 5) 83 // The following 2 are for testing and shouldn't be used.
82 friend class TestingSpecialImageAccess; 84 friend class TestingSpecialImageAccess;
83 friend class TestingSpecialSurfaceAccess; 85 friend class TestingSpecialSurfaceAccess;
84 const SkIRect& subset() const { return fSubset; }
85 86
86 /** 87 /**
87 * If the SpecialImage is backed by cpu pixels, return the const address 88 * If the SpecialImage is backed by cpu pixels, return the const address
88 * of those pixels and, if not null, return the ImageInfo and rowBytes. 89 * of those pixels and, if not null, return the ImageInfo and rowBytes.
89 * The returned address is only valid while the image object is in scope. 90 * The returned address is only valid while the image object is in scope.
90 * 91 *
91 * The returned ImageInfo represents the backing memory. Use 'subset' 92 * The returned ImageInfo represents the backing memory. Use 'subset'
92 * to get the active portion's dimensions. 93 * to get the active portion's dimensions.
93 * 94 *
94 * On failure, return false and ignore the pixmap parameter. 95 * On failure, return false and ignore the pixmap parameter.
(...skipping 14 matching lines...) Expand all
109 const uint32_t fUniqueID; 110 const uint32_t fUniqueID;
110 111
111 // TODO: remove this ASAP (see skbug.com/4965) 112 // TODO: remove this ASAP (see skbug.com/4965)
112 SkImageFilter::Proxy* fProxy; 113 SkImageFilter::Proxy* fProxy;
113 114
114 typedef SkRefCnt INHERITED; 115 typedef SkRefCnt INHERITED;
115 }; 116 };
116 117
117 #endif 118 #endif
118 119
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698