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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1124003002: Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 #include "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrGpuResourcePriv.h" 12 #include "GrGpuResourcePriv.h"
13 #include "GrLayerHoister.h" 13 #include "GrLayerHoister.h"
14 #include "GrRecordReplaceDraw.h" 14 #include "GrRecordReplaceDraw.h"
15 #include "GrStrokeInfo.h" 15 #include "GrStrokeInfo.h"
16 #include "GrTextContext.h" 16 #include "GrTextContext.h"
17 #include "GrTracing.h" 17 #include "GrTracing.h"
18 #include "SkCanvasPriv.h" 18 #include "SkCanvasPriv.h"
19 #include "SkDeviceImageFilterProxy.h" 19 #include "SkDeviceImageFilterProxy.h"
20 #include "SkDrawProcs.h" 20 #include "SkDrawProcs.h"
21 #include "SkErrorInternals.h" 21 #include "SkErrorInternals.h"
22 #include "SkGlyphCache.h" 22 #include "SkGlyphCache.h"
23 #include "SkGrTexturePixelRef.h" 23 #include "SkGrTexturePixelRef.h"
24 #include "SkImage_Base.h"
25 #include "SkImageFilter.h" 24 #include "SkImageFilter.h"
26 #include "SkLayerInfo.h" 25 #include "SkLayerInfo.h"
27 #include "SkMaskFilter.h" 26 #include "SkMaskFilter.h"
28 #include "SkPathEffect.h" 27 #include "SkPathEffect.h"
29 #include "SkPicture.h" 28 #include "SkPicture.h"
30 #include "SkPictureData.h" 29 #include "SkPictureData.h"
31 #include "SkRRect.h" 30 #include "SkRRect.h"
32 #include "SkRecord.h" 31 #include "SkRecord.h"
33 #include "SkStroke.h" 32 #include "SkStroke.h"
34 #include "SkSurface.h" 33 #include "SkSurface.h"
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 // must be pushed upstack. 1723 // must be pushed upstack.
1725 AutoBitmapTexture abt(fContext, src, NULL, &texture); 1724 AutoBitmapTexture abt(fContext, src, NULL, &texture);
1726 if (!texture) { 1725 if (!texture) {
1727 return false; 1726 return false;
1728 } 1727 }
1729 1728
1730 return this->filterTexture(fContext, texture, src.width(), src.height(), 1729 return this->filterTexture(fContext, texture, src.width(), src.height(),
1731 filter, ctx, result, offset); 1730 filter, ctx, result, offset);
1732 } 1731 }
1733 1732
1734 static SkImageInfo make_info(GrTexture* tex, int w, int h, bool isOpaque) {
1735 const GrPixelConfig config = tex->config();
1736 SkColorType ct;
1737 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
1738 if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) {
1739 ct = kUnknown_SkColorType;
1740 }
1741 return SkImageInfo::Make(w, h, ct, at);
1742 }
1743
1744 static bool wrap_as_bm(const SkImage* image, SkBitmap* bm) {
1745 GrTexture* tex = image->getTexture();
1746 if (tex) {
1747 // TODO: handle the GrTexture directly, and skip GrPixelRef
1748 const SkImageInfo info = make_info(tex, image->width(), image->height(), image->isOpaque());
1749 bm->setInfo(info);
1750 bm->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, tex)))->unref();
1751 } else {
1752 if (!as_IB(image)->getROPixels(bm)) {
1753 return false;
1754 }
1755 }
1756 return true;
1757 }
1758
1759 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y,
1760 const SkPaint& paint) {
1761 SkBitmap bm;
1762 if (wrap_as_bm(image, &bm)) {
1763 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1764 }
1765 }
1766
1767 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
1768 const SkRect& dst, const SkPaint& paint) {
1769 SkBitmap bm;
1770 if (wrap_as_bm(image, &bm)) {
1771 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm apRectFlag);
1772 }
1773 }
1774
1775 /////////////////////////////////////////////////////////////////////////////// 1733 ///////////////////////////////////////////////////////////////////////////////
1776 1734
1777 // must be in SkCanvas::VertexMode order 1735 // must be in SkCanvas::VertexMode order
1778 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1736 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1779 kTriangles_GrPrimitiveType, 1737 kTriangles_GrPrimitiveType,
1780 kTriangleStrip_GrPrimitiveType, 1738 kTriangleStrip_GrPrimitiveType,
1781 kTriangleFan_GrPrimitiveType, 1739 kTriangleFan_GrPrimitiveType,
1782 }; 1740 };
1783 1741
1784 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 1742 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 #endif 2030 #endif
2073 } 2031 }
2074 2032
2075 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 2033 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
2076 // We always return a transient cache, so it is freed after each 2034 // We always return a transient cache, so it is freed after each
2077 // filter traversal. 2035 // filter traversal.
2078 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 2036 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2079 } 2037 }
2080 2038
2081 #endif 2039 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698