| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkDevice.h" | 8 #include "SkDevice.h" |
| 9 #include "SkMetaData.h" | 9 #include "SkMetaData.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) { | 97 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) { |
| 98 const SkBitmap& bitmap = this->onAccessBitmap(); | 98 const SkBitmap& bitmap = this->onAccessBitmap(); |
| 99 if (changePixels) { | 99 if (changePixels) { |
| 100 bitmap.notifyPixelsChanged(); | 100 bitmap.notifyPixelsChanged(); |
| 101 } | 101 } |
| 102 return bitmap; | 102 return bitmap; |
| 103 } | 103 } |
| 104 | 104 |
| 105 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG | |
| 106 bool SkBaseDevice::readPixels(SkBitmap* bitmap, int x, int y, | |
| 107 SkCanvas::Config8888 config8888) { | |
| 108 if (SkBitmap::kARGB_8888_Config != bitmap->config() || | |
| 109 NULL != bitmap->getTexture()) { | |
| 110 return false; | |
| 111 } | |
| 112 | |
| 113 const SkBitmap& src = this->accessBitmap(false); | |
| 114 | |
| 115 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap->width(), | |
| 116 bitmap->height()); | |
| 117 SkIRect devbounds = SkIRect::MakeWH(src.width(), src.height()); | |
| 118 if (!srcRect.intersect(devbounds)) { | |
| 119 return false; | |
| 120 } | |
| 121 | |
| 122 SkBitmap tmp; | |
| 123 SkBitmap* bmp; | |
| 124 if (bitmap->isNull()) { | |
| 125 if (!tmp.allocPixels(SkImageInfo::MakeN32Premul(bitmap->width(), | |
| 126 bitmap->height()))) { | |
| 127 return false; | |
| 128 } | |
| 129 bmp = &tmp; | |
| 130 } else { | |
| 131 bmp = bitmap; | |
| 132 } | |
| 133 | |
| 134 SkIRect subrect = srcRect; | |
| 135 subrect.offset(-x, -y); | |
| 136 SkBitmap bmpSubset; | |
| 137 bmp->extractSubset(&bmpSubset, subrect); | |
| 138 | |
| 139 bool result = this->onReadPixels(bmpSubset, | |
| 140 srcRect.fLeft, | |
| 141 srcRect.fTop, | |
| 142 config8888); | |
| 143 if (result && bmp == &tmp) { | |
| 144 tmp.swap(*bitmap); | |
| 145 } | |
| 146 return result; | |
| 147 } | |
| 148 bool SkBaseDevice::onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8
888) { | |
| 149 return false; | |
| 150 } | |
| 151 #endif | |
| 152 | |
| 153 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; } | 105 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; } |
| 154 | 106 |
| 155 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; } | 107 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; } |
| 156 | 108 |
| 157 void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 109 void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 158 const SkRRect& inner, const SkPaint& paint) { | 110 const SkRRect& inner, const SkPaint& paint) { |
| 159 SkPath path; | 111 SkPath path; |
| 160 path.addRRect(outer); | 112 path.addRRect(outer); |
| 161 path.addRRect(inner); | 113 path.addRRect(inner); |
| 162 path.setFillType(SkPath::kEvenOdd_FillType); | 114 path.setFillType(SkPath::kEvenOdd_FillType); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 172 } |
| 221 | 173 |
| 222 void SkBaseDevice::EXPERIMENTAL_optimize(SkPicture* picture) { | 174 void SkBaseDevice::EXPERIMENTAL_optimize(SkPicture* picture) { |
| 223 // The base class doesn't perform any analysis but derived classes may | 175 // The base class doesn't perform any analysis but derived classes may |
| 224 } | 176 } |
| 225 | 177 |
| 226 bool SkBaseDevice::EXPERIMENTAL_drawPicture(const SkPicture& picture) { | 178 bool SkBaseDevice::EXPERIMENTAL_drawPicture(const SkPicture& picture) { |
| 227 // The base class doesn't perform any accelerated picture rendering | 179 // The base class doesn't perform any accelerated picture rendering |
| 228 return false; | 180 return false; |
| 229 } | 181 } |
| OLD | NEW |