blob: f71e5d6dfa24ea4ee20556ebb84d607114800cd3 [file] [log] [blame]
Romain Guye2d345e2010-09-24 18:39:22 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
19#include <utils/StopWatch.h>
20
21#include "OpenGLDebugRenderer.h"
22
23namespace android {
24namespace uirenderer {
25
Romain Guy6b7bd242010-10-06 19:49:23 -070026void OpenGLDebugRenderer::prepare(bool opaque) {
Romain Guye2d345e2010-09-24 18:39:22 -070027 mPrimitivesCount = 0;
28 LOGD("========= Frame start =========");
Romain Guy6b7bd242010-10-06 19:49:23 -070029 OpenGLRenderer::prepare(opaque);
Romain Guye2d345e2010-09-24 18:39:22 -070030}
31
32void OpenGLDebugRenderer::finish() {
33 LOGD("========= Frame end =========");
34 LOGD("Primitives draw count = %d", mPrimitivesCount);
35 OpenGLRenderer::finish();
36}
37
38void OpenGLDebugRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
39 mPrimitivesCount++;
40 StopWatch w("composeLayer");
41 return OpenGLRenderer::composeLayer(current, previous);
42}
43
44int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -070045 SkPaint* p, int flags) {
Romain Guye2d345e2010-09-24 18:39:22 -070046 mPrimitivesCount++;
47 StopWatch w("saveLayer");
48 return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags);
49}
50
Romain Guy0fe478e2010-11-08 12:08:41 -080051void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList) {
52 mPrimitivesCount++;
53 StopWatch w("drawDisplayList");
54 OpenGLRenderer::drawDisplayList(displayList);
55}
56
Romain Guyada830f2011-01-13 12:13:20 -080057void OpenGLDebugRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
58 mPrimitivesCount++;
59 StopWatch w("drawLayer");
60 OpenGLRenderer::drawLayer(layer, x, y, paint);
61}
62
Romain Guye2d345e2010-09-24 18:39:22 -070063void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float left, float top,
Chet Haase5c13d892010-10-08 08:37:55 -070064 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070065 mPrimitivesCount++;
66 StopWatch w("drawBitmap");
67 OpenGLRenderer::drawBitmap(bitmap, left, top, paint);
68}
69
Chet Haase5c13d892010-10-08 08:37:55 -070070void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix,
71 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070072 mPrimitivesCount++;
73 StopWatch w("drawBitmapMatrix");
74 OpenGLRenderer::drawBitmap(bitmap, matrix, paint);
75}
76
77void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
78 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -070079 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070080 mPrimitivesCount++;
81 StopWatch w("drawBitmapRect");
82 OpenGLRenderer::drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
83 dstLeft, dstTop, dstRight, dstBottom, paint);
84}
85
Romain Guy4aa90572010-09-26 18:40:37 -070086void OpenGLDebugRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
Romain Guy4bb94202010-10-12 15:59:26 -070087 const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
Chet Haase5c13d892010-10-08 08:37:55 -070088 float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070089 mPrimitivesCount++;
90 StopWatch w("drawPatch");
Romain Guy4bb94202010-10-12 15:59:26 -070091 OpenGLRenderer::drawPatch(bitmap, xDivs, yDivs, colors, width, height, numColors,
Romain Guy4aa90572010-09-26 18:40:37 -070092 left, top, right, bottom, paint);
Romain Guye2d345e2010-09-24 18:39:22 -070093}
94
95void OpenGLDebugRenderer::drawColor(int color, SkXfermode::Mode mode) {
96 mPrimitivesCount++;
97 StopWatch w("drawColor");
98 OpenGLRenderer::drawColor(color, mode);
99}
100
101void OpenGLDebugRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -0700102 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -0700103 mPrimitivesCount++;
104 StopWatch w("drawRect");
105 OpenGLRenderer::drawRect(left, top, right, bottom, paint);
106}
107
108void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) {
109 mPrimitivesCount++;
110 StopWatch w("drawPath");
111 OpenGLRenderer::drawPath(path, paint);
112}
113
Chet Haase5c13d892010-10-08 08:37:55 -0700114void OpenGLDebugRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -0700115 mPrimitivesCount++;
116 StopWatch w("drawLines");
117 OpenGLRenderer::drawLines(points, count, paint);
118}
119
120void OpenGLDebugRenderer::drawText(const char* text, int bytesCount, int count, float x, float y,
121 SkPaint* paint) {
122 mPrimitivesCount++;
123 StopWatch w("drawText");
124 OpenGLRenderer::drawText(text, bytesCount, count, x, y, paint);
125}
126
127}; // namespace uirenderer
128}; // namespace android