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

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

Issue 179343005: Add a class to allocate small objects w/o extra calls to new. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rename the .h file Created 6 years, 9 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
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 8 #include "SkSmallAllocator.h"
10 #include "SkSpriteBlitter.h" 9 #include "SkSpriteBlitter.h"
11 10
12 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source) 11 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source)
13 : fSource(&source) { 12 : fSource(&source) {
14 fSource->lockPixels(); 13 fSource->lockPixels();
15 } 14 }
16 15
17 SkSpriteBlitter::~SkSpriteBlitter() { 16 SkSpriteBlitter::~SkSpriteBlitter() {
18 fSource->unlockPixels(); 17 fSource->unlockPixels();
19 } 18 }
(...skipping 22 matching lines...) Expand all
42 41
43 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { 42 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) {
44 SkDEBUGFAIL("how did we get here?"); 43 SkDEBUGFAIL("how did we get here?");
45 } 44 }
46 #endif 45 #endif
47 46
48 /////////////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////////////
49 48
50 // returning null means the caller will call SkBlitter::Choose() and 49 // returning null means the caller will call SkBlitter::Choose() and
51 // have wrapped the source bitmap inside a shader 50 // have wrapped the source bitmap inside a shader
52 SkBlitter* SkBlitter::ChooseSprite( const SkBitmap& device, 51 SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint,
53 const SkPaint& paint, 52 const SkBitmap& source, int left, int top, SkTBlitterAllocator* allocato r) {
54 const SkBitmap& source,
55 int left, int top,
56 void* storage, size_t storageSize) {
57 /* We currently ignore antialiasing and filtertype, meaning we will take ou r 53 /* We currently ignore antialiasing and filtertype, meaning we will take ou r
58 special blitters regardless of these settings. Ignoring filtertype seems fine 54 special blitters regardless of these settings. Ignoring filtertype seems fine
59 since by definition there is no scale in the matrix. Ignoring antialiasi ng is 55 since by definition there is no scale in the matrix. Ignoring antialiasi ng is
60 a bit of a hack, since we "could" pass in the fractional left/top for th e bitmap, 56 a bit of a hack, since we "could" pass in the fractional left/top for th e bitmap,
61 and respect that by blending the edges of the bitmap against the device. To support 57 and respect that by blending the edges of the bitmap against the device. To support
62 this we could either add more special blitters here, or detect antialias ing in the 58 this we could either add more special blitters here, or detect antialias ing in the
63 paint and return null if it is set, forcing the client to take the slow shader case 59 paint and return null if it is set, forcing the client to take the slow shader case
64 (which does respect soft edges). 60 (which does respect soft edges).
65 */ 61 */
62 SkASSERT(allocator != NULL);
66 63
67 SkSpriteBlitter* blitter; 64 SkSpriteBlitter* blitter;
68 65
69 switch (device.colorType()) { 66 switch (device.colorType()) {
70 case kRGB_565_SkColorType: 67 case kRGB_565_SkColorType:
71 blitter = SkSpriteBlitter::ChooseD16(source, paint, storage, 68 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator);
72 storageSize);
73 break; 69 break;
74 case kPMColor_SkColorType: 70 case kPMColor_SkColorType:
75 blitter = SkSpriteBlitter::ChooseD32(source, paint, storage, 71 blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator);
76 storageSize);
77 break; 72 break;
78 default: 73 default:
79 blitter = NULL; 74 blitter = NULL;
80 break; 75 break;
81 } 76 }
82 77
83 if (blitter) { 78 if (blitter) {
84 blitter->setup(device, left, top, paint); 79 blitter->setup(device, left, top, paint);
85 } 80 }
86 return blitter; 81 return blitter;
87 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698