| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
| 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 #ifndef SkDevice_DEFINED | 8 #ifndef SkDevice_DEFINED |
| 9 #define SkDevice_DEFINED | 9 #define SkDevice_DEFINED |
| 10 | 10 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const SkColor colors[], SkXfermode* xmode, | 229 const SkColor colors[], SkXfermode* xmode, |
| 230 const uint16_t indices[], int indexCount, | 230 const uint16_t indices[], int indexCount, |
| 231 const SkPaint& paint) = 0; | 231 const SkPaint& paint) = 0; |
| 232 // default implementation unrolls the blob runs. | 232 // default implementation unrolls the blob runs. |
| 233 virtual void drawTextBlob(const SkDraw&, const SkTextBlob*, SkScalar x, SkSc
alar y, | 233 virtual void drawTextBlob(const SkDraw&, const SkTextBlob*, SkScalar x, SkSc
alar y, |
| 234 const SkPaint& paint); | 234 const SkPaint& paint); |
| 235 // default implementation calls drawVertices | 235 // default implementation calls drawVertices |
| 236 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], | 236 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], |
| 237 const SkPoint texCoords[4], SkXfermode* xmode, const
SkPaint& paint); | 237 const SkPoint texCoords[4], SkXfermode* xmode, const
SkPaint& paint); |
| 238 /** The SkDevice passed will be an SkDevice which was returned by a call to | 238 /** The SkDevice passed will be an SkDevice which was returned by a call to |
| 239 onCreateDevice on this device with kSaveLayer_Usage. | 239 onCreateCompatibleDevice on this device with kSaveLayer_Usage. |
| 240 */ | 240 */ |
| 241 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 241 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
| 242 const SkPaint&) = 0; | 242 const SkPaint&) = 0; |
| 243 | 243 |
| 244 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); | 244 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); |
| 245 | 245 |
| 246 /////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////// |
| 247 | 247 |
| 248 /** Update as needed the pixel value in the bitmap, so that the caller can | 248 /** Update as needed the pixel value in the bitmap, so that the caller can |
| 249 access the pixels directly. | 249 access the pixels directly. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 * if all rendering has been done. If false is returned, SkCanvas will | 333 * if all rendering has been done. If false is returned, SkCanvas will |
| 334 * perform its own rendering pass. It is acceptable for the backend | 334 * perform its own rendering pass. It is acceptable for the backend |
| 335 * to perform some device-specific warm up tasks and then let SkCanvas | 335 * to perform some device-specific warm up tasks and then let SkCanvas |
| 336 * perform the main rendering loop (by return false from here). | 336 * perform the main rendering loop (by return false from here). |
| 337 */ | 337 */ |
| 338 virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkM
atrix*, | 338 virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkM
atrix*, |
| 339 const SkPaint*); | 339 const SkPaint*); |
| 340 | 340 |
| 341 void setPixelGeometry(SkPixelGeometry geo); | 341 void setPixelGeometry(SkPixelGeometry geo); |
| 342 | 342 |
| 343 struct CreateInfo { |
| 344 CreateInfo(const SkImageInfo& info, Usage usage) : fInfo(info), fUsage(u
sage) {} |
| 345 |
| 346 SkImageInfo fInfo; |
| 347 Usage fUsage; |
| 348 }; |
| 349 virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& cinfo) { |
| 350 return NULL; |
| 351 } |
| 352 |
| 343 private: | 353 private: |
| 344 friend class SkCanvas; | 354 friend class SkCanvas; |
| 345 friend struct DeviceCM; //for setMatrixClip | 355 friend struct DeviceCM; //for setMatrixClip |
| 346 friend class SkDraw; | 356 friend class SkDraw; |
| 347 friend class SkDrawIter; | 357 friend class SkDrawIter; |
| 348 friend class SkDeviceFilteredPaint; | 358 friend class SkDeviceFilteredPaint; |
| 349 friend class SkDeviceImageFilterProxy; | 359 friend class SkDeviceImageFilterProxy; |
| 350 friend class SkDeferredDevice; // for newSurface | 360 friend class SkDeferredDevice; // for newSurface |
| 351 | 361 |
| 352 friend class SkSurface_Raster; | 362 friend class SkSurface_Raster; |
| 353 | 363 |
| 354 // used to change the backend's pixels (and possibly config/rowbytes) | 364 // used to change the backend's pixels (and possibly config/rowbytes) |
| 355 // but cannot change the width/height, so there should be no change to | 365 // but cannot change the width/height, so there should be no change to |
| 356 // any clip information. | 366 // any clip information. |
| 357 // TODO: move to SkBitmapDevice | 367 // TODO: move to SkBitmapDevice |
| 358 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {} | 368 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {} |
| 359 | 369 |
| 360 virtual bool forceConservativeRasterClip() const { return false; } | 370 virtual bool forceConservativeRasterClip() const { return false; } |
| 361 | 371 |
| 362 // just called by SkCanvas when built as a layer | 372 // just called by SkCanvas when built as a layer |
| 363 void setOrigin(int x, int y) { fOrigin.set(x, y); } | 373 void setOrigin(int x, int y) { fOrigin.set(x, y); } |
| 364 // just called by SkCanvas for saveLayer | 374 // just called by SkCanvas for saveLayer |
| 365 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&); | 375 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&); |
| 366 // just called by SkCanvas for imagefilter | 376 // just called by SkCanvas for imagefilter |
| 367 SkBaseDevice* createCompatibleDeviceForImageFilter(const SkImageInfo&); | 377 SkBaseDevice* createCompatibleDeviceForImageFilter(const SkImageInfo&); |
| 368 | 378 |
| 369 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) { | |
| 370 return NULL; | |
| 371 } | |
| 372 | |
| 373 /** Causes any deferred drawing to the device to be completed. | 379 /** Causes any deferred drawing to the device to be completed. |
| 374 */ | 380 */ |
| 375 virtual void flush() {} | 381 virtual void flush() {} |
| 376 | 382 |
| 377 virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; } | 383 virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; } |
| 378 | 384 |
| 379 SkIPoint fOrigin; | 385 SkIPoint fOrigin; |
| 380 SkMetaData* fMetaData; | 386 SkMetaData* fMetaData; |
| 381 SkDeviceProperties* fLeakyProperties; // will always exist. | 387 SkDeviceProperties* fLeakyProperties; // will always exist. |
| 382 | 388 |
| 383 #ifdef SK_DEBUG | 389 #ifdef SK_DEBUG |
| 384 bool fAttachedToCanvas; | 390 bool fAttachedToCanvas; |
| 385 #endif | 391 #endif |
| 386 | 392 |
| 387 typedef SkRefCnt INHERITED; | 393 typedef SkRefCnt INHERITED; |
| 388 }; | 394 }; |
| 389 | 395 |
| 390 #endif | 396 #endif |
| OLD | NEW |