OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
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 #include "SkDeferredCanvas.h" | 9 #include "SkDeferredCanvas.h" |
10 | 10 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 virtual int width() const SK_OVERRIDE; | 160 virtual int width() const SK_OVERRIDE; |
161 virtual int height() const SK_OVERRIDE; | 161 virtual int height() const SK_OVERRIDE; |
162 virtual SkBitmap::Config config() const SK_OVERRIDE; | 162 virtual SkBitmap::Config config() const SK_OVERRIDE; |
163 virtual bool isOpaque() const SK_OVERRIDE; | 163 virtual bool isOpaque() const SK_OVERRIDE; |
164 virtual SkImageInfo imageInfo() const SK_OVERRIDE; | 164 virtual SkImageInfo imageInfo() const SK_OVERRIDE; |
165 | 165 |
166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
167 | 167 |
168 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; | 168 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; |
169 | 169 |
170 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG | |
171 virtual void writePixels(const SkBitmap& bitmap, int x, int y, | |
172 SkCanvas::Config8888 config8888) SK_OVERRIDE; | |
173 #endif | |
174 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; | 170 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
175 | 171 |
176 protected: | 172 protected: |
177 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 173 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; |
178 virtual bool onReadPixels(const SkBitmap& bitmap, | 174 virtual bool onReadPixels(const SkBitmap& bitmap, |
179 int x, int y, | 175 int x, int y, |
180 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 176 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
181 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i
nt y) SK_OVERRIDE; | 177 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i
nt y) SK_OVERRIDE; |
182 | 178 |
183 // The following methods are no-ops on a deferred device | 179 // The following methods are no-ops on a deferred device |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 bool mustNotifyDirectly = !fCanDiscardCanvasContents; | 462 bool mustNotifyDirectly = !fCanDiscardCanvasContents; |
467 this->aboutToDraw(); | 463 this->aboutToDraw(); |
468 if (mustNotifyDirectly) { | 464 if (mustNotifyDirectly) { |
469 fSurface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMo
de); | 465 fSurface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMo
de); |
470 } | 466 } |
471 } | 467 } |
472 | 468 |
473 fImmediateCanvas->flush(); | 469 fImmediateCanvas->flush(); |
474 } | 470 } |
475 | 471 |
476 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG | |
477 void SkDeferredDevice::writePixels(const SkBitmap& bitmap, int x, int y, | |
478 SkCanvas::Config8888 config8888) { | |
479 | |
480 if (x <= 0 && y <= 0 && (x + bitmap.width()) >= width() && | |
481 (y + bitmap.height()) >= height()) { | |
482 this->skipPendingCommands(); | |
483 } | |
484 | |
485 if (SkBitmap::kARGB_8888_Config == bitmap.config() && | |
486 SkCanvas::kNative_Premul_Config8888 != config8888 && | |
487 kPMColorAlias != config8888) { | |
488 //Special case config: no deferral | |
489 prepareForImmediatePixelWrite(); | |
490 immediateDevice()->writePixels(bitmap, x, y, config8888); | |
491 return; | |
492 } | |
493 | |
494 SkPaint paint; | |
495 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | |
496 if (shouldDrawImmediately(&bitmap, NULL, getBitmapSizeThreshold())) { | |
497 prepareForImmediatePixelWrite(); | |
498 fImmediateCanvas->drawSprite(bitmap, x, y, &paint); | |
499 } else { | |
500 this->recordingCanvas()->drawSprite(bitmap, x, y, &paint); | |
501 this->recordedDrawCommand(); | |
502 | |
503 } | |
504 } | |
505 #endif | |
506 | |
507 bool SkDeferredDevice::onWritePixels(const SkImageInfo& info, const void* pixels
, size_t rowBytes, | 472 bool SkDeferredDevice::onWritePixels(const SkImageInfo& info, const void* pixels
, size_t rowBytes, |
508 int x, int y) { | 473 int x, int y) { |
509 SkASSERT(x >= 0 && y >= 0); | 474 SkASSERT(x >= 0 && y >= 0); |
510 SkASSERT(x + info.width() <= width()); | 475 SkASSERT(x + info.width() <= width()); |
511 SkASSERT(y + info.height() <= height()); | 476 SkASSERT(y + info.height() <= height()); |
512 | 477 |
513 this->flushPendingCommands(kNormal_PlaybackMode); | 478 this->flushPendingCommands(kNormal_PlaybackMode); |
514 | 479 |
515 const SkImageInfo deviceInfo = this->imageInfo(); | 480 const SkImageInfo deviceInfo = this->imageInfo(); |
516 if (info.width() == deviceInfo.width() && info.height() == deviceInfo.height
()) { | 481 if (info.width() == deviceInfo.width() && info.height() == deviceInfo.height
()) { |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 987 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
1023 this->drawingCanvas()->setDrawFilter(filter); | 988 this->drawingCanvas()->setDrawFilter(filter); |
1024 this->INHERITED::setDrawFilter(filter); | 989 this->INHERITED::setDrawFilter(filter); |
1025 this->recordedDrawCommand(); | 990 this->recordedDrawCommand(); |
1026 return filter; | 991 return filter; |
1027 } | 992 } |
1028 | 993 |
1029 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 994 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
1030 return this->drawingCanvas(); | 995 return this->drawingCanvas(); |
1031 } | 996 } |
OLD | NEW |