Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: src/utils/SkDeferredCanvas.cpp

Issue 199413013: add new readPixels with direct memory parameters (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 170 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
171 virtual void writePixels(const SkBitmap& bitmap, int x, int y, 171 virtual void writePixels(const SkBitmap& bitmap, int x, int y,
172 SkCanvas::Config8888 config8888) SK_OVERRIDE; 172 SkCanvas::Config8888 config8888) SK_OVERRIDE;
173 #endif 173 #endif
174 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; 174 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
175 175
176 protected: 176 protected:
177 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; 177 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
178 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
178 virtual bool onReadPixels(const SkBitmap& bitmap, 179 virtual bool onReadPixels(const SkBitmap& bitmap,
179 int x, int y, 180 int x, int y,
180 SkCanvas::Config8888 config8888) SK_OVERRIDE; 181 SkCanvas::Config8888 config8888) SK_OVERRIDE;
182 #endif
183 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) S K_OVERRIDE;
181 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i nt y) SK_OVERRIDE; 184 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i nt y) SK_OVERRIDE;
182 185
183 // The following methods are no-ops on a deferred device 186 // The following methods are no-ops on a deferred device
184 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { 187 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE {
185 return false; 188 return false;
186 } 189 }
187 190
188 // None of the following drawing methods should ever get called on the 191 // None of the following drawing methods should ever get called on the
189 // deferred device 192 // deferred device
190 virtual void clear(SkColor color) SK_OVERRIDE 193 virtual void clear(SkColor color) SK_OVERRIDE
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // will not be used with a deferred canvas (there is no API for that). 537 // will not be used with a deferred canvas (there is no API for that).
535 // And connecting a SkDeferredDevice to non-deferred canvas can result 538 // And connecting a SkDeferredDevice to non-deferred canvas can result
536 // in unpredictable behavior. 539 // in unpredictable behavior.
537 return immediateDevice()->createCompatibleDevice(info); 540 return immediateDevice()->createCompatibleDevice(info);
538 } 541 }
539 542
540 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) { 543 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) {
541 return this->immediateDevice()->newSurface(info); 544 return this->immediateDevice()->newSurface(info);
542 } 545 }
543 546
547 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
544 bool SkDeferredDevice::onReadPixels( 548 bool SkDeferredDevice::onReadPixels(
545 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { 549 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) {
546 this->flushPendingCommands(kNormal_PlaybackMode); 550 this->flushPendingCommands(kNormal_PlaybackMode);
547 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), 551 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap),
548 x, y, config8888); 552 x, y, config8888);
549 } 553 }
554 #endif
555
556 bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_ t rowBytes,
557 int x, int y) {
558 this->flushPendingCommands(kNormal_PlaybackMode);
559 return fImmediateCanvas->readPixels(info, pixels, rowBytes, x, y);
560 }
550 561
551 class AutoImmediateDrawIfNeeded { 562 class AutoImmediateDrawIfNeeded {
552 public: 563 public:
553 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap, 564 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap,
554 const SkPaint* paint) { 565 const SkPaint* paint) {
555 this->init(canvas, bitmap, paint); 566 this->init(canvas, bitmap, paint);
556 } 567 }
557 568
558 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkPaint* paint) { 569 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkPaint* paint) {
559 this->init(canvas, NULL, paint); 570 this->init(canvas, NULL, paint);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { 1033 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
1023 this->drawingCanvas()->setDrawFilter(filter); 1034 this->drawingCanvas()->setDrawFilter(filter);
1024 this->INHERITED::setDrawFilter(filter); 1035 this->INHERITED::setDrawFilter(filter);
1025 this->recordedDrawCommand(); 1036 this->recordedDrawCommand();
1026 return filter; 1037 return filter;
1027 } 1038 }
1028 1039
1029 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { 1040 SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
1030 return this->drawingCanvas(); 1041 return this->drawingCanvas();
1031 } 1042 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698