-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SkWindow.h"
#include "SkCanvas.h"
-#include "SkDevice.h"
#include "SkOSMenu.h"
+#include "SkSurface.h"
#include "SkSystemEventTypes.h"
#include "SkTime.h"
#define SK_EventDelayInval "\xd" "n" "\xa" "l"
-#define TEST_BOUNDERx
-
-#include "SkBounder.h"
-class TestSkBounder : public SkBounder {
-public:
- explicit TestSkBounder(const SkBitmap& bm) : fCanvas(bm) {}
-
-protected:
- virtual bool onIRect(const SkIRect& r) SK_OVERRIDE {
- SkRect rr;
-
- rr.set(SkIntToScalar(r.fLeft), SkIntToScalar(r.fTop),
- SkIntToScalar(r.fRight), SkIntToScalar(r.fBottom));
-
- SkPaint p;
-
- p.setStyle(SkPaint::kStroke_Style);
- p.setColor(SK_ColorYELLOW);
-
-#if 0
- rr.inset(SK_ScalarHalf, SK_ScalarHalf);
-#else
- rr.inset(-SK_ScalarHalf, -SK_ScalarHalf);
-#endif
-
- fCanvas.drawRect(rr, p);
- return true;
- }
-private:
- SkCanvas fCanvas;
-};
-
SkWindow::SkWindow() : fFocusView(NULL) {
fClicks.reset();
fWaitingOnInval = false;
fMenus.deleteAll();
}
-SkCanvas* SkWindow::createCanvas() {
- return new SkCanvas(this->getBitmap());
+SkSurface* SkWindow::createSurface() {
+ const SkBitmap& bm = this->getBitmap();
+ return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes());
}
void SkWindow::setMatrix(const SkMatrix& matrix) {
bm.setPixels(buffer);
#endif
- SkAutoTUnref<SkCanvas> canvas(this->createCanvas());
+ SkAutoTUnref<SkSurface> surface(this->createSurface());
+ SkCanvas* canvas = surface->getCanvas();
canvas->clipRegion(fDirtyRgn);
if (updateArea)
// might be made during the draw call.
fDirtyRgn.setEmpty();
-#ifdef TEST_BOUNDER
- TestSkBounder bounder(bm);
- canvas->setBounder(&bounder);
-#endif
#ifdef SK_SIMULATE_FAILED_MALLOC
gEnableControlledThrow = true;
#endif
#ifdef SK_SIMULATE_FAILED_MALLOC
gEnableControlledThrow = false;
#endif
-#ifdef TEST_BOUNDER
- canvas->setBounder(NULL);
-#endif
#if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN)
GXEndDraw();