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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 154163002: remove SkCanvas::createCompatibleDevice, and add SkCanvas::newSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 2008 The Android Open Source Project 3 * Copyright 2008 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 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 *intersection = ir; 825 *intersection = ir;
826 } 826 }
827 return true; 827 return true;
828 } 828 }
829 829
830 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, 830 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
831 SaveFlags flags) { 831 SaveFlags flags) {
832 return this->internalSaveLayer(bounds, paint, flags, false); 832 return this->internalSaveLayer(bounds, paint, flags, false);
833 } 833 }
834 834
835 static SkBaseDevice* createCompatibleDevice(SkCanvas* canvas,
836 SkBitmap::Config config,
837 int width, int height,
838 bool isOpaque) {
839 SkBaseDevice* device = canvas->getDevice();
840 if (device) {
841 return device->createCompatibleDevice(config, width, height, isOpaque);
842 } else {
843 return NULL;
844 }
845 }
846
847 #ifdef SK_SUPPORT_LEGACY_CANVAS_CREATECOMPATIBLEDEVICE
848 SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
849 int width, int height,
850 bool isOpaque) {
851 return createCompatibleDevice(this, config, width, height, isOpaque);
852 }
853 #endif
854
835 int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, 855 int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
836 SaveFlags flags, bool justForImageFilter) { 856 SaveFlags flags, bool justForImageFilter) {
837 // do this before we create the layer. We don't call the public save() since 857 // do this before we create the layer. We don't call the public save() since
838 // that would invoke a possibly overridden virtual 858 // that would invoke a possibly overridden virtual
839 int count = this->internalSave(flags); 859 int count = this->internalSave(flags);
840 860
841 fDeviceCMDirty = true; 861 fDeviceCMDirty = true;
842 862
843 SkIRect ir; 863 SkIRect ir;
844 if (!this->clipRectBounds(bounds, flags, &ir)) { 864 if (!this->clipRectBounds(bounds, flags, &ir)) {
(...skipping 12 matching lines...) Expand all
857 p->setImageFilter(NULL); 877 p->setImageFilter(NULL);
858 paint = p; 878 paint = p;
859 } 879 }
860 } 880 }
861 881
862 bool isOpaque; 882 bool isOpaque;
863 SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque); 883 SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque);
864 884
865 SkBaseDevice* device; 885 SkBaseDevice* device;
866 if (paint && paint->getImageFilter()) { 886 if (paint && paint->getImageFilter()) {
867 device = this->createCompatibleDevice(config, ir.width(), ir.height(), 887 device = createCompatibleDevice(this, config, ir.width(), ir.height(),
868 isOpaque); 888 isOpaque);
869 } else { 889 } else {
870 device = this->createLayerDevice(config, ir.width(), ir.height(), 890 device = this->createLayerDevice(config, ir.width(), ir.height(),
871 isOpaque); 891 isOpaque);
872 } 892 }
873 if (NULL == device) { 893 if (NULL == device) {
874 SkDebugf("Unable to create device for layer."); 894 SkDebugf("Unable to create device for layer.");
875 return count; 895 return count;
876 } 896 }
877 897
878 device->setOrigin(ir.fLeft, ir.fTop); 898 device->setOrigin(ir.fLeft, ir.fTop);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 int n = this->getSaveCount() - count; 977 int n = this->getSaveCount() - count;
958 for (int i = 0; i < n; ++i) { 978 for (int i = 0; i < n; ++i) {
959 this->restore(); 979 this->restore();
960 } 980 }
961 } 981 }
962 982
963 bool SkCanvas::isDrawingToLayer() const { 983 bool SkCanvas::isDrawingToLayer() const {
964 return fSaveLayerCount > 0; 984 return fSaveLayerCount > 0;
965 } 985 }
966 986
987 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) {
988 return this->onNewSurface(info);
989 }
990
991 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) {
992 SkBaseDevice* dev = this->getDevice();
993 return dev ? dev->newSurface(info) : NULL;
994 }
995
967 ///////////////////////////////////////////////////////////////////////////// 996 /////////////////////////////////////////////////////////////////////////////
968 997
969 // can't draw it if its empty, or its too big for a fixed-point width or height 998 // can't draw it if its empty, or its too big for a fixed-point width or height
970 static bool reject_bitmap(const SkBitmap& bitmap) { 999 static bool reject_bitmap(const SkBitmap& bitmap) {
971 return bitmap.width() <= 0 || bitmap.height() <= 0; 1000 return bitmap.width() <= 0 || bitmap.height() <= 0;
972 } 1001 }
973 1002
974 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, 1003 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
975 const SkMatrix& matrix, const SkPaint* paint) { 1004 const SkMatrix& matrix, const SkPaint* paint) {
976 if (reject_bitmap(bitmap)) { 1005 if (reject_bitmap(bitmap)) {
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 bool isOpaque) { 1570 bool isOpaque) {
1542 SkBaseDevice* device = this->getTopDevice(); 1571 SkBaseDevice* device = this->getTopDevice();
1543 if (device) { 1572 if (device) {
1544 return device->createCompatibleDeviceForSaveLayer(config, width, height, 1573 return device->createCompatibleDeviceForSaveLayer(config, width, height,
1545 isOpaque); 1574 isOpaque);
1546 } else { 1575 } else {
1547 return NULL; 1576 return NULL;
1548 } 1577 }
1549 } 1578 }
1550 1579
1551 SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
1552 int width, int height,
1553 bool isOpaque) {
1554 SkBaseDevice* device = this->getDevice();
1555 if (device) {
1556 return device->createCompatibleDevice(config, width, height, isOpaque);
1557 } else {
1558 return NULL;
1559 }
1560 }
1561
1562 GrContext* SkCanvas::getGrContext() { 1580 GrContext* SkCanvas::getGrContext() {
1563 #if SK_SUPPORT_GPU 1581 #if SK_SUPPORT_GPU
1564 SkBaseDevice* device = this->getTopDevice(); 1582 SkBaseDevice* device = this->getTopDevice();
1565 if (NULL != device) { 1583 if (NULL != device) {
1566 GrRenderTarget* renderTarget = device->accessRenderTarget(); 1584 GrRenderTarget* renderTarget = device->accessRenderTarget();
1567 if (NULL != renderTarget) { 1585 if (NULL != renderTarget) {
1568 return renderTarget->getContext(); 1586 return renderTarget->getContext();
1569 } 1587 }
1570 } 1588 }
1571 #endif 1589 #endif
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 return *paint; 2236 return *paint;
2219 } 2237 }
2220 2238
2221 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2239 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2222 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2240 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2223 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2241 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2224 2242
2225 /////////////////////////////////////////////////////////////////////////////// 2243 ///////////////////////////////////////////////////////////////////////////////
2226 2244
2227 SkCanvas::ClipVisitor::~ClipVisitor() { } 2245 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698