reed@google.com | 6997ebb | 2012-07-30 19:50:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
reed@google.com | 58b21ec | 2012-07-30 18:20:12 +0000 | [diff] [blame] | 8 | #include "SkImage_Base.h" |
reed@google.com | 889b09e | 2012-07-27 21:10:42 +0000 | [diff] [blame] | 9 | #include "SkImagePriv.h" |
reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 10 | #include "SkBitmap.h" |
mike@reedtribe.org | 70e3590 | 2012-07-29 20:38:16 +0000 | [diff] [blame] | 11 | #include "SkCanvas.h" |
reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 12 | |
robertphillips@google.com | a22e211 | 2012-08-16 14:58:06 +0000 | [diff] [blame^] | 13 | SK_DEFINE_INST_COUNT(SkImage) |
| 14 | |
reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 15 | static SkImage_Base* asIB(SkImage* image) { |
| 16 | return static_cast<SkImage_Base*>(image); |
| 17 | } |
| 18 | |
reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 19 | uint32_t SkImage::NextUniqueID() { |
| 20 | static int32_t gUniqueID; |
| 21 | |
| 22 | // never return 0; |
| 23 | uint32_t id; |
| 24 | do { |
| 25 | id = sk_atomic_inc(&gUniqueID) + 1; |
| 26 | } while (0 == id); |
| 27 | return id; |
| 28 | } |
| 29 | |
| 30 | void SkImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, |
| 31 | const SkPaint* paint) { |
mike@reedtribe.org | 70e3590 | 2012-07-29 20:38:16 +0000 | [diff] [blame] | 32 | asIB(this)->onDraw(canvas, x, y, paint); |
reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 33 | } |
| 34 | |