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

Side by Side Diff: src/pdf/SkBitmapKey.h

Issue 1848383002: SkPDF: properly dedup bitmaps in shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-01 (Friday) 14:35:15 EDT Created 4 years, 8 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 | « gm/subsetshader.cpp ('k') | src/pdf/SkPDFShader.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 #ifndef SkBitmapKey_DEFINED 7 #ifndef SkBitmapKey_DEFINED
8 #define SkBitmapKey_DEFINED 8 #define SkBitmapKey_DEFINED
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 13
14 class SkBitmapKey { 14 class SkBitmapKey {
15 public: 15 public:
16 SkBitmapKey() : fSubset(SkIRect::MakeEmpty()), fID(0) {} 16 SkBitmapKey() : fSubset(SkIRect::MakeEmpty()), fID(0) {}
17 explicit SkBitmapKey(const SkBitmap& bm) 17 explicit SkBitmapKey(const SkBitmap& bm)
18 : fSubset(bm.getSubset()), fID(bm.getGenerationID()) {} 18 : fSubset(bm.getSubset()), fID(bm.getGenerationID()) {}
19 explicit SkBitmapKey(const SkImage* img) 19 explicit SkBitmapKey(const SkImage* img)
20 : fSubset(img ? img->bounds() : SkIRect::MakeEmpty()) 20 : fSubset(img ? img->bounds() : SkIRect::MakeEmpty())
21 , fID(img ? img->uniqueID() : 0) {} 21 , fID(img ? img->uniqueID() : 0) {}
22 explicit SkBitmapKey(const sk_sp<SkImage> img) 22 explicit SkBitmapKey(const sk_sp<SkImage> img)
23 : fSubset(img->bounds()), fID(img->uniqueID()) {} 23 : fSubset(img->bounds()), fID(img->uniqueID()) {}
24 bool operator==(const SkBitmapKey& rhs) const { 24 bool operator==(const SkBitmapKey& rhs) const {
25 return fID == rhs.fID && fSubset == rhs.fSubset; 25 return fID == rhs.fID && fSubset == rhs.fSubset;
26 } 26 }
27 bool operator!=(const SkBitmapKey& rhs) const { return !(*this == rhs); } 27 bool operator!=(const SkBitmapKey& rhs) const { return !(*this == rhs); }
28 uint32_t id() const { return fID; }
28 29
29 private: 30 private:
30 SkIRect fSubset; 31 SkIRect fSubset;
31 uint32_t fID; 32 uint32_t fID;
32 }; 33 };
33 34
34 /** 35 /**
35 This wraps a thing that could either be a bitmap or a image and 36 This wraps a thing that could either be a bitmap or a image and
36 abstracts out some common tasks. 37 abstracts out some common tasks.
37 */ 38 */
(...skipping 19 matching lines...) Expand all
57 } 58 }
58 } 59 }
59 60
60 private: 61 private:
61 SkBitmap fBitmap; 62 SkBitmap fBitmap;
62 SkImage* fImage; // non-owning; when drawImage starts passing a sk_sp<>, 63 SkImage* fImage; // non-owning; when drawImage starts passing a sk_sp<>,
63 // we can take a const ref to that sk_sp<>. 64 // we can take a const ref to that sk_sp<>.
64 }; 65 };
65 66
66 #endif // SkBitmapKey_DEFINED 67 #endif // SkBitmapKey_DEFINED
OLDNEW
« no previous file with comments | « gm/subsetshader.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698