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

Side by Side Diff: src/device/xps/SkXPSDevice.cpp

Issue 19977003: drawBitmap* cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed bugs Created 7 years, 5 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
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.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 #ifndef UNICODE 8 #ifndef UNICODE
9 #define UNICODE 9 #define UNICODE
10 #endif 10 #endif
(...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 1942
1943 HRM(clipGeometry->SetFillRule(fillRule), 1943 HRM(clipGeometry->SetFillRule(fillRule),
1944 "Could not set fill rule."); 1944 "Could not set fill rule.");
1945 HRM(xpsVisual->SetClipGeometryLocal(clipGeometry.get()), 1945 HRM(xpsVisual->SetClipGeometryLocal(clipGeometry.get()),
1946 "Could not set clip geometry."); 1946 "Could not set clip geometry.");
1947 1947
1948 return S_OK; 1948 return S_OK;
1949 } 1949 }
1950 1950
1951 void SkXPSDevice::drawBitmap(const SkDraw& d, const SkBitmap& bitmap, 1951 void SkXPSDevice::drawBitmap(const SkDraw& d, const SkBitmap& bitmap,
1952 const SkIRect* srcRectOrNull,
1953 const SkMatrix& matrix, const SkPaint& paint) { 1952 const SkMatrix& matrix, const SkPaint& paint) {
1954 if (d.fClip->isEmpty()) { 1953 if (d.fClip->isEmpty()) {
1955 return; 1954 return;
1956 } 1955 }
1957 1956
1958 SkIRect srcRect; 1957 SkIRect srcRect;
1959 SkBitmap tmp; 1958 srcRect.set(0, 0, bitmap.width(), bitmap.height());
1960 const SkBitmap* bitmapPtr = &bitmap;
1961 if (NULL == srcRectOrNull) {
1962 srcRect.set(0, 0, bitmap.width(), bitmap.height());
1963 bitmapPtr = &bitmap;
1964 } else {
1965 srcRect = *srcRectOrNull;
1966 if (!bitmap.extractSubset(&tmp, srcRect)) {
1967 return; // extraction failed
1968 }
1969 bitmapPtr = &tmp;
1970 }
1971 1959
1972 //Create the new shaded path. 1960 //Create the new shaded path.
1973 SkTScopedComPtr<IXpsOMPath> shadedPath; 1961 SkTScopedComPtr<IXpsOMPath> shadedPath;
1974 HRVM(this->fXpsFactory->CreatePath(&shadedPath), 1962 HRVM(this->fXpsFactory->CreatePath(&shadedPath),
1975 "Could not create path for bitmap."); 1963 "Could not create path for bitmap.");
1976 1964
1977 //Create the shaded geometry. 1965 //Create the shaded geometry.
1978 SkTScopedComPtr<IXpsOMGeometry> shadedGeometry; 1966 SkTScopedComPtr<IXpsOMGeometry> shadedGeometry;
1979 HRVM(this->fXpsFactory->CreateGeometry(&shadedGeometry), 1967 HRVM(this->fXpsFactory->CreateGeometry(&shadedGeometry),
1980 "Could not create geometry for bitmap."); 1968 "Could not create geometry for bitmap.");
(...skipping 19 matching lines...) Expand all
2000 //TODO: perspective that bitmap! 1988 //TODO: perspective that bitmap!
2001 } 1989 }
2002 1990
2003 SkTScopedComPtr<IXpsOMGeometryFigure> rectFigure; 1991 SkTScopedComPtr<IXpsOMGeometryFigure> rectFigure;
2004 if (NULL != xpsTransform.get()) { 1992 if (NULL != xpsTransform.get()) {
2005 const SkShader::TileMode xy[2] = { 1993 const SkShader::TileMode xy[2] = {
2006 SkShader::kClamp_TileMode, 1994 SkShader::kClamp_TileMode,
2007 SkShader::kClamp_TileMode, 1995 SkShader::kClamp_TileMode,
2008 }; 1996 };
2009 SkTScopedComPtr<IXpsOMTileBrush> xpsImageBrush; 1997 SkTScopedComPtr<IXpsOMTileBrush> xpsImageBrush;
2010 HRV(this->createXpsImageBrush(*bitmapPtr, 1998 HRV(this->createXpsImageBrush(bitmap,
2011 transform, 1999 transform,
2012 xy, 2000 xy,
2013 paint.getAlpha(), 2001 paint.getAlpha(),
2014 &xpsImageBrush)); 2002 &xpsImageBrush));
2015 HRVM(shadedPath->SetFillBrushLocal(xpsImageBrush.get()), 2003 HRVM(shadedPath->SetFillBrushLocal(xpsImageBrush.get()),
2016 "Could not set bitmap brush."); 2004 "Could not set bitmap brush.");
2017 2005
2018 const SkRect bitmapRect = SkRect::MakeLTRB(0, 0, 2006 const SkRect bitmapRect = SkRect::MakeLTRB(0, 0,
2019 SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height())); 2007 SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
2020 HRV(this->createXpsRect(bitmapRect, FALSE, TRUE, &rectFigure)); 2008 HRV(this->createXpsRect(bitmapRect, FALSE, TRUE, &rectFigure));
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 IID_PPV_ARGS(&this->fXpsFactory)), 2435 IID_PPV_ARGS(&this->fXpsFactory)),
2448 "Could not create factory for layer."); 2436 "Could not create factory for layer.");
2449 2437
2450 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), 2438 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
2451 "Could not create canvas for layer."); 2439 "Could not create canvas for layer.");
2452 } 2440 }
2453 2441
2454 bool SkXPSDevice::allowImageFilter(SkImageFilter*) { 2442 bool SkXPSDevice::allowImageFilter(SkImageFilter*) {
2455 return false; 2443 return false;
2456 } 2444 }
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698