Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 void discard() | 45 void discard() |
| 46 { | 46 { |
| 47 ASSERT(!m_lockedMemory); | 47 ASSERT(!m_lockedMemory); |
| 48 discarded = true; | 48 discarded = true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 class Allocator : public SkBitmap::Allocator { | 51 class Allocator : public SkBitmap::Allocator { |
| 52 public: | 52 public: |
| 53 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable* ct) SK_OVERRIDE { | 53 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable* ct) SK_OVERRIDE { |
| 54 SkImageInfo info; | 54 const SkImageInfo info = dst->info(); |
|
f(malita)
2014/05/29 12:51:38
const SkImageInfo&
| |
| 55 if (!dst->asImageInfo(&info)) { | 55 if (kUnknown_SkColorType == info.colorType()) |
| 56 return false; | 56 return false; |
| 57 } | |
| 58 SkAutoTUnref<SkPixelRef> pr(new MockDiscardablePixelRef(info, dst->r owBytes())); | 57 SkAutoTUnref<SkPixelRef> pr(new MockDiscardablePixelRef(info, dst->r owBytes())); |
| 59 dst->setPixelRef(pr); | 58 dst->setPixelRef(pr); |
| 60 return true; | 59 return true; |
| 61 } | 60 } |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 SK_DECLARE_UNFLATTENABLE_OBJECT() | 63 SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 65 | 64 |
| 66 protected: | 65 protected: |
| 67 virtual bool onNewLockPixels(LockRec* rec) | 66 virtual bool onNewLockPixels(LockRec* rec) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 82 | 81 |
| 83 private: | 82 private: |
| 84 void* m_lockedMemory; | 83 void* m_lockedMemory; |
| 85 size_t m_rowBytes; | 84 size_t m_rowBytes; |
| 86 bool discarded; | 85 bool discarded; |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace WebCore | 88 } // namespace WebCore |
| 90 | 89 |
| 91 #endif // MockDiscardablePixelRef_h | 90 #endif // MockDiscardablePixelRef_h |
| OLD | NEW |