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

Side by Side Diff: src/core/SkBitmapCache.cpp

Issue 471473002: Optimize CSS box-shadow performance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: based on SkBitmapCache Created 6 years, 4 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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkRect.h" 9 #include "SkRect.h"
10 10
(...skipping 21 matching lines...) Expand all
32 { 32 {
33 this->init(sizeof(fGenID) + sizeof(fScaleX) + sizeof(fScaleY) + sizeof(f Bounds)); 33 this->init(sizeof(fGenID) + sizeof(fScaleX) + sizeof(fScaleY) + sizeof(f Bounds));
34 } 34 }
35 35
36 uint32_t fGenID; 36 uint32_t fGenID;
37 SkScalar fScaleX; 37 SkScalar fScaleX;
38 SkScalar fScaleY; 38 SkScalar fScaleY;
39 SkIRect fBounds; 39 SkIRect fBounds;
40 }; 40 };
41 41
42 struct RRectBlurKey : public SkScaledImageCache::Key {
43 public:
44 RRectBlurKey(SkScalar sigma, const SkRRect rrect)
45 : fSigma(sigma)
46 , fRRect(rrect) {
47 this->init(sizeof(fSigma) + sizeof(fRRect));
48 }
49
50 SkScalar fSigma;
51 SkRRect fRRect;
52 };
53
54 struct RectsBlurKey : public SkScaledImageCache::Key {
55 public:
56 RectsBlurKey(SkScalar sigma, int32_t count, const SkRect rects[])
57 : fSigma(sigma)
58 , fRecCount(count) {
59 for (int i = 0; i < count; i++) {
60 fRects[i] = rects[i];
61 }
62 this->init(sizeof(fSigma) + sizeof(fRecCount) + sizeof(SkRect) * fRecCou nt);
63 }
64
65 SkScalar fSigma;
66 int32_t fRecCount;
67 SkRect fRects[2];
68 };
69
42 //////////////////////////////////////////////////////////////////////////////// ////////// 70 //////////////////////////////////////////////////////////////////////////////// //////////
43 71
44 SkScaledImageCache::ID* SkBitmapCache::FindAndLock(const SkBitmap& src, 72 SkScaledImageCache::ID* SkBitmapCache::FindAndLock(const SkBitmap& src,
45 SkScalar invScaleX, SkScalar invScaleY, 73 SkScalar invScaleX, SkScalar invScaleY,
46 SkBitmap* result) { 74 SkBitmap* result) {
47 if (0 == invScaleX || 0 == invScaleY) { 75 if (0 == invScaleX || 0 == invScaleY) {
48 // degenerate, and the key we use for mipmaps 76 // degenerate, and the key we use for mipmaps
49 return NULL; 77 return NULL;
50 } 78 }
51 BitmapKey key(src.getGenerationID(), invScaleX, invScaleY, get_bounds_from_b itmap(src)); 79 BitmapKey key(src.getGenerationID(), invScaleX, invScaleY, get_bounds_from_b itmap(src));
(...skipping 30 matching lines...) Expand all
82 SkScaledImageCache::ID* SkMipMapCache::FindAndLock(const SkBitmap& src, const Sk MipMap** result) { 110 SkScaledImageCache::ID* SkMipMapCache::FindAndLock(const SkBitmap& src, const Sk MipMap** result) {
83 BitmapKey key(src.getGenerationID(), SK_Scalar1, SK_Scalar1, get_bounds_from _bitmap(src)); 111 BitmapKey key(src.getGenerationID(), SK_Scalar1, SK_Scalar1, get_bounds_from _bitmap(src));
84 return SkScaledImageCache::FindAndLock(key, result); 112 return SkScaledImageCache::FindAndLock(key, result);
85 } 113 }
86 114
87 SkScaledImageCache::ID* SkMipMapCache::AddAndLock(const SkBitmap& src, const SkM ipMap* result) { 115 SkScaledImageCache::ID* SkMipMapCache::AddAndLock(const SkBitmap& src, const SkM ipMap* result) {
88 BitmapKey key(src.getGenerationID(), SK_Scalar1, SK_Scalar1, get_bounds_from _bitmap(src)); 116 BitmapKey key(src.getGenerationID(), SK_Scalar1, SK_Scalar1, get_bounds_from _bitmap(src));
89 return SkScaledImageCache::AddAndLock(key, result); 117 return SkScaledImageCache::AddAndLock(key, result);
90 } 118 }
91 119
120 ////
121
122 SkScaledImageCache::ID* SkBitmapCache::FindAndLock(SkScalar sigma,
123 const SkRRect rrect,
124 SkBitmap* result) {
125 RRectBlurKey key(sigma, rrect);
126 return SkScaledImageCache::FindAndLock(key, result);
127 }
128
129 SkScaledImageCache::ID* SkBitmapCache::AddAndLock(SkScalar sigma,
130 const SkRRect rrect,
131 const SkBitmap& bitmap) {
132 RRectBlurKey key(sigma, rrect);
133 return SkScaledImageCache::AddAndLock(key, bitmap);
134 }
135
136 ////
137
138 SkScaledImageCache::ID* SkBitmapCache::FindAndLock(SkScalar sigma,
139 unsigned count,
140 const SkRect rects[],
141 SkBitmap* result) {
142 RectsBlurKey key(sigma, count, rects);
143 return SkScaledImageCache::FindAndLock(key, result);
144 }
145
146 SkScaledImageCache::ID* SkBitmapCache::AddAndLock(SkScalar sigma,
147 unsigned count,
148 const SkRect rects[],
149 const SkBitmap& bitmap) {
150 RectsBlurKey key(sigma, count, rects);
151 return SkScaledImageCache::AddAndLock(key, bitmap);
152 }
153
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698