| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkDevice_DEFINED | 10 #ifndef SkDevice_DEFINED |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const SkPoint verts[], const SkPoint texs[], | 280 const SkPoint verts[], const SkPoint texs[], |
| 281 const SkColor colors[], SkXfermode* xmode, | 281 const SkColor colors[], SkXfermode* xmode, |
| 282 const uint16_t indices[], int indexCount, | 282 const uint16_t indices[], int indexCount, |
| 283 const SkPaint& paint) = 0; | 283 const SkPaint& paint) = 0; |
| 284 /** The SkDevice passed will be an SkDevice which was returned by a call to | 284 /** The SkDevice passed will be an SkDevice which was returned by a call to |
| 285 onCreateDevice on this device with kSaveLayer_Usage. | 285 onCreateDevice on this device with kSaveLayer_Usage. |
| 286 */ | 286 */ |
| 287 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 287 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
| 288 const SkPaint&) = 0; | 288 const SkPaint&) = 0; |
| 289 | 289 |
| 290 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG | |
| 291 /** | |
| 292 * On success (returns true), copy the device pixels into the bitmap. | |
| 293 * On failure, the bitmap parameter is left unchanged and false is | |
| 294 * returned. | |
| 295 * | |
| 296 * The device's pixels are converted to the bitmap's config. The only | |
| 297 * supported config is kARGB_8888_Config, though this is likely to be | |
| 298 * relaxed in the future. The meaning of config kARGB_8888_Config is | |
| 299 * modified by the enum param config8888. The default value interprets | |
| 300 * kARGB_8888_Config as SkPMColor | |
| 301 * | |
| 302 * If the bitmap has pixels already allocated, the device pixels will be | |
| 303 * written there. If not, bitmap->allocPixels() will be called | |
| 304 * automatically. If the bitmap is backed by a texture readPixels will | |
| 305 * fail. | |
| 306 * | |
| 307 * The actual pixels written is the intersection of the device's bounds, | |
| 308 * and the rectangle formed by the bitmap's width,height and the specified | |
| 309 * x,y. If bitmap pixels extend outside of that intersection, they will not | |
| 310 * be modified. | |
| 311 * | |
| 312 * Other failure conditions: | |
| 313 * * If the device is not a raster device (e.g. PDF) then readPixels will | |
| 314 * fail. | |
| 315 * * If bitmap is texture-backed then readPixels will fail. (This may be | |
| 316 * relaxed in the future.) | |
| 317 */ | |
| 318 bool readPixels(SkBitmap* bitmap, | |
| 319 int x, int y, | |
| 320 SkCanvas::Config8888 config8888); | |
| 321 #endif | |
| 322 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); | 290 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); |
| 323 | 291 |
| 324 /////////////////////////////////////////////////////////////////////////// | 292 /////////////////////////////////////////////////////////////////////////// |
| 325 | 293 |
| 326 /** Update as needed the pixel value in the bitmap, so that the caller can | 294 /** Update as needed the pixel value in the bitmap, so that the caller can |
| 327 access the pixels directly. | 295 access the pixels directly. |
| 328 @return The device contents as a bitmap | 296 @return The device contents as a bitmap |
| 329 */ | 297 */ |
| 330 virtual const SkBitmap& onAccessBitmap() = 0; | 298 virtual const SkBitmap& onAccessBitmap() = 0; |
| 331 | 299 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 356 * Related (but not required) to canHandleImageFilter, this method returns | 324 * Related (but not required) to canHandleImageFilter, this method returns |
| 357 * true if the device could apply the filter to the src bitmap and return | 325 * true if the device could apply the filter to the src bitmap and return |
| 358 * the result (and updates offset as needed). | 326 * the result (and updates offset as needed). |
| 359 * If the device does not recognize or support this filter, | 327 * If the device does not recognize or support this filter, |
| 360 * it just returns false and leaves result and offset unchanged. | 328 * it just returns false and leaves result and offset unchanged. |
| 361 */ | 329 */ |
| 362 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, | 330 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, |
| 363 const SkImageFilter::Context& ctx, | 331 const SkImageFilter::Context& ctx, |
| 364 SkBitmap* result, SkIPoint* offset) = 0; | 332 SkBitmap* result, SkIPoint* offset) = 0; |
| 365 | 333 |
| 366 #ifdef SK_SUPPORT_LEGACY_CONFIG8888 | |
| 367 // This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if | |
| 368 // either is identical to kNative_Premul_Config8888. Otherwise, -1. | |
| 369 static const SkCanvas::Config8888 kPMColorAlias; | |
| 370 #endif | |
| 371 | |
| 372 protected: | 334 protected: |
| 373 // default impl returns NULL | 335 // default impl returns NULL |
| 374 virtual SkSurface* newSurface(const SkImageInfo&); | 336 virtual SkSurface* newSurface(const SkImageInfo&); |
| 375 | 337 |
| 376 // default impl returns NULL | 338 // default impl returns NULL |
| 377 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes); | 339 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes); |
| 378 | 340 |
| 379 /** | 341 /** |
| 380 * Implements readPixels API. The caller will ensure that: | |
| 381 * 1. bitmap has pixel config kARGB_8888_Config. | |
| 382 * 2. bitmap has pixels. | |
| 383 * 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is | |
| 384 * contained in the device bounds. | |
| 385 */ | |
| 386 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG | |
| 387 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, SkCanvas::Co
nfig8888); | |
| 388 #endif | |
| 389 | |
| 390 /** | |
| 391 * The caller is responsible for "pre-clipping" the dst. The impl can assum
e that the dst | 342 * The caller is responsible for "pre-clipping" the dst. The impl can assum
e that the dst |
| 392 * image at the specified x,y offset will fit within the device's bounds. | 343 * image at the specified x,y offset will fit within the device's bounds. |
| 393 * | 344 * |
| 394 * This is explicitly asserted in readPixels(), the public way to call this
. | 345 * This is explicitly asserted in readPixels(), the public way to call this
. |
| 395 */ | 346 */ |
| 396 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y); | 347 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y); |
| 397 | 348 |
| 398 /** | 349 /** |
| 399 * The caller is responsible for "pre-clipping" the src. The impl can assum
e that the src | 350 * The caller is responsible for "pre-clipping" the src. The impl can assum
e that the src |
| 400 * image at the specified x,y offset will fit within the device's bounds. | 351 * image at the specified x,y offset will fit within the device's bounds. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 SkMetaData* fMetaData; | 431 SkMetaData* fMetaData; |
| 481 | 432 |
| 482 #ifdef SK_DEBUG | 433 #ifdef SK_DEBUG |
| 483 bool fAttachedToCanvas; | 434 bool fAttachedToCanvas; |
| 484 #endif | 435 #endif |
| 485 | 436 |
| 486 typedef SkRefCnt INHERITED; | 437 typedef SkRefCnt INHERITED; |
| 487 }; | 438 }; |
| 488 | 439 |
| 489 #endif | 440 #endif |
| OLD | NEW |