OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable* ct) SK_OVERRIDE
{ | 53 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable* ct) SK_OVERRIDE
{ |
54 const SkImageInfo& info = dst->info(); | 54 const SkImageInfo& info = dst->info(); |
55 if (kUnknown_SkColorType == info.colorType()) | 55 if (kUnknown_SkColorType == info.colorType()) |
56 return false; | 56 return false; |
57 SkAutoTUnref<SkPixelRef> pr(new MockDiscardablePixelRef(info, dst->r
owBytes())); | 57 SkAutoTUnref<SkPixelRef> pr(new MockDiscardablePixelRef(info, dst->r
owBytes())); |
58 dst->setPixelRef(pr); | 58 dst->setPixelRef(pr); |
59 return true; | 59 return true; |
60 } | 60 } |
61 }; | 61 }; |
62 | 62 |
63 #ifdef SK_SUPPORT_LEGACY_PIXELREF_UNFLATTENABLE | |
64 SK_DECLARE_UNFLATTENABLE_OBJECT() | |
65 #endif | |
66 | |
67 protected: | 63 protected: |
68 virtual bool onNewLockPixels(LockRec* rec) | 64 virtual bool onNewLockPixels(LockRec* rec) |
69 { | 65 { |
70 if (discarded) | 66 if (discarded) |
71 return false; | 67 return false; |
72 m_lockedMemory = &discarded; | 68 m_lockedMemory = &discarded; |
73 rec->fPixels = m_lockedMemory; | 69 rec->fPixels = m_lockedMemory; |
74 rec->fColorTable = 0; | 70 rec->fColorTable = 0; |
75 rec->fRowBytes = m_rowBytes; | 71 rec->fRowBytes = m_rowBytes; |
76 return true; | 72 return true; |
77 } | 73 } |
78 | 74 |
79 virtual void onUnlockPixels() | 75 virtual void onUnlockPixels() |
80 { | 76 { |
81 m_lockedMemory = 0; | 77 m_lockedMemory = 0; |
82 } | 78 } |
83 | 79 |
84 private: | 80 private: |
85 void* m_lockedMemory; | 81 void* m_lockedMemory; |
86 size_t m_rowBytes; | 82 size_t m_rowBytes; |
87 bool discarded; | 83 bool discarded; |
88 }; | 84 }; |
89 | 85 |
90 } // namespace WebCore | 86 } // namespace WebCore |
91 | 87 |
92 #endif // MockDiscardablePixelRef_h | 88 #endif // MockDiscardablePixelRef_h |
OLD | NEW |